Skip to content

Commit 2f2cc81

Browse files
committed
Small update
1 parent d04760d commit 2f2cc81

2 files changed

Lines changed: 226 additions & 298 deletions

File tree

foxfile.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ def handler(signum, frame):
117117
argparser.add_argument("-v", "--validate", action="store_true", help="Validate archive file checksums.")
118118
argparser.add_argument("-C", "--checksum", default="md5", help="Specify the type of checksum to use. The default is crc32.")
119119
argparser.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.")
120121
# Permissions and metadata
121122
argparser.add_argument("-p", "--preserve", action="store_false", help="Do not preserve permissions and timestamps of files.")
122123
# Miscellaneous
@@ -153,38 +154,38 @@ def handler(signum, frame):
153154
checkcompressfile = pyfoxfile.CheckCompressionSubType(
154155
input_file, fnamedict, True)
155156
if((pyfoxfile.IsNestedDict(fnamedict) and checkcompressfile in fnamedict) or (pyfoxfile.IsSingleDict(fnamedict) and checkcompressfile==fnamedict['format_magic'])):
156-
tmpout = pyfoxfile.RePackFoxFile(input_file, getargs.output, 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.verbose, False)
157+
tmpout = pyfoxfile.RePackFoxFile(input_file, getargs.output, 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.verbose, False)
157158
else:
158159
tmpout = pyfoxfile.PackFoxFileFromInFile(
159-
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.verbose, False)
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)
160161
if(not tmpout):
161162
sys.exit(1)
162163
else:
163-
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.verbose, False)
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)
164165
elif active_action == 'repack':
165166
if getargs.convert:
166167
checkcompressfile = pyfoxfile.CheckCompressionSubType(
167168
input_file, fnamedict, True)
168169
if((pyfoxfile.IsNestedDict(fnamedict) and checkcompressfile in fnamedict) or (pyfoxfile.IsSingleDict(fnamedict) and checkcompressfile==fnamedict['format_magic'])):
169170
pyfoxfile.RePackFoxFile(input_file, getargs.output, getargs.compression, getargs.wholefile, getargs.level, pyfoxfile.compressionlistalt,
170-
False, getargs.filestart, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.verbose, False)
171+
False, getargs.filestart, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.secretkey, getargs.verbose, False)
171172
else:
172-
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.verbose, False)
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)
173174
if(not tmpout):
174175
sys.exit(1)
175176
else:
176177
pyfoxfile.RePackFoxFile(input_file, getargs.output, getargs.compression, getargs.wholefile, getargs.level, pyfoxfile.compressionlistalt,
177-
False, getargs.filestart, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.verbose, False)
178+
False, getargs.filestart, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.secretkey, getargs.verbose, False)
178179
elif active_action == 'extract':
179180
if getargs.convert:
180181
checkcompressfile = pyfoxfile.CheckCompressionSubType(
181182
input_file, fnamedict, True)
182183
tempout = BytesIO()
183184
if((pyfoxfile.IsNestedDict(fnamedict) and checkcompressfile in fnamedict) or (pyfoxfile.IsSingleDict(fnamedict) and checkcompressfile==fnamedict['format_magic'])):
184-
tmpout = pyfoxfile.RePackFoxFile(input_file, tempout, 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, False, False)
185+
tmpout = pyfoxfile.RePackFoxFile(input_file, tempout, 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, False, False)
185186
else:
186187
tmpout = pyfoxfile.PackFoxFileFromInFile(
187-
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, False, False)
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)
188189
if(not tmpout):
189190
sys.exit(1)
190191
input_file = tempout
@@ -195,28 +196,28 @@ def handler(signum, frame):
195196
checkcompressfile = pyfoxfile.CheckCompressionSubType(
196197
input_file, fnamedict, True)
197198
if((pyfoxfile.IsNestedDict(fnamedict) and checkcompressfile in fnamedict) or (pyfoxfile.IsSingleDict(fnamedict) and checkcompressfile==fnamedict['format_magic'])):
198-
tmpout = pyfoxfile.FoxFileListFiles(input_file, "auto", getargs.filestart, 0, 0, getargs.skipchecksum, fnamedict, False, getargs.verbose, False, False)
199+
tmpout = pyfoxfile.FoxFileListFiles(input_file, "auto", getargs.filestart, 0, 0, getargs.skipchecksum, fnamedict, getargs.secretkey, False, getargs.verbose, False, False)
199200
else:
200-
tmpout = pyfoxfile.InFileListFiles(input_file, getargs.verbose, fnamedict, False, False, False)
201+
tmpout = pyfoxfile.InFileListFiles(input_file, getargs.verbose, fnamedict, getargs.secretkey, False, False, False)
201202
if(not tmpout):
202203
sys.exit(1)
203204
else:
204-
pyfoxfile.FoxFileListFiles(input_file, "auto", getargs.filestart, 0, 0, getargs.skipchecksum, fnamedict, False, getargs.verbose, False, False)
205+
pyfoxfile.FoxFileListFiles(input_file, "auto", getargs.filestart, 0, 0, getargs.skipchecksum, fnamedict, getargs.secretkey, False, getargs.verbose, False, False)
205206
elif active_action == 'validate':
206207
if getargs.convert:
207208
checkcompressfile = pyfoxfile.CheckCompressionSubType(
208209
input_file, fnamedict, True)
209210
tempout = BytesIO()
210211
if((pyfoxfile.IsNestedDict(fnamedict) and checkcompressfile in fnamedict) or (pyfoxfile.IsSingleDict(fnamedict) and checkcompressfile==fnamedict['format_magic'])):
211-
tmpout = pyfoxfile.RePackFoxFile(input_file, tempout, 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, False, False, False)
212+
tmpout = pyfoxfile.RePackFoxFile(input_file, tempout, 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, False, False, False)
212213
else:
213214
tmpout = pyfoxfile.PackFoxFileFromInFile(
214-
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, False, False)
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)
215216
input_file = tempout
216217
if(not tmpout):
217218
sys.exit(1)
218219
fvalid = pyfoxfile.StackedFoxFileValidate(
219-
input_file, "auto", getargs.filestart, fnamedict, False, getargs.verbose, False)
220+
input_file, "auto", getargs.filestart, fnamedict, getargs.secretkey, False, getargs.verbose, False)
220221
if(not getargs.verbose):
221222
import sys
222223
import logging

0 commit comments

Comments
 (0)