mirror of
https://github.com/Virtual-World-RE/NeoGF.git
synced 2024-11-15 15:05:34 +01:00
Update pzztest.py
This commit is contained in:
parent
54bf1b1d02
commit
550fd1c700
27
pzztest.py
27
pzztest.py
|
@ -6,7 +6,7 @@ import pzztool
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
|
|
||||||
TPL_MAGIC_FILE = b"\x00\x20\xAF\x30" # http://virtualre.rf.gd/index.php/TPL_(Format_de_fichier)
|
TPL_MAGIC_NUMBER = b"\x00\x20\xAF\x30" # http://virtualre.rf.gd/index.php/TPL_(Format_de_fichier)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,10 +41,9 @@ def get_argparser():
|
||||||
pzz2 : will be created with all pzz(pzz_folder) from pzzu folder
|
pzz2 : will be created with all pzz(pzz_folder) from pzzu folder
|
||||||
print file_name when sha256 is different between source_pzz_folder and pzz2 folder""")
|
print file_name when sha256 is different between source_pzz_folder and pzz2 folder""")
|
||||||
group.add_argument('-tctplh', '--test-check-tpl-headers', action='store_true', help="-tctplh afs_data_folder : check all files headers in the afs_data and print those who have the tpl magicfile")
|
group.add_argument('-tctplh', '--test-check-tpl-headers', action='store_true', help="-tctplh afs_data_folder : check all files headers in the afs_data and print those who have the tpl magicfile")
|
||||||
group.add_argument('-td', '--test-decompress', action='store_true', help="""
|
group.add_argument('-tcd', '--test-check-decompress', action='store_true', help="""
|
||||||
pzz : put all pzz in this folder
|
pzz : put all pzz in this folder
|
||||||
then tip "pzztool.py -td"
|
then tip "pzztool.py -tcd pzz"
|
||||||
decompressed_tpl_files : will be created with all decompressed files from pzzu having the tpl header
|
|
||||||
The script will then check that tpls are correctly decompressed with their specific characteristics""")
|
The script will then check that tpls are correctly decompressed with their specific characteristics""")
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
@ -103,16 +102,26 @@ if __name__ == '__main__':
|
||||||
os.system("python pzztool.py -bpzz pzzu pzz2")
|
os.system("python pzztool.py -bpzz pzzu pzz2")
|
||||||
verify_sha256(p_input, Path("pzz2"))
|
verify_sha256(p_input, Path("pzz2"))
|
||||||
elif args.test_check_tpl_headers:
|
elif args.test_check_tpl_headers:
|
||||||
# Démontre que SEUL les TPLs ont ce magicfile
|
# Démontre que SEUL les TPLs ont ce magicnumber
|
||||||
# TEST OK
|
# TEST OK
|
||||||
print("# TEST : CHECK TPLs HEADERS")
|
print("# TEST : CHECK TPLs HEADERS")
|
||||||
for afs_data_filename in os.listdir(p_input):
|
for afs_data_filename in os.listdir(p_input):
|
||||||
with open(p_input / afs_data_filename, "rb") as afs_data_file:
|
with open(p_input / afs_data_filename, "rb") as afs_data_file:
|
||||||
if TPL_MAGIC_FILE == afs_data_file.read(4) and Path(afs_data_filename).suffix != ".tpl":
|
if TPL_MAGIC_NUMBER == afs_data_file.read(4) and Path(afs_data_filename).suffix != ".tpl":
|
||||||
print(f"TPL magicfile found : afs_data.afs/{afs_data_filename}")
|
print(f"TPL magicfile found : afs_data.afs/{afs_data_filename}")
|
||||||
elif args.test_check_decompress:
|
elif args.test_check_decompress:
|
||||||
print("# TEST : CHECK DECOMPRESS")
|
print("# TEST : CHECK DECOMPRESS")
|
||||||
# create decompressed_tpl_files folder
|
# os.system(f"python pzztool.py -bunpzz {args.input_path} pzzu")
|
||||||
# copy pzzu files having the tpl header inside decompressed_tpl_files
|
|
||||||
# check that the length is a multiple of 32
|
invalid_files_count = 0
|
||||||
|
total = 0
|
||||||
|
# check that all TPLs length is a multiple of 32
|
||||||
|
for p in Path("pzzu").glob("**/*.tpl"):
|
||||||
|
if p.is_file():
|
||||||
|
#print(Path(p).stat().st_size)
|
||||||
|
total+=1
|
||||||
|
if (Path(p).stat().st_size % 32) != 0:
|
||||||
|
print(f"Invalid TPL file length modulo 32 ({Path(p).stat().st_size % 32}) - {p}")
|
||||||
|
invalid_files_count += 1
|
||||||
|
print(f"Invalid files : {invalid_files_count}/{total}")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user