Remove seek
arguments from read/write struct funcs
This commit is contained in:
parent
15cbb9e62a
commit
dd86df83aa
@ -480,8 +480,7 @@ def parse_fumen(fumen_file: str,
|
|||||||
|
|
||||||
def read_struct(file: BinaryIO,
|
def read_struct(file: BinaryIO,
|
||||||
order: str,
|
order: str,
|
||||||
format_string: str,
|
format_string: str) -> tuple[Any, ...]:
|
||||||
seek: int = 0) -> tuple[Any, ...]:
|
|
||||||
"""
|
"""
|
||||||
Interpret bytes as packed binary data.
|
Interpret bytes as packed binary data.
|
||||||
|
|
||||||
@ -497,8 +496,6 @@ def read_struct(file: BinaryIO,
|
|||||||
- interpreted_string: A string containing interpreted byte values,
|
- interpreted_string: A string containing interpreted byte values,
|
||||||
based on the specified 'fmt' format characters.
|
based on the specified 'fmt' format characters.
|
||||||
"""
|
"""
|
||||||
if seek:
|
|
||||||
file.seek(seek)
|
|
||||||
expected_size = struct.calcsize(order + format_string)
|
expected_size = struct.calcsize(order + format_string)
|
||||||
byte_string = file.read(expected_size)
|
byte_string = file.read(expected_size)
|
||||||
# One "official" fumen (AC11\deo\deo_n.bin) runs out of data early
|
# One "official" fumen (AC11\deo\deo_n.bin) runs out of data early
|
||||||
|
@ -55,10 +55,7 @@ def write_fumen(path_out: str, song: FumenCourse) -> None:
|
|||||||
def write_struct(file: BinaryIO,
|
def write_struct(file: BinaryIO,
|
||||||
order: str,
|
order: str,
|
||||||
format_string: str,
|
format_string: str,
|
||||||
value_list: list[Any],
|
value_list: list[Any]) -> None:
|
||||||
seek: int = 0) -> None:
|
|
||||||
"""Pack (int, float, etc.) values into a string of bytes, then write."""
|
"""Pack (int, float, etc.) values into a string of bytes, then write."""
|
||||||
if seek:
|
|
||||||
file.seek(seek)
|
|
||||||
packed_bytes = struct.pack(order + format_string, *value_list)
|
packed_bytes = struct.pack(order + format_string, *value_list)
|
||||||
file.write(packed_bytes)
|
file.write(packed_bytes)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user