Move is_compressed into comptolib

I think it makes more sense
This commit is contained in:
Mc-muffin
2023-05-19 07:50:04 -05:00
parent 69cd0b03d8
commit 7f8f153dbd
2 changed files with 17 additions and 13 deletions

View File

@@ -404,18 +404,6 @@ class ToolsTales:
# Didn't match anything
return None
def is_compressed(self,data):
if len(data) < 0x09:
return False
expected_size = struct.unpack("<L", data[1:5])[0]
tail_data = abs(len(data) - (expected_size + 9))
if expected_size == len(data) - 9:
return True
elif tail_data <= 0x10 and data[expected_size + 9 :] == b"#" * tail_data:
return True # SCPK files have these trailing "#" bytes :(
return False
def extract_Cab(self, cab_file_name, new_file_name, working_dir):

View File

@@ -101,4 +101,20 @@ def compress_file(input: str, output: str, raw: bool=False, version: int=3):
def decompress_file(input: str, output: str, raw: bool=False, version: int=3):
error = compto_fdecode(input.encode("utf-8"), output.encode("utf-8"), raw, version)
RaiseError(error)
RaiseError(error)
def is_compressed(data: bytes) -> bool:
if len(data) < 0x09:
return False
expected_size = struct.unpack("<L", data[1:5])[0]
tail_data = abs(len(data) - (expected_size + 9))
if expected_size == len(data) - 9:
return True
if tail_data <= 0x10 and data[expected_size + 9 :] == b"#" * tail_data:
return True # SCPK files have these trailing "#" bytes :(
return False