Utilities#
Binary Reader#
File IO#
- dk64_lib.file_io.get_bytes(fh, byte_count, position=None, keep_last_pos=False)[source]#
Reads bytes and returns them
- Parameters:
fh (FileIO) – File IO retrieve bytes from
byte_count (int) – Number of bytes to read
position (int | None, optional) – Position to seek to and read. Defaults to None.
keep_last_pos (bool, optional) – Whether or not to return to the last position before seeking. Defaults to False.
- Returns:
Read bytes
- Return type:
bytes
- dk64_lib.file_io.get_char(fh, position=None, keep_last_pos=False)[source]#
Reads one byte and returns it as an integer
- Parameters:
fh (FileIO) – File IO retrieve bytes from
position (int | None, optional) – Position to seek to and read. Defaults to None.
keep_last_pos (bool, optional) – Whether or not to return to the last position before seeking. Defaults to False.
- Returns:
Bytes as integer
- Return type:
int
- dk64_lib.file_io.get_short(fh, position=None, keep_last_pos=False)[source]#
Reads two bytes and returns them as an integer
- Parameters:
fh (FileIO) – File IO retrieve bytes from
position (int | None, optional) – Position to seek to and read. Defaults to None.
keep_last_pos (bool, optional) – Whether or not to return to the last position before seeking. Defaults to False.
- Returns:
Bytes as integer
- Return type:
int
- dk64_lib.file_io.get_long(fh, position=None, keep_last_pos=False)[source]#
Reads four bytes and returns them as an integer
- Parameters:
fh (FileIO) – File IO retrieve bytes from
position (int | None, optional) – Position to seek to and read. Defaults to None.
keep_last_pos (bool, optional) – Whether or not to return to the last position before seeking. Defaults to False.
- Returns:
Bytes as integer
- Return type:
int