fileio - Special files

This module contains some special file objects.

Classes

class pyctr.fileio.SubsectionIO(file, offset, size)

Provides read-write access to a subsection of a file. Data written after the end is discarded.

This class is thread-safe with other SubsectionIO objects. A thread lock is stored for each base file, meaning two SubsectionIO objects on one base file will use locks to prevent issues, while two with different base files can operate independently.

However this cannot protect against threaded access from somewhere else. If another function seeks, reads, or writes data to the base file at the same time, it could interfere and read or write the wrong data.

Available methods: close, read, seek, tell, write, readable, writable, seekable, flush.

Parameters:
  • file (binary file) – Base file.

  • offset (int) – Offset of the section.

  • size (int) – Size of the section.

class pyctr.fileio.SplitFileMerger(files, read_only=True, closefds=False)

Provides access to multiple file objects as one large file.

This is not thread-safe with other SplitFileMerger objects.

Note

Writing is not implemented yet.

Available methods: close, read, seek, tell, write, readable, writable, seekable.

Parameters:
  • files (Iterable[Tuple[(binary file), int]]) – A list of tuples with binary files and size.

  • read_only (bool) – Disable writing.

  • closefds (bool) – Close all file objects when this is closed.