PyCatFile 0.18.0__tar.gz → 0.18.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pycatfile-0.18.0 → pycatfile-0.18.2}/PKG-INFO +1 -1
- {pycatfile-0.18.0 → pycatfile-0.18.2}/PyCatFile.egg-info/PKG-INFO +1 -1
- {pycatfile-0.18.0 → pycatfile-0.18.2}/catfile.py +11 -11
- {pycatfile-0.18.0 → pycatfile-0.18.2}/neocatfile.py +2 -2
- {pycatfile-0.18.0 → pycatfile-0.18.2}/pycatfile.py +217 -79
- {pycatfile-0.18.0 → pycatfile-0.18.2}/pyproject.toml +1 -1
- {pycatfile-0.18.0 → pycatfile-0.18.2}/setup.py +1 -1
- {pycatfile-0.18.0 → pycatfile-0.18.2}/LICENSE +0 -0
- {pycatfile-0.18.0 → pycatfile-0.18.2}/PyCatFile.egg-info/SOURCES.txt +0 -0
- {pycatfile-0.18.0 → pycatfile-0.18.2}/PyCatFile.egg-info/dependency_links.txt +0 -0
- {pycatfile-0.18.0 → pycatfile-0.18.2}/PyCatFile.egg-info/top_level.txt +0 -0
- {pycatfile-0.18.0 → pycatfile-0.18.2}/PyCatFile.egg-info/zip-safe +0 -0
- {pycatfile-0.18.0 → pycatfile-0.18.2}/README.md +0 -0
- {pycatfile-0.18.0 → pycatfile-0.18.2}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: PyCatFile
|
|
3
|
-
Version: 0.18.
|
|
3
|
+
Version: 0.18.2
|
|
4
4
|
Summary: A tar like file format name catfile after unix cat command (concatenate files) .
|
|
5
5
|
Home-page: https://github.com/GameMaker2k/PyCatFile
|
|
6
6
|
Download-URL: https://github.com/GameMaker2k/PyCatFile/archive/master.tar.gz
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: PyCatFile
|
|
3
|
-
Version: 0.18.
|
|
3
|
+
Version: 0.18.2
|
|
4
4
|
Summary: A tar like file format name catfile after unix cat command (concatenate files) .
|
|
5
5
|
Home-page: https://github.com/GameMaker2k/PyCatFile
|
|
6
6
|
Download-URL: https://github.com/GameMaker2k/PyCatFile/archive/master.tar.gz
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
Copyright 2018-2024 Game Maker 2k - http://intdb.sourceforge.net/
|
|
15
15
|
Copyright 2018-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
|
|
16
16
|
|
|
17
|
-
$FileInfo: catfile.py - Last Update:
|
|
17
|
+
$FileInfo: catfile.py - Last Update: 2/7/2025 Ver. 0.18.2 RC 1 - Author: cooldude2k $
|
|
18
18
|
'''
|
|
19
19
|
|
|
20
20
|
from __future__ import absolute_import, division, print_function, unicode_literals, generators, with_statement, nested_scopes
|
|
@@ -173,38 +173,38 @@ if active_action:
|
|
|
173
173
|
checkcompressfile = pycatfile.CheckCompressionSubType(
|
|
174
174
|
input_file, fnamedict, True)
|
|
175
175
|
if((IsNestedDict(fnamedict) and compresscheck in fnamedict) or (IsSingleDict(fnamedict) and compresscheck==fnamedict['format_magic'])):
|
|
176
|
-
tmpout = pycatfile.RePackCatFile(input_file, getargs.output, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, False, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], fnamedict, getargs.verbose, False)
|
|
176
|
+
tmpout = pycatfile.RePackCatFile(input_file, getargs.output, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, False, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.verbose, False)
|
|
177
177
|
else:
|
|
178
178
|
tmpout = pycatfile.PackCatFileFromInFile(
|
|
179
|
-
input_file, getargs.output, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum], [], fnamedict, getargs.verbose, False)
|
|
179
|
+
input_file, getargs.output, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.verbose, False)
|
|
180
180
|
if(not tmpout):
|
|
181
181
|
sys.exit(1)
|
|
182
182
|
else:
|
|
183
|
-
pycatfile.PackCatFile(getargs.input, getargs.output, getargs.text, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, False, [getargs.checksum, getargs.checksum, getargs.checksum], [], fnamedict, getargs.verbose, False)
|
|
183
|
+
pycatfile.PackCatFile(getargs.input, getargs.output, getargs.text, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, False, [getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.verbose, False)
|
|
184
184
|
elif active_action == 'repack':
|
|
185
185
|
if getargs.convert:
|
|
186
186
|
checkcompressfile = pycatfile.CheckCompressionSubType(
|
|
187
187
|
input_file, fnamedict, True)
|
|
188
188
|
if((IsNestedDict(fnamedict) and compresscheck in fnamedict) or (IsSingleDict(fnamedict) and compresscheck==fnamedict['format_magic'])):
|
|
189
189
|
pycatfile.RePackCatFile(input_file, getargs.output, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt,
|
|
190
|
-
False, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], fnamedict, getargs.verbose, False)
|
|
190
|
+
False, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.verbose, False)
|
|
191
191
|
else:
|
|
192
|
-
pycatfile.PackCatFileFromInFile(input_file, getargs.output, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum], [], fnamedict, getargs.verbose, False)
|
|
192
|
+
pycatfile.PackCatFileFromInFile(input_file, getargs.output, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.verbose, False)
|
|
193
193
|
if(not tmpout):
|
|
194
194
|
sys.exit(1)
|
|
195
195
|
else:
|
|
196
196
|
pycatfile.RePackCatFile(input_file, getargs.output, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt,
|
|
197
|
-
False, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], fnamedict, getargs.verbose, False)
|
|
197
|
+
False, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.verbose, False)
|
|
198
198
|
elif active_action == 'extract':
|
|
199
199
|
if getargs.convert:
|
|
200
200
|
checkcompressfile = pycatfile.CheckCompressionSubType(
|
|
201
201
|
input_file, fnamedict, True)
|
|
202
202
|
tempout = BytesIO()
|
|
203
203
|
if((IsNestedDict(fnamedict) and compresscheck in fnamedict) or (IsSingleDict(fnamedict) and compresscheck==fnamedict['format_magic'])):
|
|
204
|
-
tmpout = pycatfile.RePackCatFile(input_file, tempout, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, False, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], fnamedict, False, False)
|
|
204
|
+
tmpout = pycatfile.RePackCatFile(input_file, tempout, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, False, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, False, False)
|
|
205
205
|
else:
|
|
206
206
|
tmpout = pycatfile.PackCatFileFromInFile(
|
|
207
|
-
input_file, tempout, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum], [], fnamedict, False, False)
|
|
207
|
+
input_file, tempout, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, False, False)
|
|
208
208
|
if(not tmpout):
|
|
209
209
|
sys.exit(1)
|
|
210
210
|
input_file = tempout
|
|
@@ -228,10 +228,10 @@ if active_action:
|
|
|
228
228
|
input_file, fnamedict, True)
|
|
229
229
|
tempout = BytesIO()
|
|
230
230
|
if((IsNestedDict(fnamedict) and compresscheck in fnamedict) or (IsSingleDict(fnamedict) and compresscheck==fnamedict['format_magic'])):
|
|
231
|
-
tmpout = pycatfile.RePackCatFile(input_file, tempout, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, False, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], fnamedict, False, False)
|
|
231
|
+
tmpout = pycatfile.RePackCatFile(input_file, tempout, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, False, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, False, False)
|
|
232
232
|
else:
|
|
233
233
|
tmpout = pycatfile.PackCatFileFromInFile(
|
|
234
|
-
input_file, tempout, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum], [], fnamedict, False, False)
|
|
234
|
+
input_file, tempout, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, False, False)
|
|
235
235
|
input_file = tempout
|
|
236
236
|
if(not tmpout):
|
|
237
237
|
sys.exit(1)
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
Copyright 2018-2024 Game Maker 2k - http://intdb.sourceforge.net/
|
|
15
15
|
Copyright 2018-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
|
|
16
16
|
|
|
17
|
-
$FileInfo: neocatfile.py - Last Update:
|
|
17
|
+
$FileInfo: neocatfile.py - Last Update: 2/7/2025 Ver. 0.18.2 RC 1 - Author: cooldude2k $
|
|
18
18
|
'''
|
|
19
19
|
|
|
20
20
|
from __future__ import absolute_import, division, print_function, unicode_literals, generators, with_statement, nested_scopes
|
|
@@ -112,7 +112,7 @@ if primary_action == 'create':
|
|
|
112
112
|
], pycatfile.__file_format_dict__, args.verbose, False)
|
|
113
113
|
else:
|
|
114
114
|
pycatfile.PackCatFile(args.input, args.output, args.verbose, args.compression, args.level, pycatfile.compressionlistalt,
|
|
115
|
-
False, [args.checksum, args.checksum, args.checksum], [], pycatfile.__file_format_dict__, args.verbose, False)
|
|
115
|
+
False, [args.checksum, args.checksum, args.checksum], [], {}, pycatfile.__file_format_dict__, args.verbose, False)
|
|
116
116
|
elif primary_action == 'repack':
|
|
117
117
|
pycatfile.RePackCatFile(
|
|
118
118
|
input_file, args.output, args.compression, args.level, pycatfile.compressionlistalt, [args.checksum, args.checksum, args.checksum], args.verbose)
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
Copyright 2018-2024 Game Maker 2k - http://intdb.sourceforge.net/
|
|
15
15
|
Copyright 2018-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
|
|
16
16
|
|
|
17
|
-
$FileInfo: pycatfile.py - Last Update:
|
|
17
|
+
$FileInfo: pycatfile.py - Last Update: 2/7/2025 Ver. 0.18.2 RC 1 - Author: cooldude2k $
|
|
18
18
|
'''
|
|
19
19
|
|
|
20
20
|
from __future__ import absolute_import, division, print_function, unicode_literals, generators, with_statement, nested_scopes
|
|
@@ -350,12 +350,12 @@ __file_format_extension__ = __file_format_multi_dict__[__file_format_default__][
|
|
|
350
350
|
__file_format_dict__ = __file_format_multi_dict__[__file_format_default__]
|
|
351
351
|
__project__ = __program_name__
|
|
352
352
|
__project_url__ = "https://github.com/GameMaker2k/PyCatFile"
|
|
353
|
-
__version_info__ = (0, 18,
|
|
354
|
-
__version_date_info__ = (2025,
|
|
353
|
+
__version_info__ = (0, 18, 2, "RC 1", 1)
|
|
354
|
+
__version_date_info__ = (2025, 2, 7, "RC 1", 1)
|
|
355
355
|
__version_date__ = str(__version_date_info__[0]) + "." + str(
|
|
356
356
|
__version_date_info__[1]).zfill(2) + "." + str(__version_date_info__[2]).zfill(2)
|
|
357
357
|
__revision__ = __version_info__[3]
|
|
358
|
-
__revision_id__ = "$Id:
|
|
358
|
+
__revision_id__ = "$Id: 04d8ef9954fbec39ade4bbce2a7c6efaa3938666 $"
|
|
359
359
|
if(__version_info__[4] is not None):
|
|
360
360
|
__version_date_plusrc__ = __version_date__ + \
|
|
361
361
|
"-" + str(__version_date_info__[4])
|
|
@@ -2097,8 +2097,25 @@ def ReadFileHeaderDataWithContent(fp, listonly=False, uncompress=True, skipcheck
|
|
|
2097
2097
|
fcompression = HeaderOut[12]
|
|
2098
2098
|
fcsize = int(HeaderOut[13], 16)
|
|
2099
2099
|
fseeknextfile = HeaderOut[25]
|
|
2100
|
+
fjsonsize = int(HeaderOut[27], 16)
|
|
2101
|
+
fjsoncontent = {}
|
|
2102
|
+
fprejsoncontent = fp.read(fjsonsize).decode("UTF-8")
|
|
2103
|
+
if(fjsonsize > 0):
|
|
2104
|
+
try:
|
|
2105
|
+
fjsoncontent = json.loads(base64.b64decode(fprejsoncontent).decode("UTF-8"))
|
|
2106
|
+
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
2107
|
+
try:
|
|
2108
|
+
fjsoncontent = json.loads(fprejsoncontent.decode("UTF-8"))
|
|
2109
|
+
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
2110
|
+
fprejsoncontent = ""
|
|
2111
|
+
fjsoncontent = {}
|
|
2112
|
+
else:
|
|
2113
|
+
fprejsoncontent = ""
|
|
2114
|
+
fjsoncontent = {}
|
|
2115
|
+
fp.seek(len(delimiter), 1)
|
|
2100
2116
|
newfcs = GetHeaderChecksum(
|
|
2101
|
-
HeaderOut[:-2], HeaderOut[-4].lower(), True, formatspecs)
|
|
2117
|
+
HeaderOut[:-2] + [fprejsoncontent], HeaderOut[-4].lower(), True, formatspecs)
|
|
2118
|
+
HeaderOut.append(fjsoncontent)
|
|
2102
2119
|
if(fcs != newfcs and not skipchecksum):
|
|
2103
2120
|
VerbosePrintOut("File Header Checksum Error with file " +
|
|
2104
2121
|
fname + " at offset " + str(fheaderstart))
|
|
@@ -2130,7 +2147,7 @@ def ReadFileHeaderDataWithContent(fp, listonly=False, uncompress=True, skipcheck
|
|
|
2130
2147
|
else:
|
|
2131
2148
|
fcontents.seek(0, 0)
|
|
2132
2149
|
if(uncompress):
|
|
2133
|
-
cfcontents =
|
|
2150
|
+
cfcontents = UncompressArchiveFile(fcontents, formatspecs)
|
|
2134
2151
|
cfcontents.seek(0, 0)
|
|
2135
2152
|
cfcontents.seek(0, 0)
|
|
2136
2153
|
shutil.copyfileobj(cfcontents, fcontents)
|
|
@@ -2202,10 +2219,11 @@ def ReadFileHeaderDataWithContentToArray(fp, listonly=False, contentasfile=True,
|
|
|
2202
2219
|
fdev_minor = int(HeaderOut[24], 16)
|
|
2203
2220
|
fdev_major = int(HeaderOut[25], 16)
|
|
2204
2221
|
fseeknextfile = HeaderOut[26]
|
|
2205
|
-
|
|
2206
|
-
|
|
2222
|
+
fjsonsize = int(HeaderOut[27], 16)
|
|
2223
|
+
fextrasize = int(HeaderOut[28], 16)
|
|
2224
|
+
fextrafields = int(HeaderOut[29], 16)
|
|
2207
2225
|
fextrafieldslist = []
|
|
2208
|
-
extrastart =
|
|
2226
|
+
extrastart = 30
|
|
2209
2227
|
extraend = extrastart + fextrafields
|
|
2210
2228
|
while(extrastart < extraend):
|
|
2211
2229
|
fextrafieldslist.append(HeaderOut[extrastart])
|
|
@@ -2215,11 +2233,29 @@ def ReadFileHeaderDataWithContentToArray(fp, listonly=False, contentasfile=True,
|
|
|
2215
2233
|
fextrafieldslist = json.loads(base64.b64decode(fextrafieldslist[0]).decode("UTF-8"))
|
|
2216
2234
|
fextrafields = len(fextrafieldslist)
|
|
2217
2235
|
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
2218
|
-
|
|
2236
|
+
try:
|
|
2237
|
+
fextrafieldslist = json.loads(fextrafieldslist[0])
|
|
2238
|
+
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
2239
|
+
pass
|
|
2240
|
+
fjsoncontent = {}
|
|
2241
|
+
fprejsoncontent = fp.read(fjsonsize).decode("UTF-8")
|
|
2242
|
+
if(fjsonsize > 0):
|
|
2243
|
+
try:
|
|
2244
|
+
fjsoncontent = json.loads(base64.b64decode(fprejsoncontent).decode("UTF-8"))
|
|
2245
|
+
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
2246
|
+
try:
|
|
2247
|
+
fjsoncontent = json.loads(fprejsoncontent.decode("UTF-8"))
|
|
2248
|
+
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
2249
|
+
fprejsoncontent = ""
|
|
2250
|
+
fjsoncontent = {}
|
|
2251
|
+
else:
|
|
2252
|
+
fprejsoncontent = ""
|
|
2253
|
+
fjsoncontent = {}
|
|
2254
|
+
fp.seek(len(delimiter), 1)
|
|
2219
2255
|
fcs = HeaderOut[-2].lower()
|
|
2220
2256
|
fccs = HeaderOut[-1].lower()
|
|
2221
2257
|
newfcs = GetHeaderChecksum(
|
|
2222
|
-
HeaderOut[:-2], HeaderOut[-4].lower(), True, formatspecs)
|
|
2258
|
+
HeaderOut[:-2] + [fprejsoncontent], HeaderOut[-4].lower(), True, formatspecs)
|
|
2223
2259
|
if(fcs != newfcs and not skipchecksum):
|
|
2224
2260
|
VerbosePrintOut("File Header Checksum Error with file " +
|
|
2225
2261
|
fname + " at offset " + str(fheaderstart))
|
|
@@ -2263,7 +2299,7 @@ def ReadFileHeaderDataWithContentToArray(fp, listonly=False, contentasfile=True,
|
|
|
2263
2299
|
fcontents.seek(0, 0)
|
|
2264
2300
|
fccs = GetFileChecksum(
|
|
2265
2301
|
fcontents.read(), HeaderOut[-3].lower(), False, formatspecs)
|
|
2266
|
-
fcontentend = fp.tell()
|
|
2302
|
+
fcontentend = fp.tell()
|
|
2267
2303
|
if(re.findall("^\\+([0-9]+)", fseeknextfile)):
|
|
2268
2304
|
fseeknextasnum = int(fseeknextfile.replace("+", ""))
|
|
2269
2305
|
if(abs(fseeknextasnum) == 0):
|
|
@@ -2285,7 +2321,7 @@ def ReadFileHeaderDataWithContentToArray(fp, listonly=False, contentasfile=True,
|
|
|
2285
2321
|
if(not contentasfile):
|
|
2286
2322
|
fcontents = fcontents.read()
|
|
2287
2323
|
outlist = {'fheadersize': fheadsize, 'fhstart': fheaderstart, 'fhend': fhend, 'ftype': ftype, 'fencoding': fencoding, 'fcencoding': fcencoding, 'fname': fname, 'fbasedir': fbasedir, 'flinkname': flinkname, 'fsize': fsize, 'fatime': fatime, 'fmtime': fmtime, 'fctime': fctime, 'fbtime': fbtime, 'fmode': fmode, 'fchmode': fchmode, 'ftypemod': ftypemod, 'fwinattributes': fwinattributes, 'fcompression': fcompression, 'fcsize': fcsize, 'fuid': fuid, 'funame': funame, 'fgid': fgid, 'fgname': fgname, 'finode': finode, 'flinkcount': flinkcount,
|
|
2288
|
-
'fdev': fdev, 'fminor': fdev_minor, 'fmajor': fdev_major, 'fseeknextfile': fseeknextfile, 'fheaderchecksumtype': HeaderOut[-4], 'fcontentchecksumtype': HeaderOut[-3], 'fnumfields': fnumfields + 2, 'frawheader': HeaderOut, 'fextrafields': fextrafields, 'fextrafieldsize': fextrasize, '
|
|
2324
|
+
'fdev': fdev, 'fminor': fdev_minor, 'fmajor': fdev_major, 'fseeknextfile': fseeknextfile, 'fheaderchecksumtype': HeaderOut[-4], 'fcontentchecksumtype': HeaderOut[-3], 'fnumfields': fnumfields + 2, 'frawheader': HeaderOut, 'fextrafields': fextrafields, 'fextrafieldsize': fextrasize, 'fextradata': fextrafieldslist, 'fjsondata': fjsoncontent, 'fheaderchecksum': fcs, 'fcontentchecksum': fccs, 'fhascontents': pyhascontents, 'fcontentstart': fcontentstart, 'fcontentend': fcontentend, 'fcontentasfile': contentasfile, 'fcontents': fcontents}
|
|
2289
2325
|
return outlist
|
|
2290
2326
|
|
|
2291
2327
|
|
|
@@ -2333,10 +2369,11 @@ def ReadFileHeaderDataWithContentToList(fp, listonly=False, contentasfile=False,
|
|
|
2333
2369
|
fdev_minor = int(HeaderOut[24], 16)
|
|
2334
2370
|
fdev_major = int(HeaderOut[25], 16)
|
|
2335
2371
|
fseeknextfile = HeaderOut[26]
|
|
2336
|
-
|
|
2337
|
-
|
|
2372
|
+
fjsonsize = int(HeaderOut[27], 16)
|
|
2373
|
+
fextrasize = int(HeaderOut[28], 16)
|
|
2374
|
+
fextrafields = int(HeaderOut[29], 16)
|
|
2338
2375
|
fextrafieldslist = []
|
|
2339
|
-
extrastart =
|
|
2376
|
+
extrastart = 30
|
|
2340
2377
|
extraend = extrastart + fextrafields
|
|
2341
2378
|
while(extrastart < extraend):
|
|
2342
2379
|
fextrafieldslist.append(HeaderOut[extrastart])
|
|
@@ -2346,11 +2383,29 @@ def ReadFileHeaderDataWithContentToList(fp, listonly=False, contentasfile=False,
|
|
|
2346
2383
|
fextrafieldslist = json.loads(base64.b64decode(fextrafieldslist[0]).decode("UTF-8"))
|
|
2347
2384
|
fextrafields = len(fextrafieldslist)
|
|
2348
2385
|
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
2349
|
-
|
|
2386
|
+
try:
|
|
2387
|
+
fextrafieldslist = json.loads(fextrafieldslist[0])
|
|
2388
|
+
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
2389
|
+
pass
|
|
2390
|
+
fjsoncontent = {}
|
|
2391
|
+
fprejsoncontent = fp.read(fjsonsize).decode("UTF-8")
|
|
2392
|
+
if(fjsonsize > 0):
|
|
2393
|
+
try:
|
|
2394
|
+
fjsoncontent = json.loads(base64.b64decode(fprejsoncontent).decode("UTF-8"))
|
|
2395
|
+
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
2396
|
+
try:
|
|
2397
|
+
fjsoncontent = json.loads(fprejsoncontent.decode("UTF-8"))
|
|
2398
|
+
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
2399
|
+
fprejsoncontent = ""
|
|
2400
|
+
fjsoncontent = ""
|
|
2401
|
+
else:
|
|
2402
|
+
fprejsoncontent = ""
|
|
2403
|
+
fjsoncontent = ""
|
|
2404
|
+
fp.seek(len(delimiter), 1)
|
|
2350
2405
|
fcs = HeaderOut[-2].lower()
|
|
2351
2406
|
fccs = HeaderOut[-1].lower()
|
|
2352
2407
|
newfcs = GetHeaderChecksum(
|
|
2353
|
-
HeaderOut[:-2], HeaderOut[-4].lower(), True, formatspecs)
|
|
2408
|
+
HeaderOut[:-2] + [fprejsoncontent], HeaderOut[-4].lower(), True, formatspecs)
|
|
2354
2409
|
if(fcs != newfcs and not skipchecksum):
|
|
2355
2410
|
VerbosePrintOut("File Header Checksum Error with file " +
|
|
2356
2411
|
fname + " at offset " + str(fheaderstart))
|
|
@@ -2394,7 +2449,7 @@ def ReadFileHeaderDataWithContentToList(fp, listonly=False, contentasfile=False,
|
|
|
2394
2449
|
fcontents.seek(0, 0)
|
|
2395
2450
|
fccs = GetFileChecksum(
|
|
2396
2451
|
fcontents.read(), HeaderOut[-3].lower(), False, formatspecs)
|
|
2397
|
-
fcontentend = fp.tell()
|
|
2452
|
+
fcontentend = fp.tell()
|
|
2398
2453
|
if(re.findall("^\\+([0-9]+)", fseeknextfile)):
|
|
2399
2454
|
fseeknextasnum = int(fseeknextfile.replace("+", ""))
|
|
2400
2455
|
if(abs(fseeknextasnum) == 0):
|
|
@@ -2416,7 +2471,7 @@ def ReadFileHeaderDataWithContentToList(fp, listonly=False, contentasfile=False,
|
|
|
2416
2471
|
if(not contentasfile):
|
|
2417
2472
|
fcontents = fcontents.read()
|
|
2418
2473
|
outlist = [ftype, fencoding, fcencoding, fname, flinkname, fsize, fatime, fmtime, fctime, fbtime, fmode, fwinattributes, fcompression, fcsize, fuid, funame, fgid, fgname, fid,
|
|
2419
|
-
finode, flinkcount, fdev, fdev_minor, fdev_major, fseeknextfile, fextrafieldslist, HeaderOut[-4], HeaderOut[-3], fcontents]
|
|
2474
|
+
finode, flinkcount, fdev, fdev_minor, fdev_major, fseeknextfile, fjsoncontent, fextrafieldslist, HeaderOut[-4], HeaderOut[-3], fcontents]
|
|
2420
2475
|
return outlist
|
|
2421
2476
|
|
|
2422
2477
|
|
|
@@ -2518,7 +2573,10 @@ def ReadFileDataWithContentToArray(fp, seekstart=0, seekend=0, listonly=False, c
|
|
|
2518
2573
|
fextrafieldslist = json.loads(base64.b64decode(fextrafieldslist[0]).decode("UTF-8"))
|
|
2519
2574
|
fnumextrafields = len(fextrafieldslist)
|
|
2520
2575
|
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
2521
|
-
|
|
2576
|
+
try:
|
|
2577
|
+
fextrafieldslist = json.loads(fextrafieldslist[0])
|
|
2578
|
+
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
2579
|
+
pass
|
|
2522
2580
|
if(curloc > 0):
|
|
2523
2581
|
fp.seek(curloc, 0)
|
|
2524
2582
|
formversion = re.findall("([\\d]+)", formstring)
|
|
@@ -2539,7 +2597,7 @@ def ReadFileDataWithContentToArray(fp, seekstart=0, seekend=0, listonly=False, c
|
|
|
2539
2597
|
return False
|
|
2540
2598
|
formversions = re.search('(.*?)(\\d+)', formstring).groups()
|
|
2541
2599
|
fcompresstype = ""
|
|
2542
|
-
outlist = {'fnumfiles': fnumfiles, 'fformat': formversions[0], 'fcompression': fcompresstype, 'fencoding': fhencoding, 'fversion': formversions[1], 'fostype': fostype, 'fheadersize': fheadsize, 'fsize': CatSizeEnd, 'fnumfields': fnumfields + 2, 'fformatspecs': formatspecs, 'fchecksumtype': fprechecksumtype, 'fheaderchecksum': fprechecksum, 'frawheader': [formstring] + inheader, 'fextrafields': fnumextrafields, 'fextrafieldsize': fnumextrafieldsize, '
|
|
2600
|
+
outlist = {'fnumfiles': fnumfiles, 'fformat': formversions[0], 'fcompression': fcompresstype, 'fencoding': fhencoding, 'fversion': formversions[1], 'fostype': fostype, 'fheadersize': fheadsize, 'fsize': CatSizeEnd, 'fnumfields': fnumfields + 2, 'fformatspecs': formatspecs, 'fchecksumtype': fprechecksumtype, 'fheaderchecksum': fprechecksum, 'frawheader': [formstring] + inheader, 'fextrafields': fnumextrafields, 'fextrafieldsize': fnumextrafieldsize, 'fextradata': fextrafieldslist, 'ffilelist': []}
|
|
2543
2601
|
if(seekstart < 0 and seekstart > fnumfiles):
|
|
2544
2602
|
seekstart = 0
|
|
2545
2603
|
if(seekend == 0 or seekend > fnumfiles and seekend < seekstart):
|
|
@@ -2659,7 +2717,10 @@ def ReadFileDataWithContentToList(fp, seekstart=0, seekend=0, listonly=False, co
|
|
|
2659
2717
|
fextrafieldslist = json.loads(base64.b64decode(fextrafieldslist[0]).decode("UTF-8"))
|
|
2660
2718
|
fnumextrafields = len(fextrafieldslist)
|
|
2661
2719
|
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
2662
|
-
|
|
2720
|
+
try:
|
|
2721
|
+
fextrafieldslist = json.loads(fextrafieldslist[0])
|
|
2722
|
+
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
2723
|
+
pass
|
|
2663
2724
|
if(curloc > 0):
|
|
2664
2725
|
fp.seek(curloc, 0)
|
|
2665
2726
|
formversion = re.findall("([\\d]+)", formstring)
|
|
@@ -3318,7 +3379,7 @@ def MakeEmptyCatFile(outfile, compression="auto", compresswholefile=True, compre
|
|
|
3318
3379
|
return MakeEmptyFile(outfile, compression, compresswholefile, compressionlevel, checksumtype, formatspecs, returnfp)
|
|
3319
3380
|
|
|
3320
3381
|
|
|
3321
|
-
def AppendFileHeaderWithContent(fp, filevalues=[], extradata=[], filecontent="", checksumtype=["crc32", "crc32"], formatspecs=__file_format_dict__):
|
|
3382
|
+
def AppendFileHeaderWithContent(fp, filevalues=[], extradata=[], jsondata={}, filecontent="", checksumtype=["crc32", "crc32"], formatspecs=__file_format_dict__):
|
|
3322
3383
|
if(not hasattr(fp, "write")):
|
|
3323
3384
|
return False
|
|
3324
3385
|
if (isinstance(extradata, dict) or IsNestedDictAlt(extradata)) and len(extradata) > 0:
|
|
@@ -3331,10 +3392,22 @@ def AppendFileHeaderWithContent(fp, filevalues=[], extradata=[], filecontent="",
|
|
|
3331
3392
|
extrasizestr = extrasizestr + \
|
|
3332
3393
|
AppendNullBytes(extradata, formatspecs['format_delimiter'])
|
|
3333
3394
|
extrasizelen = format(len(extrasizestr), 'x').lower()
|
|
3334
|
-
tmpoutlen = len(filevalues) + len(extradata) +
|
|
3395
|
+
tmpoutlen = len(filevalues) + len(extradata) + 7
|
|
3335
3396
|
tmpoutlenhex = format(tmpoutlen, 'x').lower()
|
|
3336
3397
|
tmpoutlist = filevalues
|
|
3398
|
+
if(len(jsondata) > 0):
|
|
3399
|
+
try:
|
|
3400
|
+
fjsoncontent = base64.b64encode(json.dumps(jsondata, separators=(',', ':')).encode("UTF-8"))
|
|
3401
|
+
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
3402
|
+
try:
|
|
3403
|
+
fjsoncontent = json.dumps(jsondata.decode("UTF-8"))
|
|
3404
|
+
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
3405
|
+
fjsoncontent = "".encode("UTF-8")
|
|
3406
|
+
else:
|
|
3407
|
+
fjsoncontent = "".encode("UTF-8")
|
|
3408
|
+
fjsonsize = format(len(fjsoncontent), 'x').lower()
|
|
3337
3409
|
tmpoutlist.insert(0, tmpoutlenhex)
|
|
3410
|
+
tmpoutlist.append(fjsonsize)
|
|
3338
3411
|
tmpoutlist.append(extrasizelen)
|
|
3339
3412
|
tmpoutlist.append(extrafields)
|
|
3340
3413
|
outfileoutstr = AppendNullBytes(
|
|
@@ -3348,8 +3421,9 @@ def AppendFileHeaderWithContent(fp, filevalues=[], extradata=[], filecontent="",
|
|
|
3348
3421
|
checksumlist = checksumtype
|
|
3349
3422
|
outfileoutstr = outfileoutstr + \
|
|
3350
3423
|
AppendNullBytes(checksumlist, formatspecs['format_delimiter'])
|
|
3424
|
+
nullstrecd = formatspecs['format_delimiter'].encode('UTF-8')
|
|
3351
3425
|
outfileheadercshex = GetFileChecksum(
|
|
3352
|
-
outfileoutstr, checksumtype[0], True, formatspecs)
|
|
3426
|
+
outfileoutstr + fjsoncontent + nullstrecd, checksumtype[0], True, formatspecs)
|
|
3353
3427
|
if(len(filecontent) == 0):
|
|
3354
3428
|
outfilecontentcshex = GetFileChecksum(
|
|
3355
3429
|
filecontent, "none", False, formatspecs)
|
|
@@ -3363,13 +3437,12 @@ def AppendFileHeaderWithContent(fp, filevalues=[], extradata=[], filecontent="",
|
|
|
3363
3437
|
outfileoutstr = AppendNullByte(
|
|
3364
3438
|
formheaersize, formatspecs['format_delimiter']) + outfileoutstr
|
|
3365
3439
|
outfileheadercshex = GetFileChecksum(
|
|
3366
|
-
outfileoutstr, checksumtype[0], True, formatspecs)
|
|
3440
|
+
outfileoutstr + fjsoncontent + nullstrecd, checksumtype[0], True, formatspecs)
|
|
3367
3441
|
outfileoutstr = outfileoutstr + \
|
|
3368
3442
|
AppendNullBytes([outfileheadercshex, outfilecontentcshex],
|
|
3369
3443
|
formatspecs['format_delimiter'])
|
|
3370
3444
|
outfileoutstrecd = outfileoutstr
|
|
3371
|
-
|
|
3372
|
-
outfileout = outfileoutstrecd + filecontent + nullstrecd
|
|
3445
|
+
outfileout = outfileoutstrecd + fjsoncontent + nullstrecd + filecontent + nullstrecd
|
|
3373
3446
|
try:
|
|
3374
3447
|
fp.write(outfileout)
|
|
3375
3448
|
except OSError:
|
|
@@ -3387,7 +3460,7 @@ def AppendFileHeaderWithContent(fp, filevalues=[], extradata=[], filecontent="",
|
|
|
3387
3460
|
return fp
|
|
3388
3461
|
|
|
3389
3462
|
|
|
3390
|
-
def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], extradata=[], compression="auto", compresswholefile=True, compressionlevel=None, compressionuselist=compressionlistalt, followlink=False, checksumtype=["crc32", "crc32", "crc32"], formatspecs=__file_format_dict__, verbose=False):
|
|
3463
|
+
def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], extradata=[], jsondata={}, compression="auto", compresswholefile=True, compressionlevel=None, compressionuselist=compressionlistalt, followlink=False, checksumtype=["crc32", "crc32", "crc32"], formatspecs=__file_format_dict__, verbose=False):
|
|
3391
3464
|
if(not hasattr(fp, "write")):
|
|
3392
3465
|
return False
|
|
3393
3466
|
advancedlist = formatspecs['use_advanced_list']
|
|
@@ -3680,7 +3753,7 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
|
|
|
3680
3753
|
tmpoutlist = [ftypehex, fencoding, fcencoding, fname, flinkname, fsize, fatime, fmtime, fctime, fbtime, fmode, fwinattributes, fcompression,
|
|
3681
3754
|
fcsize, fuid, funame, fgid, fgname, fcurfid, fcurinode, flinkcount, fdev, fdev_minor, fdev_major, "+"+str(len(formatspecs['format_delimiter']))]
|
|
3682
3755
|
AppendFileHeaderWithContent(
|
|
3683
|
-
fp, tmpoutlist, extradata, fcontents.read(), [checksumtype[1], checksumtype[2]], formatspecs)
|
|
3756
|
+
fp, tmpoutlist, extradata, jsondata, fcontents.read(), [checksumtype[1], checksumtype[2]], formatspecs)
|
|
3684
3757
|
if(numfiles > 0):
|
|
3685
3758
|
try:
|
|
3686
3759
|
fp.write(AppendNullBytes(
|
|
@@ -3691,7 +3764,7 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
|
|
|
3691
3764
|
return fp
|
|
3692
3765
|
|
|
3693
3766
|
|
|
3694
|
-
def AppendListsWithContent(inlist, fp, dirlistfromtxt=False, filevalues=[], extradata=[], compression="auto", compresswholefile=True, compressionlevel=None, followlink=False, checksumtype=["crc32", "crc32", "crc32"], formatspecs=__file_format_dict__, verbose=False):
|
|
3767
|
+
def AppendListsWithContent(inlist, fp, dirlistfromtxt=False, filevalues=[], extradata=[], jsondata={}, compression="auto", compresswholefile=True, compressionlevel=None, followlink=False, checksumtype=["crc32", "crc32", "crc32"], formatspecs=__file_format_dict__, verbose=False):
|
|
3695
3768
|
if(not hasattr(fp, "write")):
|
|
3696
3769
|
return False
|
|
3697
3770
|
if(verbose):
|
|
@@ -3749,7 +3822,7 @@ def AppendListsWithContent(inlist, fp, dirlistfromtxt=False, filevalues=[], extr
|
|
|
3749
3822
|
fuid, funame, fgid, fgname, fid, finode, flinkcount, fdev, fdev_minor, fdev_major, fseeknextfile]
|
|
3750
3823
|
fcontents.seek(0, 0)
|
|
3751
3824
|
AppendFileHeaderWithContent(
|
|
3752
|
-
fp, tmpoutlist, extradata, fcontents.read(), [checksumtype[1], checksumtype[2]], formatspecs)
|
|
3825
|
+
fp, tmpoutlist, extradata, jsondata, fcontents.read(), [checksumtype[1], checksumtype[2]], formatspecs)
|
|
3753
3826
|
if(numfiles > 0):
|
|
3754
3827
|
try:
|
|
3755
3828
|
fp.write(AppendNullBytes(
|
|
@@ -3759,12 +3832,12 @@ def AppendListsWithContent(inlist, fp, dirlistfromtxt=False, filevalues=[], extr
|
|
|
3759
3832
|
return fp
|
|
3760
3833
|
|
|
3761
3834
|
|
|
3762
|
-
def AppendInFileWithContent(infile, fp, dirlistfromtxt=False, filevalues=[], extradata=[], followlink=False, checksumtype=["crc32", "crc32", "crc32"], formatspecs=__file_format_dict__, verbose=False):
|
|
3835
|
+
def AppendInFileWithContent(infile, fp, dirlistfromtxt=False, filevalues=[], extradata=[], jsondata={}, followlink=False, checksumtype=["crc32", "crc32", "crc32"], formatspecs=__file_format_dict__, verbose=False):
|
|
3763
3836
|
inlist = ReadInFileWithContentToList(infile, "auto", 0, 0, False, False, True, False, formatspecs)
|
|
3764
|
-
return AppendListsWithContent(inlist, fp, dirlistfromtxt, filevalues, extradata, followlink, checksumtype, formatspecs, verbose)
|
|
3837
|
+
return AppendListsWithContent(inlist, fp, dirlistfromtxt, filevalues, extradata, jsondata, followlink, checksumtype, formatspecs, verbose)
|
|
3765
3838
|
|
|
3766
3839
|
|
|
3767
|
-
def AppendFilesWithContentToOutFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, compressionuselist=compressionlistalt, filevalues=[], extradata=[], followlink=False, checksumtype=["crc32", "crc32", "crc32"], formatspecs=__file_format_multi_dict__, verbose=False, returnfp=False):
|
|
3840
|
+
def AppendFilesWithContentToOutFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, compressionuselist=compressionlistalt, filevalues=[], extradata=[], jsondata={}, followlink=False, checksumtype=["crc32", "crc32", "crc32"], formatspecs=__file_format_multi_dict__, verbose=False, returnfp=False):
|
|
3768
3841
|
if(IsNestedDict(formatspecs) and fmttype=="auto" and
|
|
3769
3842
|
(outfile != "-" and outfile is not None and not hasattr(outfile, "read") and not hasattr(outfile, "write"))):
|
|
3770
3843
|
get_in_ext = os.path.splitext(outfile)
|
|
@@ -3805,7 +3878,7 @@ def AppendFilesWithContentToOutFile(infiles, outfile, dirlistfromtxt=False, fmtt
|
|
|
3805
3878
|
fp = CompressOpenFile(outfile, compresswholefile, compressionlevel)
|
|
3806
3879
|
except PermissionError:
|
|
3807
3880
|
return False
|
|
3808
|
-
AppendFilesWithContent(infiles, fp, dirlistfromtxt, filevalues, extradata, compression,
|
|
3881
|
+
AppendFilesWithContent(infiles, fp, dirlistfromtxt, filevalues, extradata, jsondata, compression,
|
|
3809
3882
|
compresswholefile, compressionlevel, compressionuselist, followlink, checksumtype, formatspecs, verbose)
|
|
3810
3883
|
if(outfile == "-" or outfile is None or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
3811
3884
|
fp = CompressCatFile(
|
|
@@ -3844,7 +3917,7 @@ def AppendFilesWithContentToOutFile(infiles, outfile, dirlistfromtxt=False, fmtt
|
|
|
3844
3917
|
return True
|
|
3845
3918
|
|
|
3846
3919
|
|
|
3847
|
-
def AppendListsWithContentToOutFile(inlist, outfile, dirlistfromtxt=False, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, filevalues=[], extradata=[], followlink=False, checksumtype=["crc32", "crc32", "crc32"], formatspecs=__file_format_dict__, verbose=False, returnfp=False):
|
|
3920
|
+
def AppendListsWithContentToOutFile(inlist, outfile, dirlistfromtxt=False, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, filevalues=[], extradata=[], jsondata={}, followlink=False, checksumtype=["crc32", "crc32", "crc32"], formatspecs=__file_format_dict__, verbose=False, returnfp=False):
|
|
3848
3921
|
if(IsNestedDict(formatspecs) and fmttype=="auto" and
|
|
3849
3922
|
(outfile != "-" and outfile is not None and not hasattr(outfile, "read") and not hasattr(outfile, "write"))):
|
|
3850
3923
|
get_in_ext = os.path.splitext(outfile)
|
|
@@ -3885,7 +3958,7 @@ def AppendListsWithContentToOutFile(inlist, outfile, dirlistfromtxt=False, fmtty
|
|
|
3885
3958
|
fp = CompressOpenFile(outfile, compresswholefile, compressionlevel)
|
|
3886
3959
|
except PermissionError:
|
|
3887
3960
|
return False
|
|
3888
|
-
AppendListsWithContent(inlist, fp, dirlistfromtxt, filevalues, extradata, compression,
|
|
3961
|
+
AppendListsWithContent(inlist, fp, dirlistfromtxt, filevalues, extradata, jsondata, compression,
|
|
3889
3962
|
compresswholefile, compressionlevel, followlink, checksumtype, formatspecs, verbose)
|
|
3890
3963
|
if(outfile == "-" or outfile is None or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
3891
3964
|
fp = CompressCatFile(
|
|
@@ -3924,9 +3997,9 @@ def AppendListsWithContentToOutFile(inlist, outfile, dirlistfromtxt=False, fmtty
|
|
|
3924
3997
|
return True
|
|
3925
3998
|
|
|
3926
3999
|
|
|
3927
|
-
def AppendInFileWithContentToOutFile(infile, outfile, dirlistfromtxt=False, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, filevalues=[], extradata=[], followlink=False, checksumtype=["crc32", "crc32", "crc32"], formatspecs=__file_format_dict__, verbose=False, returnfp=False):
|
|
4000
|
+
def AppendInFileWithContentToOutFile(infile, outfile, dirlistfromtxt=False, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, filevalues=[], extradata=[], jsondata={}, followlink=False, checksumtype=["crc32", "crc32", "crc32"], formatspecs=__file_format_dict__, verbose=False, returnfp=False):
|
|
3928
4001
|
inlist = ReadInFileWithContentToList(infile, "auto", 0, 0, False, False, True, False, formatspecs)
|
|
3929
|
-
return AppendListsWithContentToOutFile(inlist, outfile, dirlistfromtxt, fmttype, compression, compresswholefile, compressionlevel, filevalues, extradata, followlink, checksumtype, formatspecs, verbose, returnfp)
|
|
4002
|
+
return AppendListsWithContentToOutFile(inlist, outfile, dirlistfromtxt, fmttype, compression, compresswholefile, compressionlevel, filevalues, extradata, jsondata, followlink, checksumtype, formatspecs, verbose, returnfp)
|
|
3930
4003
|
|
|
3931
4004
|
|
|
3932
4005
|
def PrintPermissionString(fchmode, ftype):
|
|
@@ -4167,6 +4240,8 @@ def CheckCompressionType(infile, formatspecs=__file_format_multi_dict__, closefp
|
|
|
4167
4240
|
filetype = "zlib"
|
|
4168
4241
|
elif(prefp == binascii.unhexlify("78da")):
|
|
4169
4242
|
filetype = "zlib"
|
|
4243
|
+
elif(prefp == binascii.unhexlify("1f9d")):
|
|
4244
|
+
filetype = "compress"
|
|
4170
4245
|
fp.seek(0, 0)
|
|
4171
4246
|
prefp = fp.read(3)
|
|
4172
4247
|
if(prefp == binascii.unhexlify("425a68")):
|
|
@@ -4802,7 +4877,7 @@ def CheckSumSupportAlt(checkfor, guaranteed=True):
|
|
|
4802
4877
|
return False
|
|
4803
4878
|
|
|
4804
4879
|
|
|
4805
|
-
def PackCatFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, compressionuselist=compressionlistalt, followlink=False, checksumtype=["crc32", "crc32", "crc32"], extradata=[], formatspecs=__file_format_multi_dict__, verbose=False, returnfp=False):
|
|
4880
|
+
def PackCatFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, compressionuselist=compressionlistalt, followlink=False, checksumtype=["crc32", "crc32", "crc32"], extradata=[], jsondata={}, formatspecs=__file_format_multi_dict__, verbose=False, returnfp=False):
|
|
4806
4881
|
if(IsNestedDict(formatspecs) and fmttype=="auto" and
|
|
4807
4882
|
(outfile != "-" and outfile is not None and not hasattr(outfile, "read") and not hasattr(outfile, "write"))):
|
|
4808
4883
|
get_in_ext = os.path.splitext(outfile)
|
|
@@ -5140,7 +5215,7 @@ def PackCatFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", compress
|
|
|
5140
5215
|
tmpoutlist = [ftypehex, fencoding, fcencoding, fname, flinkname, fsize, fatime, fmtime, fctime, fbtime, fmode, fwinattributes, fcompression,
|
|
5141
5216
|
fcsize, fuid, funame, fgid, fgname, fcurfid, fcurinode, flinkcount, fdev, fdev_minor, fdev_major, "+"+str(len(formatspecs['format_delimiter']))]
|
|
5142
5217
|
AppendFileHeaderWithContent(
|
|
5143
|
-
fp, tmpoutlist, extradata, fcontents.read(), [checksumtype[1], checksumtype[2]], formatspecs)
|
|
5218
|
+
fp, tmpoutlist, extradata, jsondata, fcontents.read(), [checksumtype[1], checksumtype[2]], formatspecs)
|
|
5144
5219
|
fcontents.close()
|
|
5145
5220
|
if(numfiles > 0):
|
|
5146
5221
|
try:
|
|
@@ -5189,7 +5264,7 @@ def PackCatFileFromDirList(infiles, outfile, dirlistfromtxt=False, fmttype="auto
|
|
|
5189
5264
|
return PackCatFile(infiles, outfile, dirlistfromtxt, fmttype, compression, compresswholefile, compressionlevel, compressionuselist, followlink, checksumtype, extradata, formatspecs, verbose, returnfp)
|
|
5190
5265
|
|
|
5191
5266
|
|
|
5192
|
-
def PackCatFileFromTarFile(infile, outfile, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, compressionuselist=compressionlistalt, checksumtype=["crc32", "crc32", "crc32"], extradata=[], formatspecs=__file_format_dict__, verbose=False, returnfp=False):
|
|
5267
|
+
def PackCatFileFromTarFile(infile, outfile, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, compressionuselist=compressionlistalt, checksumtype=["crc32", "crc32", "crc32"], extradata=[], jsondata={}, formatspecs=__file_format_dict__, verbose=False, returnfp=False):
|
|
5193
5268
|
if(IsNestedDict(formatspecs) and fmttype=="auto" and
|
|
5194
5269
|
(outfile != "-" and outfile is not None and not hasattr(outfile, "read") and not hasattr(outfile, "write"))):
|
|
5195
5270
|
get_in_ext = os.path.splitext(outfile)
|
|
@@ -5440,7 +5515,7 @@ def PackCatFileFromTarFile(infile, outfile, fmttype="auto", compression="auto",
|
|
|
5440
5515
|
tmpoutlist = [ftypehex, fencoding, fcencoding, fname, flinkname, fsize, fatime, fmtime, fctime, fbtime, fmode, fwinattributes, fcompression,
|
|
5441
5516
|
fcsize, fuid, funame, fgid, fgname, fcurfid, fcurinode, flinkcount, fdev, fdev_minor, fdev_major, "+"+str(len(formatspecs['format_delimiter']))]
|
|
5442
5517
|
AppendFileHeaderWithContent(
|
|
5443
|
-
fp, tmpoutlist, extradata, fcontents.read(), [checksumtype[1], checksumtype[2]], formatspecs)
|
|
5518
|
+
fp, tmpoutlist, extradata, jsondata, fcontents.read(), [checksumtype[1], checksumtype[2]], formatspecs)
|
|
5444
5519
|
fcontents.close()
|
|
5445
5520
|
if(numfiles > 0):
|
|
5446
5521
|
try:
|
|
@@ -5485,7 +5560,7 @@ def PackCatFileFromTarFile(infile, outfile, fmttype="auto", compression="auto",
|
|
|
5485
5560
|
return True
|
|
5486
5561
|
|
|
5487
5562
|
|
|
5488
|
-
def PackCatFileFromZipFile(infile, outfile, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, compressionuselist=compressionlistalt, checksumtype=["crc32", "crc32", "crc32"], extradata=[], formatspecs=__file_format_dict__, verbose=False, returnfp=False):
|
|
5563
|
+
def PackCatFileFromZipFile(infile, outfile, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, compressionuselist=compressionlistalt, checksumtype=["crc32", "crc32", "crc32"], extradata=[], jsondata={}, formatspecs=__file_format_dict__, verbose=False, returnfp=False):
|
|
5489
5564
|
if(IsNestedDict(formatspecs) and fmttype=="auto" and
|
|
5490
5565
|
(outfile != "-" and outfile is not None and not hasattr(outfile, "read") and not hasattr(outfile, "write"))):
|
|
5491
5566
|
get_in_ext = os.path.splitext(outfile)
|
|
@@ -5731,7 +5806,7 @@ def PackCatFileFromZipFile(infile, outfile, fmttype="auto", compression="auto",
|
|
|
5731
5806
|
tmpoutlist = [ftypehex, fencoding, fcencoding, fname, flinkname, fsize, fatime, fmtime, fctime, fbtime, fmode, fwinattributes, fcompression,
|
|
5732
5807
|
fcsize, fuid, funame, fgid, fgname, fcurfid, fcurinode, flinkcount, fdev, fdev_minor, fdev_major, "+"+str(len(formatspecs['format_delimiter']))]
|
|
5733
5808
|
AppendFileHeaderWithContent(
|
|
5734
|
-
fp, tmpoutlist, extradata, fcontents.read(), [checksumtype[1], checksumtype[2]], formatspecs)
|
|
5809
|
+
fp, tmpoutlist, extradata, jsondata, fcontents.read(), [checksumtype[1], checksumtype[2]], formatspecs)
|
|
5735
5810
|
fcontents.close()
|
|
5736
5811
|
if(numfiles > 0):
|
|
5737
5812
|
try:
|
|
@@ -5777,11 +5852,11 @@ def PackCatFileFromZipFile(infile, outfile, fmttype="auto", compression="auto",
|
|
|
5777
5852
|
|
|
5778
5853
|
|
|
5779
5854
|
if(not rarfile_support):
|
|
5780
|
-
def PackCatFileFromRarFile(infile, outfile, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, compressionuselist=compressionlistalt, checksumtype=["crc32", "crc32", "crc32"], extradata=[], formatspecs=__file_format_dict__, verbose=False, returnfp=False):
|
|
5855
|
+
def PackCatFileFromRarFile(infile, outfile, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, compressionuselist=compressionlistalt, checksumtype=["crc32", "crc32", "crc32"], extradata=[], jsondata={}, formatspecs=__file_format_dict__, verbose=False, returnfp=False):
|
|
5781
5856
|
return False
|
|
5782
5857
|
|
|
5783
5858
|
if(rarfile_support):
|
|
5784
|
-
def PackCatFileFromRarFile(infile, outfile, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, compressionuselist=compressionlistalt, checksumtype=["crc32", "crc32", "crc32"], extradata=[], formatspecs=__file_format_dict__, verbose=False, returnfp=False):
|
|
5859
|
+
def PackCatFileFromRarFile(infile, outfile, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, compressionuselist=compressionlistalt, checksumtype=["crc32", "crc32", "crc32"], extradata=[], jsondata={}, formatspecs=__file_format_dict__, verbose=False, returnfp=False):
|
|
5785
5860
|
if(IsNestedDict(formatspecs) and fmttype=="auto" and
|
|
5786
5861
|
(outfile != "-" and outfile is not None and not hasattr(outfile, "read") and not hasattr(outfile, "write"))):
|
|
5787
5862
|
get_in_ext = os.path.splitext(outfile)
|
|
@@ -6051,7 +6126,7 @@ if(rarfile_support):
|
|
|
6051
6126
|
tmpoutlist = [ftypehex, fencoding, fcencoding, fname, flinkname, fsize, fatime, fmtime, fctime, fbtime, fmode, fwinattributes, fcompression,
|
|
6052
6127
|
fcsize, fuid, funame, fgid, fgname, fcurfid, fcurinode, flinkcount, fdev, fdev_minor, fdev_major, "+"+str(len(formatspecs['format_delimiter']))]
|
|
6053
6128
|
AppendFileHeaderWithContent(
|
|
6054
|
-
fp, tmpoutlist, extradata, fcontents.read(), [checksumtype[1], checksumtype[2]], formatspecs)
|
|
6129
|
+
fp, tmpoutlist, extradata, jsondata, fcontents.read(), [checksumtype[1], checksumtype[2]], formatspecs)
|
|
6055
6130
|
fcontents.close()
|
|
6056
6131
|
if(numfiles > 0):
|
|
6057
6132
|
try:
|
|
@@ -6101,7 +6176,7 @@ if(not py7zr_support):
|
|
|
6101
6176
|
return False
|
|
6102
6177
|
|
|
6103
6178
|
if(py7zr_support):
|
|
6104
|
-
def PackCatFileFromSevenZipFile(infile, outfile, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, compressionuselist=compressionlistalt, checksumtype=["crc32", "crc32", "crc32"], extradata=[], formatspecs=__file_format_dict__, verbose=False, returnfp=False):
|
|
6179
|
+
def PackCatFileFromSevenZipFile(infile, outfile, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, compressionuselist=compressionlistalt, checksumtype=["crc32", "crc32", "crc32"], extradata=[], jsondata={}, formatspecs=__file_format_dict__, verbose=False, returnfp=False):
|
|
6105
6180
|
if(IsNestedDict(formatspecs) and fmttype=="auto" and
|
|
6106
6181
|
(outfile != "-" and outfile is not None and not hasattr(outfile, "read") and not hasattr(outfile, "write"))):
|
|
6107
6182
|
get_in_ext = os.path.splitext(outfile)
|
|
@@ -6304,7 +6379,7 @@ if(py7zr_support):
|
|
|
6304
6379
|
tmpoutlist = [ftypehex, fencoding, fcencoding, fname, flinkname, fsize, fatime, fmtime, fctime, fbtime, fmode, fwinattributes, fcompression,
|
|
6305
6380
|
fcsize, fuid, funame, fgid, fgname, fcurfid, fcurinode, flinkcount, fdev, fdev_minor, fdev_major, "+"+str(len(formatspecs['format_delimiter']))]
|
|
6306
6381
|
AppendFileHeaderWithContent(
|
|
6307
|
-
fp, tmpoutlist, extradata, fcontents.read(), [checksumtype[1], checksumtype[2]], formatspecs)
|
|
6382
|
+
fp, tmpoutlist, extradata, jsondata, fcontents.read(), [checksumtype[1], checksumtype[2]], formatspecs)
|
|
6308
6383
|
fcontents.close()
|
|
6309
6384
|
if(numfiles > 0):
|
|
6310
6385
|
try:
|
|
@@ -6521,7 +6596,10 @@ def CatFileSeekToFileNum(infile, fmttype="auto", seekto=0, listonly=False, conte
|
|
|
6521
6596
|
fextrafieldslist = json.loads(base64.b64decode(fextrafieldslist[0]).decode("UTF-8"))
|
|
6522
6597
|
fnumextrafields = len(fextrafieldslist)
|
|
6523
6598
|
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
6524
|
-
|
|
6599
|
+
try:
|
|
6600
|
+
fextrafieldslist = json.loads(fextrafieldslist[0])
|
|
6601
|
+
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
6602
|
+
pass
|
|
6525
6603
|
if(curloc > 0):
|
|
6526
6604
|
fp.seek(curloc, 0)
|
|
6527
6605
|
formversion = re.findall("([\\d]+)", formstring)
|
|
@@ -6544,7 +6622,7 @@ def CatFileSeekToFileNum(infile, fmttype="auto", seekto=0, listonly=False, conte
|
|
|
6544
6622
|
fcompresstype = compresscheck
|
|
6545
6623
|
if(fcompresstype==formatspecs['format_magic']):
|
|
6546
6624
|
fcompresstype = ""
|
|
6547
|
-
outlist = {'fnumfiles': fnumfiles, 'fformat': formversions[0], 'fcompression': fcompresstype, 'fencoding': fhencoding, 'fversion': formversions[1], 'fostype': fostype, 'fheadersize': fheadsize, 'fsize': CatSizeEnd, 'fnumfields': fnumfields + 2, 'fformatspecs': formatspecs, 'fchecksumtype': fprechecksumtype, 'fheaderchecksum': fprechecksum, 'frawheader': [formstring] + inheader, 'fextrafields': fnumextrafields, 'fextrafieldsize': fnumextrafieldsize, '
|
|
6625
|
+
outlist = {'fnumfiles': fnumfiles, 'fformat': formversions[0], 'fcompression': fcompresstype, 'fencoding': fhencoding, 'fversion': formversions[1], 'fostype': fostype, 'fheadersize': fheadsize, 'fsize': CatSizeEnd, 'fnumfields': fnumfields + 2, 'fformatspecs': formatspecs, 'fchecksumtype': fprechecksumtype, 'fheaderchecksum': fprechecksum, 'frawheader': [formstring] + inheader, 'fextrafields': fnumextrafields, 'fextrafieldsize': fnumextrafieldsize, 'fextradata': fextrafieldslist, 'ffilelist': []}
|
|
6548
6626
|
if(seekto >= fnumfiles):
|
|
6549
6627
|
seekto = fnumfiles - 1
|
|
6550
6628
|
if(seekto < 0):
|
|
@@ -6818,7 +6896,10 @@ def CatFileSeekToFileName(infile, fmttype="auto", seekfile=None, listonly=False,
|
|
|
6818
6896
|
fextrafieldslist = json.loads(base64.b64decode(fextrafieldslist[0]).decode("UTF-8"))
|
|
6819
6897
|
fnumextrafields = len(fextrafieldslist)
|
|
6820
6898
|
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
6821
|
-
|
|
6899
|
+
try:
|
|
6900
|
+
fextrafieldslist = json.loads(fextrafieldslist[0])
|
|
6901
|
+
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
6902
|
+
pass
|
|
6822
6903
|
if(curloc > 0):
|
|
6823
6904
|
fp.seek(curloc, 0)
|
|
6824
6905
|
formversion = re.findall("([\\d]+)", formstring)
|
|
@@ -6841,7 +6922,7 @@ def CatFileSeekToFileName(infile, fmttype="auto", seekfile=None, listonly=False,
|
|
|
6841
6922
|
fcompresstype = compresscheck
|
|
6842
6923
|
if(fcompresstype==formatspecs['format_magic']):
|
|
6843
6924
|
fcompresstype = ""
|
|
6844
|
-
outlist = {'fnumfiles': fnumfiles, 'fformat': formversions[0], 'fcompression': fcompresstype, 'fencoding': fhencoding, 'fversion': formversions[1], 'fostype': fostype, 'fheadersize': fheadsize, 'fsize': CatSizeEnd, 'fnumfields': fnumfields + 2, 'fformatspecs': formatspecs, 'fchecksumtype': fprechecksumtype, 'fheaderchecksum': fprechecksum, 'frawheader': [formstring] + inheader, 'fextrafields': fnumextrafields, 'fextrafieldsize': fnumextrafieldsize, '
|
|
6925
|
+
outlist = {'fnumfiles': fnumfiles, 'fformat': formversions[0], 'fcompression': fcompresstype, 'fencoding': fhencoding, 'fversion': formversions[1], 'fostype': fostype, 'fheadersize': fheadsize, 'fsize': CatSizeEnd, 'fnumfields': fnumfields + 2, 'fformatspecs': formatspecs, 'fchecksumtype': fprechecksumtype, 'fheaderchecksum': fprechecksum, 'frawheader': [formstring] + inheader, 'fextrafields': fnumextrafields, 'fextrafieldsize': fnumextrafieldsize, 'fextradata': fextrafieldslist, 'ffilelist': []}
|
|
6845
6926
|
seekto = fnumfiles - 1
|
|
6846
6927
|
filefound = False
|
|
6847
6928
|
if(seekto >= 0):
|
|
@@ -6889,14 +6970,23 @@ def CatFileSeekToFileName(infile, fmttype="auto", seekfile=None, listonly=False,
|
|
|
6889
6970
|
prefdev_minor = int(preheaderdata[24], 16)
|
|
6890
6971
|
prefdev_major = int(preheaderdata[25], 16)
|
|
6891
6972
|
prefseeknextfile = preheaderdata[26]
|
|
6892
|
-
|
|
6893
|
-
|
|
6894
|
-
|
|
6973
|
+
prefsize = int(preheaderdata[7], 16)
|
|
6974
|
+
prefcompression = preheaderdata[14]
|
|
6975
|
+
prefcsize = int(preheaderdata[15], 16)
|
|
6976
|
+
prefseeknextfile = preheaderdata[26]
|
|
6977
|
+
prefjsonsize = int(HeaderOut[27], 16)
|
|
6978
|
+
prefjoutfprejsoncontent = fp.read(prefjsonsize).decode("UTF-8")
|
|
6979
|
+
if(prefjsonsize <= 0):
|
|
6980
|
+
prefjoutfprejsoncontent = "".encode()
|
|
6981
|
+
fp.seek(len(formatspecs['format_delimiter']), 1)
|
|
6982
|
+
prefextrasize = int(preheaderdata[28], 16)
|
|
6983
|
+
prefextrafields = int(preheaderdata[29], 16)
|
|
6984
|
+
extrastart = 30
|
|
6895
6985
|
extraend = extrastart + prefextrafields
|
|
6896
6986
|
prefcs = preheaderdata[-2].lower()
|
|
6897
6987
|
prenewfcs = preheaderdata[-1].lower()
|
|
6898
6988
|
prenewfcs = GetHeaderChecksum(
|
|
6899
|
-
preheaderdata[:-2], preheaderdata[-4].lower(), True, formatspecs)
|
|
6989
|
+
preheaderdata[:-2] + [prefjoutfprejsoncontent], preheaderdata[-4].lower(), True, formatspecs)
|
|
6900
6990
|
if(prefcs != prenewfcs and not skipchecksum):
|
|
6901
6991
|
VerbosePrintOut("File Header Checksum Error with file " +
|
|
6902
6992
|
prefname + " at offset " + str(prefhstart))
|
|
@@ -7196,14 +7286,31 @@ def CatFileValidate(infile, fmttype="auto", formatspecs=__file_format_multi_dict
|
|
|
7196
7286
|
outfdev_minor = int(inheaderdata[24], 16)
|
|
7197
7287
|
outfdev_major = int(inheaderdata[25], 16)
|
|
7198
7288
|
outfseeknextfile = inheaderdata[26]
|
|
7199
|
-
|
|
7200
|
-
|
|
7201
|
-
|
|
7289
|
+
outfjsonsize = int(inheaderdata[27], 16)
|
|
7290
|
+
outfjsoncontent = {}
|
|
7291
|
+
outfprejsoncontent = fp.read(outfjsonsize).decode("UTF-8")
|
|
7292
|
+
if(outfjsonsize > 0):
|
|
7293
|
+
try:
|
|
7294
|
+
outfjsoncontent = json.loads(base64.b64decode(outfprejsoncontent).decode("UTF-8"))
|
|
7295
|
+
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
7296
|
+
try:
|
|
7297
|
+
outfjsoncontent = json.loads(outfprejsoncontent.decode("UTF-8"))
|
|
7298
|
+
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
7299
|
+
outfprejsoncontent = ""
|
|
7300
|
+
outfjsoncontent = {}
|
|
7301
|
+
else:
|
|
7302
|
+
outfprejsoncontent = ""
|
|
7303
|
+
outfjsoncontent = {}
|
|
7304
|
+
fp.seek(len(formatspecs['format_delimiter']), 1)
|
|
7305
|
+
outfextrasize = int(inheaderdata[28], 16)
|
|
7306
|
+
outfextrafields = int(inheaderdata[29], 16)
|
|
7307
|
+
extrafieldslist = []
|
|
7308
|
+
extrastart = 30
|
|
7202
7309
|
extraend = extrastart + outfextrafields
|
|
7203
7310
|
outfcs = inheaderdata[-2].lower()
|
|
7204
7311
|
outfccs = inheaderdata[-1].lower()
|
|
7205
7312
|
infcs = GetHeaderChecksum(
|
|
7206
|
-
inheaderdata[:-2], inheaderdata[-4].lower(), True, formatspecs)
|
|
7313
|
+
inheaderdata[:-2] + [outfprejsoncontent], inheaderdata[-4].lower(), True, formatspecs)
|
|
7207
7314
|
if(verbose):
|
|
7208
7315
|
VerbosePrintOut(outfname)
|
|
7209
7316
|
VerbosePrintOut("Record Number " + str(il) + "; File ID " +
|
|
@@ -7448,7 +7555,10 @@ def CatFileToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=Fals
|
|
|
7448
7555
|
fextrafieldslist = json.loads(base64.b64decode(fextrafieldslist[0]).decode("UTF-8"))
|
|
7449
7556
|
fnumextrafields = len(fextrafieldslist)
|
|
7450
7557
|
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
7451
|
-
|
|
7558
|
+
try:
|
|
7559
|
+
fextrafieldslist = json.loads(fextrafieldslist[0])
|
|
7560
|
+
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
7561
|
+
pass
|
|
7452
7562
|
if(curloc > 0):
|
|
7453
7563
|
fp.seek(curloc, 0)
|
|
7454
7564
|
formversion = re.findall("([\\d]+)", formstring)
|
|
@@ -7471,7 +7581,7 @@ def CatFileToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=Fals
|
|
|
7471
7581
|
fcompresstype = compresscheck
|
|
7472
7582
|
if(fcompresstype==formatspecs['format_magic']):
|
|
7473
7583
|
fcompresstype = ""
|
|
7474
|
-
outlist = {'fnumfiles': fnumfiles, 'fformat': formversions[0], 'fcompression': fcompresstype, 'fencoding': fhencoding, 'fversion': formversions[1], 'fostype': fostype, 'fheadersize': fheadsize, 'fsize': CatSizeEnd, 'fnumfields': fnumfields + 2, 'fformatspecs': formatspecs, 'fchecksumtype': fprechecksumtype, 'fheaderchecksum': fprechecksum, 'frawheader': [formstring] + inheader, 'fextrafields': fnumextrafields, 'fextrafieldsize': fnumextrafieldsize, '
|
|
7584
|
+
outlist = {'fnumfiles': fnumfiles, 'fformat': formversions[0], 'fcompression': fcompresstype, 'fencoding': fhencoding, 'fversion': formversions[1], 'fostype': fostype, 'fheadersize': fheadsize, 'fsize': CatSizeEnd, 'fnumfields': fnumfields + 2, 'fformatspecs': formatspecs, 'fchecksumtype': fprechecksumtype, 'fheaderchecksum': fprechecksum, 'frawheader': [formstring] + inheader, 'fextrafields': fnumextrafields, 'fextrafieldsize': fnumextrafieldsize, 'fextradata': fextrafieldslist, 'ffilelist': []}
|
|
7475
7585
|
if(seekstart < 0 and seekstart > fnumfiles):
|
|
7476
7586
|
seekstart = 0
|
|
7477
7587
|
if(seekend == 0 or seekend > fnumfiles and seekend < seekstart):
|
|
@@ -7502,14 +7612,19 @@ def CatFileToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=Fals
|
|
|
7502
7612
|
prefcompression = preheaderdata[14]
|
|
7503
7613
|
prefcsize = int(preheaderdata[15], 16)
|
|
7504
7614
|
prefseeknextfile = preheaderdata[26]
|
|
7505
|
-
|
|
7506
|
-
|
|
7507
|
-
|
|
7615
|
+
prefjsonsize = int(preheaderdata[27], 16)
|
|
7616
|
+
prefjoutfprejsoncontent = fp.read(prefjsonsize).decode("UTF-8")
|
|
7617
|
+
if(prefjsonsize <= 0):
|
|
7618
|
+
prefjoutfprejsoncontent = ""
|
|
7619
|
+
fp.seek(len(formatspecs['format_delimiter']), 1)
|
|
7620
|
+
prefextrasize = int(preheaderdata[28], 16)
|
|
7621
|
+
prefextrafields = int(preheaderdata[29], 16)
|
|
7622
|
+
extrastart = 30
|
|
7508
7623
|
extraend = extrastart + prefextrafields
|
|
7509
7624
|
prefcs = preheaderdata[-2].lower()
|
|
7510
7625
|
prenewfcs = preheaderdata[-1].lower()
|
|
7511
7626
|
prenewfcs = GetHeaderChecksum(
|
|
7512
|
-
preheaderdata[:-2], preheaderdata[-4].lower(), True, formatspecs)
|
|
7627
|
+
preheaderdata[:-2] + [prefjoutfprejsoncontent], preheaderdata[-4].lower(), True, formatspecs)
|
|
7513
7628
|
if(prefcs != prenewfcs and not skipchecksum):
|
|
7514
7629
|
VerbosePrintOut("File Header Checksum Error with file " +
|
|
7515
7630
|
prefname + " at offset " + str(prefhstart))
|
|
@@ -7599,10 +7714,26 @@ def CatFileToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=Fals
|
|
|
7599
7714
|
outfdev_minor = int(inheaderdata[24], 16)
|
|
7600
7715
|
outfdev_major = int(inheaderdata[25], 16)
|
|
7601
7716
|
outfseeknextfile = inheaderdata[26]
|
|
7602
|
-
|
|
7603
|
-
|
|
7717
|
+
outfjsonsize = int(inheaderdata[27], 16)
|
|
7718
|
+
outfjsoncontent = {}
|
|
7719
|
+
outfprejsoncontent = fp.read(outfjsonsize).decode("UTF-8")
|
|
7720
|
+
if(outfjsonsize > 0):
|
|
7721
|
+
try:
|
|
7722
|
+
outfjsoncontent = json.loads(base64.b64decode(outfprejsoncontent).decode("UTF-8"))
|
|
7723
|
+
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
7724
|
+
try:
|
|
7725
|
+
outfjsoncontent = json.loads(outfprejsoncontent.decode("UTF-8"))
|
|
7726
|
+
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
7727
|
+
outfprejsoncontent = ""
|
|
7728
|
+
outfjsoncontent = {}
|
|
7729
|
+
else:
|
|
7730
|
+
outfprejsoncontent = ""
|
|
7731
|
+
outfjsoncontent = {}
|
|
7732
|
+
fp.seek(len(formatspecs['format_delimiter']), 1)
|
|
7733
|
+
outfextrasize = int(inheaderdata[28], 16)
|
|
7734
|
+
outfextrafields = int(inheaderdata[29], 16)
|
|
7604
7735
|
extrafieldslist = []
|
|
7605
|
-
extrastart =
|
|
7736
|
+
extrastart = 30
|
|
7606
7737
|
extraend = extrastart + outfextrafields
|
|
7607
7738
|
while(extrastart < extraend):
|
|
7608
7739
|
extrafieldslist.append(inheaderdata[extrastart])
|
|
@@ -7612,11 +7743,14 @@ def CatFileToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=Fals
|
|
|
7612
7743
|
extrafieldslist = json.loads(base64.b64decode(extrafieldslist[0]).decode("UTF-8"))
|
|
7613
7744
|
outfextrafields = len(extrafieldslist)
|
|
7614
7745
|
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
7615
|
-
|
|
7746
|
+
try:
|
|
7747
|
+
fextrafieldslist = json.loads(fextrafieldslist[0])
|
|
7748
|
+
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
7749
|
+
pass
|
|
7616
7750
|
outfcs = inheaderdata[-2].lower()
|
|
7617
7751
|
outfccs = inheaderdata[-1].lower()
|
|
7618
7752
|
infcs = GetHeaderChecksum(
|
|
7619
|
-
inheaderdata[:-2], inheaderdata[-4].lower(), True, formatspecs)
|
|
7753
|
+
inheaderdata[:-2] + [outfprejsoncontent], inheaderdata[-4].lower(), True, formatspecs)
|
|
7620
7754
|
if(outfcs != infcs and not skipchecksum):
|
|
7621
7755
|
VerbosePrintOut("File Header Checksum Error with file " +
|
|
7622
7756
|
outfname + " at offset " + str(outfhstart))
|
|
@@ -7683,7 +7817,7 @@ def CatFileToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=Fals
|
|
|
7683
7817
|
outfcontents.seek(0, 0)
|
|
7684
7818
|
if(not contentasfile):
|
|
7685
7819
|
outfcontents = outfcontents.read()
|
|
7686
|
-
outlist['ffilelist'].append({'fid': realidnum, 'fidalt': fileidnum, 'fheadersize': outfheadsize, 'fhstart': outfhstart, 'fhend': outfhend, 'ftype': outftype, 'fencoding': outfencoding, 'fcencoding': outfcencoding, 'fname': outfname, 'fbasedir': outfbasedir, 'flinkname': outflinkname, 'fsize': outfsize, 'fatime': outfatime, 'fmtime': outfmtime, 'fctime': outfctime, 'fbtime': outfbtime, 'fmode': outfmode, 'fchmode': outfchmode, 'ftypemod': outftypemod, 'fwinattributes': outfwinattributes, 'fcompression': outfcompression, 'fcsize': outfcsize, 'fuid': outfuid, 'funame': outfuname, 'fgid': outfgid, 'fgname': outfgname, 'finode': outfinode, 'flinkcount': outflinkcount, 'fdev': outfdev, 'fminor': outfdev_minor, 'fmajor': outfdev_major, 'fseeknextfile': outfseeknextfile, 'fheaderchecksumtype': inheaderdata[-4], 'fcontentchecksumtype': inheaderdata[-3], 'fnumfields': outfnumfields + 2, 'frawheader': inheaderdata, 'fextrafields': outfextrafields, 'fextrafieldsize': outfextrasize, '
|
|
7820
|
+
outlist['ffilelist'].append({'fid': realidnum, 'fidalt': fileidnum, 'fheadersize': outfheadsize, 'fhstart': outfhstart, 'fhend': outfhend, 'ftype': outftype, 'fencoding': outfencoding, 'fcencoding': outfcencoding, 'fname': outfname, 'fbasedir': outfbasedir, 'flinkname': outflinkname, 'fsize': outfsize, 'fatime': outfatime, 'fmtime': outfmtime, 'fctime': outfctime, 'fbtime': outfbtime, 'fmode': outfmode, 'fchmode': outfchmode, 'ftypemod': outftypemod, 'fwinattributes': outfwinattributes, 'fcompression': outfcompression, 'fcsize': outfcsize, 'fuid': outfuid, 'funame': outfuname, 'fgid': outfgid, 'fgname': outfgname, 'finode': outfinode, 'flinkcount': outflinkcount, 'fdev': outfdev, 'fminor': outfdev_minor, 'fmajor': outfdev_major, 'fseeknextfile': outfseeknextfile, 'fheaderchecksumtype': inheaderdata[-4], 'fcontentchecksumtype': inheaderdata[-3], 'fnumfields': outfnumfields + 2, 'frawheader': inheaderdata, 'fextrafields': outfextrafields, 'fextrafieldsize': outfextrasize, 'fextradata': extrafieldslist, 'fjsondata': outfjsoncontent, 'fheaderchecksum': outfcs, 'fcontentchecksum': outfccs, 'fhascontents': pyhascontents, 'fcontentstart': outfcontentstart, 'fcontentend': outfcontentend, 'fcontentasfile': contentasfile, 'fcontents': outfcontents})
|
|
7687
7821
|
fileidnum = fileidnum + 1
|
|
7688
7822
|
realidnum = realidnum + 1
|
|
7689
7823
|
if(returnfp):
|
|
@@ -7862,7 +7996,7 @@ def CatFileArrayToArrayIndex(inarray, seekstart=0, seekend=0, listonly=False, un
|
|
|
7862
7996
|
return outarray
|
|
7863
7997
|
|
|
7864
7998
|
|
|
7865
|
-
def RePackCatFile(infile, outfile, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, compressionuselist=compressionlistalt, followlink=False, seekstart=0, seekend=0, checksumtype=["crc32", "crc32", "crc32"], skipchecksum=False, extradata=[], formatspecs=__file_format_dict__, verbose=False, returnfp=False):
|
|
7999
|
+
def RePackCatFile(infile, outfile, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, compressionuselist=compressionlistalt, followlink=False, seekstart=0, seekend=0, checksumtype=["crc32", "crc32", "crc32"], skipchecksum=False, extradata=[], jsondata={}, formatspecs=__file_format_dict__, verbose=False, returnfp=False):
|
|
7866
8000
|
if(isinstance(infile, dict)):
|
|
7867
8001
|
listarchivefiles = infile
|
|
7868
8002
|
else:
|
|
@@ -7984,8 +8118,10 @@ def RePackCatFile(infile, outfile, fmttype="auto", compression="auto", compressw
|
|
|
7984
8118
|
if(len(listarchivefiles['ffilelist'][reallcfi]['fextralist']) > listarchivefiles['ffilelist'][reallcfi]['fextrafields'] and len(listarchivefiles['ffilelist'][reallcfi]['fextralist']) > 0):
|
|
7985
8119
|
listarchivefiles['ffilelist'][reallcfi]['fextrafields'] = len(
|
|
7986
8120
|
listarchivefiles['ffilelist'][reallcfi]['fextralist'])
|
|
7987
|
-
if(not followlink and len(extradata)
|
|
8121
|
+
if(not followlink and len(extradata) <= 0):
|
|
7988
8122
|
extradata = listarchivefiles['ffilelist'][reallcfi]['fextralist']
|
|
8123
|
+
if(not followlink and len(jsondata) <= 0):
|
|
8124
|
+
jsondata = listarchivefiles['ffilelist'][reallcfi]['jsondata']
|
|
7989
8125
|
fcontents = listarchivefiles['ffilelist'][reallcfi]['fcontents']
|
|
7990
8126
|
if(not listarchivefiles['ffilelist'][reallcfi]['fcontentasfile']):
|
|
7991
8127
|
fcontents = BytesIO(fcontents)
|
|
@@ -8066,6 +8202,8 @@ def RePackCatFile(infile, outfile, fmttype="auto", compression="auto", compressw
|
|
|
8066
8202
|
flinkinfo['fextrafields'] = len(flinkinfo['fextralist'])
|
|
8067
8203
|
if(len(extradata) < 0):
|
|
8068
8204
|
extradata = flinkinfo['fextralist']
|
|
8205
|
+
if(len(jsondata) < 0):
|
|
8206
|
+
extradata = flinkinfo['jsondata']
|
|
8069
8207
|
fcontents = flinkinfo['fcontents']
|
|
8070
8208
|
if(not flinkinfo['fcontentasfile']):
|
|
8071
8209
|
fcontents = BytesIO(fcontents)
|
|
@@ -8091,7 +8229,7 @@ def RePackCatFile(infile, outfile, fmttype="auto", compression="auto", compressw
|
|
|
8091
8229
|
tmpoutlist = [ftypehex, fencoding, fcencoding, fname, flinkname, fsize, fatime, fmtime, fctime, fbtime, fmode, fwinattributes, fcompression, fcsize,
|
|
8092
8230
|
fuid, funame, fgid, fgname, fcurfid, fcurinode, flinkcount, fdev, fdev_minor, fdev_major, fseeknextfile]
|
|
8093
8231
|
AppendFileHeaderWithContent(
|
|
8094
|
-
fp, tmpoutlist, extradata, fcontents.read(), [checksumtype[1], checksumtype[2]], formatspecs)
|
|
8232
|
+
fp, tmpoutlist, extradata, jsondata, fcontents.read(), [checksumtype[1], checksumtype[2]], formatspecs)
|
|
8095
8233
|
fcontents.close()
|
|
8096
8234
|
lcfi = lcfi + 1
|
|
8097
8235
|
reallcfi = reallcfi + 1
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
Copyright 2016-2024 Game Maker 2k - http://intdb.sourceforge.net/
|
|
14
14
|
Copyright 2016-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
|
|
15
15
|
|
|
16
|
-
$FileInfo: setup.py - Last Update:
|
|
16
|
+
$FileInfo: setup.py - Last Update: 2/7/2025 Ver. 0.18.2 RC 1 - Author: cooldude2k $
|
|
17
17
|
'''
|
|
18
18
|
|
|
19
19
|
import os
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|