FatIO

Implementation of FatIO for basic I/O.

class pyfatfs.FatIO.FatIO(fs: PyFat, path: str, mode: fs.mode.Mode = fs.mode.Mode)

Bases: RawIOBase

Wrap basic I/O operations for PyFat.

Wrap basic I/O operations for PyFat. Currently read-only.

Parameters:
  • fsPyFat: Instance of opened filesystem

  • pathstr: Path to file. If mode is r, the file must exist.

  • modeMode: Mode to open file in.

close() None

Close open file handles assuming lock handle.

read(size: int = -1) bytes | None

Read given bytes from file.

readable() bool

Determine whether the file is readable.

readinto(_FatIO__buffer: bytearray) int | None

Read data “directly” into bytearray.

seek(offset: int, whence: int = 0) int

Seek to a given offset in the file.

Parameters:
  • offsetint: offset in bytes in the file

  • whenceint: offset position: - 0: absolute - 1: relative to current position - 2: relative to file end

Returns:

New position in bytes in the file

seekable() bool

FAT I/O driver is able to seek in files.

Returns:

True

truncate(size: int | None = 0) int

Truncate file to given size.

Parameters:

sizeint: Size to truncate to, defaults to 0.

Returns:

int: Truncated size

writable() bool

Determine whether the file is writable.

write(_FatIO__b: bytes | bytearray) int | None

Write given bytes to file.