pycdlib.pycdlibio¶
PyCdlibIO class.
- class PyCdlibIO(
- ino: Inode,
- logical_block_size: int,
The class that implements the user-facing python io-style context manager. Since ISOs are generally only readable, this is only a readable context manager.
- read(size: int | None = None) bytes¶
Read and return up to size bytes.
- Parameters:
size – Optional parameter to read size number of bytes; if None or negative, all remaining bytes in the file will be read
- Returns:
The number of bytes requested or the rest of the data left in the file, whichever is smaller. If the file is at or past EOF, returns an empty bytestring.
- readall() bytes¶
Read and return the remaining bytes in the file.
- Returns:
The rest of the data left in the file. If the file is at or past EOF, returns an empty bytestring.
- readinto(b: Buffer) int¶
Read bytes into a pre-allocated, writable buffer.
- Parameters:
b – A writable bytes-like object to read into.
- Returns:
The number of bytes read and stored into the buffer. This is 0 if the file is at or past EOF.
- seek(offset: int, whence: int = 0) int¶
Change the stream position to byte offset offset. The offset is interpreted relative to the position indicated by whence. Valid values for whence are:
0 – start of stream (the default); offset should be zero or positive
1 – current stream position; offset may be negative
2 – end of stream; offset is usually negative
- Parameters:
offset – The byte offset to seek to.
whence – The position in the file to start from (0 for start, 1 for current, 2 for end)
- Returns:
The new absolute position.
- tell() int¶
Return the current stream position.
- Returns:
The current stream position.
- length() int¶
Return the length of the current file.
- Returns:
The length of the file.
- readable() bool¶
Determine whether this file is readable.
- Returns:
True in all cases.
- seekable() bool¶
Determine whether this file is seekable.
- Returns:
True in all cases.
- close() None¶
Close this file stream.
- Returns:
Nothing.