diff --git a/TOR_Test.py b/TOR_Test.py index 0eed23f..e625a1e 100644 --- a/TOR_Test.py +++ b/TOR_Test.py @@ -29,4 +29,6 @@ tool.pack_Main_Archive() files = os.listdir("abcde_lauren") for file in files: - tool.extract_abcde_text("abcde_lauren/{}".format(file)) \ No newline at end of file + tool.extract_abcde_text("abcde_lauren/{}".format(file)) + + diff --git a/ToolsTOR.py b/ToolsTOR.py index 47134e1..6ec56b2 100644 --- a/ToolsTOR.py +++ b/ToolsTOR.py @@ -341,6 +341,10 @@ class ToolsTOR(ToolsTales): print("Writing file %05d/%05d..." % (i, total_files)) f.close() + #Copy File 11181 + shutil.copy( self.datPathExtract+"BIN/11181.bin", self.datPathExtract+"PAK3/11181.pak3") + os.remove( self.datPathExtract+"BIN/11181.bin") + def pack_Main_Archive(self): sectors = [0] remainders = [] diff --git a/ToolsTales.py b/ToolsTales.py index 93fb7a7..0f50d75 100644 --- a/ToolsTales.py +++ b/ToolsTales.py @@ -60,23 +60,42 @@ class ToolsTales: # action is -d or -c # fileType : -0, -1 or -3 # basePath is the location of the PAK file you want to compress/decompress - def pakComposer_Comptoe(self, fileName, action, fileType, do_comptoe, cwd): + def pakComposer_Comptoe(self, file_name, action, file_type, do_comptoe, working): - #Delete the file if already there + #Delete the file if already there + file_number = file_name.split(".")[0] if (action == '-c'): - if os.path.exists(fileName): - os.remove( fileName.replace(".pak{}", fileType[1])) - + if os.path.exists(file_name): + os.remove( file_name.replace(".pak{}", file_type[1])) + else: + + if os.path.exists(working+"/"+file_number): + shutil.rmtree(working+"/"+file_number) + #Run Pakcomposer with parameters - args = [ "pakcomposer", action, fileName, fileType] - if do_comptoe: - args.append("-u") - + args = [ "pakcomposer", action, file_name, file_type, "-x"] + listFile = subprocess.run( args, - cwd=cwd + cwd=working ) + if do_comptoe: + + files = [ele for ele in os.listdir(working+"/"+file_number) if ".compress" in ele] + for ele in files: + + ctype=0 + with open(working+"/{}/".format(file_number)+ele, "rb") as f: + ctype = ord(f.read(1)) + + args = ["comptoe", "-d{}".format(ctype), ele, ele.split(".")[0]+"d.unknown"] + listFile = subprocess.run( + args, + cwd=working+"/"+file_number + ) + + def fps4_action(self, action, b_file, dat_file, destination): fps4.dump_fps4(b_file, dat_file, destination) @@ -295,19 +314,6 @@ class ToolsTales: # Didn't match anything return "bin" - - def is_compressed(self, data): - if len(data) < 0x09: - return False - - expected_size = struct.unpack("