FileSection#

class barecat.FileSection(file, start, size, readonly=True)#

Bases: io.IOBase

File-like object representing a section of a file.

Parameters:
  • file (RawIOBase) – file-like object to read from or write to

  • start (int) – start position of the section in the file

  • size (int) – size of the section

  • readonly (bool) – whether the section should be read-only

Properties#

size

Size of the section in bytes.

Methods#

read([size])

Read a from the section, starting from the current position.

readinto(buffer)

Read bytes into a buffer from the section, starting from the current position.

readall()

Read all remaining bytes from the section.

readable()

Return whether object was opened for reading.

writable()

Return whether object was opened for writing.

write(data)

Write data to the section, starting from the current position.

readline([size])

Read and return a line from the stream.

tell()

Return current stream position.

seek(offset[, whence])

Change stream position.

close()

Flush and close the IO object.