1414 Copyright 2018-2024 Game Maker 2k - http://intdb.sourceforge.net/
1515 Copyright 2018-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
1616
17- $FileInfo: foxfile.py - Last Update: 11/6 /2025 Ver. 0.25.2 RC 1 - Author: cooldude2k $
17+ $FileInfo: foxfile.py - Last Update: 11/12 /2025 Ver. 0.26.0 RC 1 - Author: cooldude2k $
1818'''
1919
2020from __future__ import absolute_import , division , print_function , unicode_literals , generators , with_statement , nested_scopes
2121import os
2222import sys
23+ import logging
2324import argparse
24- import pyfoxfile
25+ import pyarchivefile
2526import binascii
2627
28+ # Text streams (as provided by Python)
29+ PY_STDIN_TEXT = sys .stdin
30+ PY_STDOUT_TEXT = sys .stdout
31+ PY_STDERR_TEXT = sys .stderr
32+
33+ # Binary-friendly streams (use .buffer on Py3, fall back on Py2)
34+ PY_STDIN_BUF = getattr (sys .stdin , "buffer" , sys .stdin )
35+ PY_STDOUT_BUF = getattr (sys .stdout , "buffer" , sys .stdout )
36+ PY_STDERR_BUF = getattr (sys .stderr , "buffer" , sys .stderr )
37+ logging .basicConfig (format = "%(message)s" , stream = PY_STDOUT_TEXT , level = logging .DEBUG )
38+
2739# Conditional import and signal handling for Unix-like systems
2840if os .name != 'nt' : # Not Windows
2941 import signal
@@ -117,7 +129,8 @@ def handler(signum, frame):
117129argparser .add_argument ("-v" , "--validate" , action = "store_true" , help = "Validate archive file checksums." )
118130argparser .add_argument ("-C" , "--checksum" , default = "md5" , help = "Specify the type of checksum to use. The default is crc32." )
119131argparser .add_argument ("-s" , "--skipchecksum" , action = "store_true" , help = "Skip the checksum check of files." )
120- argparser .add_argument ("-k" , "--secretkey" , default = None , help = "Secretkey to use for checksum." )
132+ argparser .add_argument ("-k" , "--insecretkey" , default = None , help = "Secretkey to use for checksum input." )
133+ argparser .add_argument ("-K" , "--outsecretkey" , default = None , help = "Secretkey to use for checksum output." )
121134# Permissions and metadata
122135argparser .add_argument ("-p" , "--preserve" , action = "store_false" , help = "Do not preserve permissions and timestamps of files." )
123136# Miscellaneous
@@ -154,38 +167,38 @@ def handler(signum, frame):
154167 checkcompressfile = pyfoxfile .CheckCompressionSubType (
155168 input_file , fnamedict , True )
156169 if ((pyfoxfile .IsNestedDict (fnamedict ) and checkcompressfile in fnamedict ) or (pyfoxfile .IsSingleDict (fnamedict ) and checkcompressfile == fnamedict ['format_magic' ])):
157- tmpout = pyfoxfile .RePackFoxFile (input_file , getargs .output , "auto" , getargs .compression , getargs .wholefile , getargs .level , pyfoxfile .compressionlistalt , False , getargs .filestart , 0 , 0 , [getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum ], getargs .skipchecksum , [], {}, fnamedict , getargs .secretkey , getargs .secretkey , getargs .verbose , False )
170+ tmpout = pyfoxfile .RePackFoxFile (input_file , getargs .output , "auto" , getargs .compression , getargs .wholefile , getargs .level , pyfoxfile .compressionlistalt , False , getargs .filestart , 0 , 0 , [getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum ], getargs .skipchecksum , [], {}, fnamedict , getargs .insecretkey , getargs .outsecretkey , False , getargs .verbose , False )
158171 else :
159172 tmpout = pyfoxfile .PackFoxFileFromInFile (
160- input_file , getargs .output , __file_format_default__ , getargs .compression , getargs .wholefile , getargs .level , pyfoxfile .compressionlistalt , [getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum ], [], {}, fnamedict , getargs .secretkey , getargs .verbose , False )
173+ input_file , getargs .output , __file_format_default__ , getargs .compression , getargs .wholefile , getargs .level , pyfoxfile .compressionlistalt , [getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum ], [], {}, fnamedict , getargs .insecretkey , getargs .verbose , False )
161174 if (not tmpout ):
162175 sys .exit (1 )
163176 else :
164- pyfoxfile .PackFoxFile (getargs .input , getargs .output , getargs .text , __file_format_default__ , getargs .compression , getargs .wholefile , getargs .level , pyfoxfile .compressionlistalt , False , [getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum ], [], {}, fnamedict , getargs .secretkey , getargs .verbose , False )
177+ pyfoxfile .PackFoxFile (getargs .input , getargs .output , getargs .text , __file_format_default__ , getargs .compression , getargs .wholefile , getargs .level , pyfoxfile .compressionlistalt , False , [getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum ], [], {}, fnamedict , getargs .insecretkey , getargs .verbose , False )
165178 elif active_action == 'repack' :
166179 if getargs .convert :
167180 checkcompressfile = pyfoxfile .CheckCompressionSubType (
168181 input_file , fnamedict , True )
169182 if ((pyfoxfile .IsNestedDict (fnamedict ) and checkcompressfile in fnamedict ) or (pyfoxfile .IsSingleDict (fnamedict ) and checkcompressfile == fnamedict ['format_magic' ])):
170183 pyfoxfile .RePackFoxFile (input_file , getargs .output , "auto" , getargs .compression , getargs .wholefile , getargs .level , pyfoxfile .compressionlistalt ,
171- False , getargs .filestart , 0 , 0 , [getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum ], getargs .skipchecksum , [], {}, fnamedict , getargs .secretkey , getargs .secretkey , getargs .verbose , False )
184+ False , getargs .filestart , 0 , 0 , [getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum ], getargs .skipchecksum , [], {}, fnamedict , getargs .insecretkey , getargs .outsecretkey , False , getargs .verbose , False )
172185 else :
173- pyfoxfile .PackFoxFileFromInFile (input_file , getargs .output , __file_format_default__ , getargs .compression , getargs .wholefile , getargs .level , pyfoxfile .compressionlistalt , [getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum ], [], {}, fnamedict , getargs .secretkey , getargs .verbose , False )
186+ pyfoxfile .PackFoxFileFromInFile (input_file , getargs .output , __file_format_default__ , getargs .compression , getargs .wholefile , getargs .level , pyfoxfile .compressionlistalt , [getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum ], [], {}, fnamedict , getargs .insecretkey , getargs .verbose , False )
174187 if (not tmpout ):
175188 sys .exit (1 )
176189 else :
177190 pyfoxfile .RePackFoxFile (input_file , getargs .output , "auto" , getargs .compression , getargs .wholefile , getargs .level , pyfoxfile .compressionlistalt ,
178- False , getargs .filestart , 0 , 0 , [getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum ], getargs .skipchecksum , [], {}, fnamedict , getargs .secretkey , getargs .secretkey , getargs .verbose , False )
191+ False , getargs .filestart , 0 , 0 , [getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum ], getargs .skipchecksum , [], {}, fnamedict , getargs .insecretkey , getargs .outsecretkey , False , getargs .verbose , False )
179192 elif active_action == 'extract' :
180193 if getargs .convert :
181194 checkcompressfile = pyfoxfile .CheckCompressionSubType (
182195 input_file , fnamedict , True )
183196 tempout = BytesIO ()
184197 if ((pyfoxfile .IsNestedDict (fnamedict ) and checkcompressfile in fnamedict ) or (pyfoxfile .IsSingleDict (fnamedict ) and checkcompressfile == fnamedict ['format_magic' ])):
185- tmpout = pyfoxfile .RePackFoxFile (input_file , tempout , "auto" , getargs .compression , getargs .wholefile , getargs .level , pyfoxfile .compressionlistalt , False , getargs .filestart , 0 , 0 , [getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum ], getargs .skipchecksum , [], {}, fnamedict , getargs .secretkey , getargs .secretkey , False , False )
198+ tmpout = pyfoxfile .RePackFoxFile (input_file , tempout , "auto" , getargs .compression , getargs .wholefile , getargs .level , pyfoxfile .compressionlistalt , False , getargs .filestart , 0 , 0 , [getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum ], getargs .skipchecksum , [], {}, fnamedict , getargs .insecretkey , getargs .outsecretkey , False , False )
186199 else :
187200 tmpout = pyfoxfile .PackFoxFileFromInFile (
188- input_file , tempout , __file_format_default__ , getargs .compression , getargs .wholefile , getargs .level , pyfoxfile .compressionlistalt , [getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum ], [], {}, fnamedict , getargs .secretkey , False , False )
201+ input_file , tempout , __file_format_default__ , getargs .compression , getargs .wholefile , getargs .level , pyfoxfile .compressionlistalt , [getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum ], [], {}, fnamedict , getargs .insecretkey , False , False )
189202 if (not tmpout ):
190203 sys .exit (1 )
191204 input_file = tempout
@@ -196,28 +209,28 @@ def handler(signum, frame):
196209 checkcompressfile = pyfoxfile .CheckCompressionSubType (
197210 input_file , fnamedict , True )
198211 if ((pyfoxfile .IsNestedDict (fnamedict ) and checkcompressfile in fnamedict ) or (pyfoxfile .IsSingleDict (fnamedict ) and checkcompressfile == fnamedict ['format_magic' ])):
199- tmpout = pyfoxfile .FoxFileListFiles (input_file , "auto" , getargs .filestart , 0 , 0 , getargs .skipchecksum , fnamedict , getargs .secretkey , False , getargs .verbose , False , False )
212+ tmpout = pyfoxfile .FoxFileListFiles (input_file , "auto" , getargs .filestart , 0 , 0 , getargs .skipchecksum , fnamedict , getargs .insecretkey , False , getargs .verbose , False , False )
200213 else :
201- tmpout = pyfoxfile .InFileListFiles (input_file , getargs .verbose , fnamedict , getargs .secretkey , False , False , False )
214+ tmpout = pyfoxfile .InFileListFiles (input_file , getargs .verbose , fnamedict , getargs .insecretkey , False , False , False )
202215 if (not tmpout ):
203216 sys .exit (1 )
204217 else :
205- pyfoxfile .FoxFileListFiles (input_file , "auto" , getargs .filestart , 0 , 0 , getargs .skipchecksum , fnamedict , getargs .secretkey , False , getargs .verbose , False , False )
218+ pyfoxfile .FoxFileListFiles (input_file , "auto" , getargs .filestart , 0 , 0 , getargs .skipchecksum , fnamedict , getargs .insecretkey , False , getargs .verbose , False , False )
206219 elif active_action == 'validate' :
207220 if getargs .convert :
208221 checkcompressfile = pyfoxfile .CheckCompressionSubType (
209222 input_file , fnamedict , True )
210223 tempout = BytesIO ()
211224 if ((pyfoxfile .IsNestedDict (fnamedict ) and checkcompressfile in fnamedict ) or (pyfoxfile .IsSingleDict (fnamedict ) and checkcompressfile == fnamedict ['format_magic' ])):
212- tmpout = pyfoxfile .RePackFoxFile (input_file , tempout , "auto" , getargs .compression , getargs .wholefile , getargs .level , pyfoxfile .compressionlistalt , False , getargs .filestart , 0 , 0 , [getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum ], getargs .skipchecksum , [], {}, fnamedict , getargs .secretkey , getargs .secretkey , False , False , False )
225+ tmpout = pyfoxfile .RePackFoxFile (input_file , tempout , "auto" , getargs .compression , getargs .wholefile , getargs .level , pyfoxfile .compressionlistalt , False , getargs .filestart , 0 , 0 , [getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum ], getargs .skipchecksum , [], {}, fnamedict , getargs .insecretkey , getargs .outsecretkey , False , False , False )
213226 else :
214227 tmpout = pyfoxfile .PackFoxFileFromInFile (
215- input_file , tempout , __file_format_default__ , getargs .compression , getargs .wholefile , getargs .level , pyfoxfile .compressionlistalt , [getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum ], [], {}, fnamedict , getargs .secretkey , False , False )
228+ input_file , tempout , __file_format_default__ , getargs .compression , getargs .wholefile , getargs .level , pyfoxfile .compressionlistalt , [getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum , getargs .checksum ], [], {}, fnamedict , getargs .insecretkey , False , False )
216229 input_file = tempout
217230 if (not tmpout ):
218231 sys .exit (1 )
219232 fvalid = pyfoxfile .StackedFoxFileValidate (
220- input_file , "auto" , getargs .filestart , fnamedict , getargs .secretkey , False , getargs .verbose , False )
233+ input_file , "auto" , getargs .filestart , fnamedict , getargs .insecretkey , False , getargs .verbose , False )
221234 if (not getargs .verbose ):
222235 import sys
223236 import logging
0 commit comments