PyCatFile 0.21.0__py3-none-any.whl → 0.21.4__py3-none-any.whl
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.21.0.data → pycatfile-0.21.4.data}/scripts/catfile.py +6 -6
- {pycatfile-0.21.0.data → pycatfile-0.21.4.data}/scripts/neocatfile.py +1 -1
- {pycatfile-0.21.0.dist-info → pycatfile-0.21.4.dist-info}/METADATA +4 -4
- pycatfile-0.21.4.dist-info/RECORD +10 -0
- pycatfile.py +565 -456
- pycatfile-0.21.0.dist-info/RECORD +0 -10
- {pycatfile-0.21.0.data → pycatfile-0.21.4.data}/scripts/catneofile.py +0 -0
- {pycatfile-0.21.0.dist-info → pycatfile-0.21.4.dist-info}/WHEEL +0 -0
- {pycatfile-0.21.0.dist-info → pycatfile-0.21.4.dist-info}/licenses/LICENSE +0 -0
- {pycatfile-0.21.0.dist-info → pycatfile-0.21.4.dist-info}/top_level.txt +0 -0
- {pycatfile-0.21.0.dist-info → pycatfile-0.21.4.dist-info}/zip-safe +0 -0
pycatfile.py
CHANGED
|
@@ -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: 8/26/2025 Ver. 0.21.4 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
|
|
@@ -32,10 +32,12 @@ import socket
|
|
|
32
32
|
import hashlib
|
|
33
33
|
import inspect
|
|
34
34
|
import datetime
|
|
35
|
+
import tempfile
|
|
35
36
|
import logging
|
|
36
37
|
import zipfile
|
|
37
38
|
import binascii
|
|
38
39
|
import platform
|
|
40
|
+
from io import StringIO, BytesIO
|
|
39
41
|
try:
|
|
40
42
|
from backports import tempfile
|
|
41
43
|
except ImportError:
|
|
@@ -243,17 +245,6 @@ except ImportError:
|
|
|
243
245
|
from urllib2 import Request, build_opener, HTTPBasicAuthHandler
|
|
244
246
|
from urlparse import urlparse
|
|
245
247
|
|
|
246
|
-
# StringIO and BytesIO
|
|
247
|
-
try:
|
|
248
|
-
from io import StringIO, BytesIO
|
|
249
|
-
except ImportError:
|
|
250
|
-
try:
|
|
251
|
-
from cStringIO import StringIO
|
|
252
|
-
from cStringIO import StringIO as BytesIO
|
|
253
|
-
except ImportError:
|
|
254
|
-
from StringIO import StringIO
|
|
255
|
-
from StringIO import StringIO as BytesIO
|
|
256
|
-
|
|
257
248
|
def get_importing_script_path():
|
|
258
249
|
# Inspect the stack and get the frame of the caller
|
|
259
250
|
stack = inspect.stack()
|
|
@@ -275,22 +266,6 @@ def get_default_threads():
|
|
|
275
266
|
|
|
276
267
|
|
|
277
268
|
__use_pysftp__ = False
|
|
278
|
-
__use_alt_format__ = False
|
|
279
|
-
__use_env_file__ = True
|
|
280
|
-
__use_ini_file__ = True
|
|
281
|
-
__use_ini_name__ = "catfile.ini"
|
|
282
|
-
if('PYCATFILE_CONFIG_FILE' in os.environ and os.path.exists(os.environ['PYCATFILE_CONFIG_FILE']) and __use_env_file__):
|
|
283
|
-
scriptconf = os.environ['PYCATFILE_CONFIG_FILE']
|
|
284
|
-
else:
|
|
285
|
-
prescriptpath = get_importing_script_path()
|
|
286
|
-
if(prescriptpath is not None):
|
|
287
|
-
scriptconf = os.path.join(os.path.dirname(prescriptpath), __use_ini_name__)
|
|
288
|
-
else:
|
|
289
|
-
scriptconf = ""
|
|
290
|
-
if os.path.exists(scriptconf):
|
|
291
|
-
__config_file__ = scriptconf
|
|
292
|
-
else:
|
|
293
|
-
__config_file__ = os.path.join(os.path.dirname(os.path.realpath(__file__)), __use_ini_name__)
|
|
294
269
|
if(not havepysftp):
|
|
295
270
|
__use_pysftp__ = False
|
|
296
271
|
__use_http_lib__ = "httpx"
|
|
@@ -328,7 +303,25 @@ def is_only_nonprintable(var):
|
|
|
328
303
|
__file_format_multi_dict__ = {}
|
|
329
304
|
__file_format_default__ = "CatFile"
|
|
330
305
|
__include_defaults__ = True
|
|
306
|
+
__use_inmemfile__ = False
|
|
331
307
|
__program_name__ = "Py"+__file_format_default__
|
|
308
|
+
__use_env_file__ = True
|
|
309
|
+
__use_ini_file__ = True
|
|
310
|
+
__use_ini_name__ = "catfile.ini"
|
|
311
|
+
__use_json_file__ = False
|
|
312
|
+
__use_json_name__ = "catfile.json"
|
|
313
|
+
if('PYCATFILE_CONFIG_FILE' in os.environ and os.path.exists(os.environ['PYCATFILE_CONFIG_FILE']) and __use_env_file__):
|
|
314
|
+
scriptconf = os.environ['PYCATFILE_CONFIG_FILE']
|
|
315
|
+
else:
|
|
316
|
+
prescriptpath = get_importing_script_path()
|
|
317
|
+
if(prescriptpath is not None):
|
|
318
|
+
scriptconf = os.path.join(os.path.dirname(prescriptpath), __use_ini_name__)
|
|
319
|
+
else:
|
|
320
|
+
scriptconf = ""
|
|
321
|
+
if os.path.exists(scriptconf):
|
|
322
|
+
__config_file__ = scriptconf
|
|
323
|
+
else:
|
|
324
|
+
__config_file__ = os.path.join(os.path.dirname(os.path.realpath(__file__)), __use_ini_name__)
|
|
332
325
|
if __use_ini_file__ and os.path.exists(__config_file__):
|
|
333
326
|
config = configparser.ConfigParser()
|
|
334
327
|
config.read(__config_file__)
|
|
@@ -340,6 +333,7 @@ if __use_ini_file__ and os.path.exists(__config_file__):
|
|
|
340
333
|
__file_format_default__ = decode_unicode_escape(config.get('config', 'default'))
|
|
341
334
|
__program_name__ = decode_unicode_escape(config.get('config', 'proname'))
|
|
342
335
|
__include_defaults__ = config.getboolean('config', 'includedef')
|
|
336
|
+
__use_inmemfile__ = config.getboolean('config', 'inmemfile')
|
|
343
337
|
# Loop through all sections
|
|
344
338
|
for section in config.sections():
|
|
345
339
|
required_keys = [
|
|
@@ -391,12 +385,12 @@ __file_format_extension__ = __file_format_multi_dict__[__file_format_default__][
|
|
|
391
385
|
__file_format_dict__ = __file_format_multi_dict__[__file_format_default__]
|
|
392
386
|
__project__ = __program_name__
|
|
393
387
|
__project_url__ = "https://github.com/GameMaker2k/PyCatFile"
|
|
394
|
-
__version_info__ = (0, 21,
|
|
395
|
-
__version_date_info__ = (2025, 9,
|
|
388
|
+
__version_info__ = (0, 21, 4, "RC 1", 1)
|
|
389
|
+
__version_date_info__ = (2025, 9, 26, "RC 1", 1)
|
|
396
390
|
__version_date__ = str(__version_date_info__[0]) + "." + str(
|
|
397
391
|
__version_date_info__[1]).zfill(2) + "." + str(__version_date_info__[2]).zfill(2)
|
|
398
392
|
__revision__ = __version_info__[3]
|
|
399
|
-
__revision_id__ = "$Id:
|
|
393
|
+
__revision_id__ = "$Id: 4b73b24d1d9cb1fb5011cf0090b2e853058cd6fe $"
|
|
400
394
|
if(__version_info__[4] is not None):
|
|
401
395
|
__version_date_plusrc__ = __version_date__ + \
|
|
402
396
|
"-" + str(__version_date_info__[4])
|
|
@@ -586,6 +580,105 @@ def VerbosePrintOutReturn(dbgtxt, outtype="log", dbgenable=True, dgblevel=20):
|
|
|
586
580
|
return dbgtxt
|
|
587
581
|
|
|
588
582
|
|
|
583
|
+
# --- Helpers ---
|
|
584
|
+
def _normalize_initial_data(data, isbytes, encoding):
|
|
585
|
+
"""Return data in the correct type for write(): bytes (if isbytes) or text (if not)."""
|
|
586
|
+
if data is None:
|
|
587
|
+
return None
|
|
588
|
+
|
|
589
|
+
if isbytes:
|
|
590
|
+
# Want bytes
|
|
591
|
+
if isinstance(data, bytes):
|
|
592
|
+
return data
|
|
593
|
+
# Py2: str is already bytes, unicode needs encode
|
|
594
|
+
if sys.version_info[0] == 2:
|
|
595
|
+
try:
|
|
596
|
+
unicode # noqa: F821
|
|
597
|
+
except NameError:
|
|
598
|
+
pass
|
|
599
|
+
else:
|
|
600
|
+
if isinstance(data, unicode): # noqa: F821
|
|
601
|
+
return data.encode(encoding)
|
|
602
|
+
# Py3 str -> encode
|
|
603
|
+
return str(data).encode(encoding)
|
|
604
|
+
else:
|
|
605
|
+
# Want text (unicode/str)
|
|
606
|
+
if sys.version_info[0] == 2:
|
|
607
|
+
try:
|
|
608
|
+
unicode # noqa: F821
|
|
609
|
+
if isinstance(data, unicode): # noqa: F821
|
|
610
|
+
return data
|
|
611
|
+
# bytes/str -> decode
|
|
612
|
+
return data.decode(encoding) if isinstance(data, str) else unicode(data) # noqa: F821
|
|
613
|
+
except NameError:
|
|
614
|
+
# Very defensive; shouldn't happen
|
|
615
|
+
return data
|
|
616
|
+
else:
|
|
617
|
+
# Py3: want str
|
|
618
|
+
if isinstance(data, bytes):
|
|
619
|
+
return data.decode(encoding)
|
|
620
|
+
return str(data)
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
def MkTempFile(data=None, inmem=__use_inmemfile__, isbytes=True, prefix=__project__,
|
|
624
|
+
delete=True, encoding="utf-8"):
|
|
625
|
+
"""
|
|
626
|
+
Return a file-like handle.
|
|
627
|
+
- If inmem=True: returns StringIO (text) or BytesIO (bytes).
|
|
628
|
+
- If inmem=False: returns a NamedTemporaryFile opened in text or binary mode.
|
|
629
|
+
Args:
|
|
630
|
+
data: optional initial content; if provided, it's written and the handle is seek(0)
|
|
631
|
+
inmem: bool — return in-memory handle if True
|
|
632
|
+
isbytes: bool — choose bytes (True) or text (False)
|
|
633
|
+
prefix: str — tempfile prefix
|
|
634
|
+
delete: bool — whether the tempfile is deleted on close (NamedTemporaryFile)
|
|
635
|
+
encoding: str — used for text mode (and for conversions when needed)
|
|
636
|
+
"""
|
|
637
|
+
init = _normalize_initial_data(data, isbytes, encoding)
|
|
638
|
+
|
|
639
|
+
if inmem:
|
|
640
|
+
buf = BytesIO() if isbytes else StringIO()
|
|
641
|
+
if init is not None:
|
|
642
|
+
buf.write(init)
|
|
643
|
+
buf.seek(0)
|
|
644
|
+
return buf
|
|
645
|
+
|
|
646
|
+
mode = "wb+" if isbytes else "w+"
|
|
647
|
+
kwargs = {"prefix": prefix or "", "delete": delete, "mode": mode}
|
|
648
|
+
|
|
649
|
+
# Only Python 3's text-mode files accept encoding/newline explicitly
|
|
650
|
+
if not isbytes and sys.version_info[0] >= 3:
|
|
651
|
+
kwargs["encoding"] = encoding
|
|
652
|
+
kwargs["newline"] = ""
|
|
653
|
+
|
|
654
|
+
f = tempfile.NamedTemporaryFile(**kwargs)
|
|
655
|
+
|
|
656
|
+
if init is not None:
|
|
657
|
+
f.write(init)
|
|
658
|
+
f.seek(0)
|
|
659
|
+
return f
|
|
660
|
+
|
|
661
|
+
|
|
662
|
+
def MkTempFileSmart(data=None, isbytes=True, prefix=__project__, max_mem=1024*1024, encoding="utf-8"):
|
|
663
|
+
"""
|
|
664
|
+
Spooled temp file: starts in memory and spills to disk past max_mem.
|
|
665
|
+
Behaves like BytesIO/StringIO for small data, with the same preload+seek(0) behavior.
|
|
666
|
+
"""
|
|
667
|
+
mode = "wb+" if isbytes else "w+"
|
|
668
|
+
kwargs = {"mode": mode, "max_size": max_mem, "prefix": prefix or ""}
|
|
669
|
+
if not isbytes and sys.version_info[0] >= 3:
|
|
670
|
+
kwargs["encoding"] = encoding
|
|
671
|
+
kwargs["newline"] = ""
|
|
672
|
+
|
|
673
|
+
f = tempfile.SpooledTemporaryFile(**kwargs)
|
|
674
|
+
|
|
675
|
+
init = _normalize_initial_data(data, isbytes, encoding)
|
|
676
|
+
if init is not None:
|
|
677
|
+
f.write(init)
|
|
678
|
+
f.seek(0)
|
|
679
|
+
return f
|
|
680
|
+
|
|
681
|
+
|
|
589
682
|
def RemoveWindowsPath(dpath):
|
|
590
683
|
"""
|
|
591
684
|
Normalize a path by converting backslashes to forward slashes
|
|
@@ -1722,9 +1815,9 @@ def GetFileChecksum(instr, checksumtype="crc32", encodedata=True, formatspecs=__
|
|
|
1722
1815
|
|
|
1723
1816
|
|
|
1724
1817
|
def ValidateHeaderChecksum(inlist=[], checksumtype="crc32", inchecksum="0", formatspecs=__file_format_dict__):
|
|
1725
|
-
|
|
1818
|
+
catfileheadercshex = GetHeaderChecksum(
|
|
1726
1819
|
inlist, checksumtype, True, formatspecs).lower()
|
|
1727
|
-
return inchecksum.lower() ==
|
|
1820
|
+
return inchecksum.lower() == catfileheadercshex
|
|
1728
1821
|
|
|
1729
1822
|
|
|
1730
1823
|
def ValidateFileChecksum(infile, checksumtype="crc32", inchecksum="0", formatspecs=__file_format_dict__):
|
|
@@ -1922,7 +2015,7 @@ def ReadFileHeaderDataBySize(fp, delimiter=__file_format_dict__['format_delimite
|
|
|
1922
2015
|
headersize = int(preheaderdata[0], 16)
|
|
1923
2016
|
if(headersize <= 0):
|
|
1924
2017
|
return []
|
|
1925
|
-
subfp =
|
|
2018
|
+
subfp = MkTempFile()
|
|
1926
2019
|
subfp.write(fp.read(headersize))
|
|
1927
2020
|
fp.seek(len(delimiter), 1)
|
|
1928
2021
|
subfp.seek(0, 0)
|
|
@@ -1959,15 +2052,15 @@ def ReadFileHeaderDataWithContent(fp, listonly=False, uncompress=True, skipcheck
|
|
|
1959
2052
|
HeaderOut = ReadFileHeaderDataWoSize(fp, delimiter)
|
|
1960
2053
|
if(len(HeaderOut) == 0):
|
|
1961
2054
|
return False
|
|
1962
|
-
if(re.findall("^[.|/]", HeaderOut[
|
|
1963
|
-
fname = HeaderOut[
|
|
2055
|
+
if(re.findall("^[.|/]", HeaderOut[5])):
|
|
2056
|
+
fname = HeaderOut[5]
|
|
1964
2057
|
else:
|
|
1965
|
-
fname = "./"+HeaderOut[
|
|
2058
|
+
fname = "./"+HeaderOut[5]
|
|
1966
2059
|
fcs = HeaderOut[-2].lower()
|
|
1967
2060
|
fccs = HeaderOut[-1].lower()
|
|
1968
|
-
fsize = int(HeaderOut[
|
|
1969
|
-
fcompression = HeaderOut[
|
|
1970
|
-
fcsize = int(HeaderOut[
|
|
2061
|
+
fsize = int(HeaderOut[7], 16)
|
|
2062
|
+
fcompression = HeaderOut[14]
|
|
2063
|
+
fcsize = int(HeaderOut[15], 16)
|
|
1971
2064
|
fseeknextfile = HeaderOut[26]
|
|
1972
2065
|
fjsontype = HeaderOut[27]
|
|
1973
2066
|
fjsonlen = int(HeaderOut[28], 16)
|
|
@@ -2006,7 +2099,7 @@ def ReadFileHeaderDataWithContent(fp, listonly=False, uncompress=True, skipcheck
|
|
|
2006
2099
|
return False
|
|
2007
2100
|
fhend = fp.tell() - 1
|
|
2008
2101
|
fcontentstart = fp.tell()
|
|
2009
|
-
fcontents =
|
|
2102
|
+
fcontents = MkTempFile()
|
|
2010
2103
|
if(fsize > 0 and not listonly):
|
|
2011
2104
|
if(fcompression == "none" or fcompression == "" or fcompression == "auto"):
|
|
2012
2105
|
fcontents.write(fp.read(fsize))
|
|
@@ -2020,6 +2113,7 @@ def ReadFileHeaderDataWithContent(fp, listonly=False, uncompress=True, skipcheck
|
|
|
2020
2113
|
fcontents.seek(0, 0)
|
|
2021
2114
|
newfccs = GetFileChecksum(
|
|
2022
2115
|
fcontents.read(), HeaderOut[-3].lower(), False, formatspecs)
|
|
2116
|
+
fcontents.seek(0, 0)
|
|
2023
2117
|
if(fccs != newfccs and not skipchecksum and not listonly):
|
|
2024
2118
|
VerbosePrintOut("File Content Checksum Error with file " +
|
|
2025
2119
|
fname + " at offset " + str(fcontentstart))
|
|
@@ -2032,7 +2126,7 @@ def ReadFileHeaderDataWithContent(fp, listonly=False, uncompress=True, skipcheck
|
|
|
2032
2126
|
if(uncompress):
|
|
2033
2127
|
cfcontents = UncompressFileAlt(fcontents, formatspecs)
|
|
2034
2128
|
cfcontents.seek(0, 0)
|
|
2035
|
-
|
|
2129
|
+
fcontents = MkTempFile()
|
|
2036
2130
|
shutil.copyfileobj(cfcontents, fcontents)
|
|
2037
2131
|
cfcontents.close()
|
|
2038
2132
|
fcontents.seek(0, 0)
|
|
@@ -2124,6 +2218,7 @@ def ReadFileHeaderDataWithContentToArray(fp, listonly=False, contentasfile=True,
|
|
|
2124
2218
|
fextrafieldslist = json.loads(fextrafieldslist[0])
|
|
2125
2219
|
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
2126
2220
|
pass
|
|
2221
|
+
fjstart = fp.tell()
|
|
2127
2222
|
if(fjsontype=="json"):
|
|
2128
2223
|
fjsoncontent = {}
|
|
2129
2224
|
fprejsoncontent = fp.read(fjsonsize).decode("UTF-8")
|
|
@@ -2145,17 +2240,17 @@ def ReadFileHeaderDataWithContentToArray(fp, listonly=False, contentasfile=True,
|
|
|
2145
2240
|
fjsoncontent = {}
|
|
2146
2241
|
elif(fjsontype=="list"):
|
|
2147
2242
|
fprejsoncontent = fp.read(fjsonsize).decode("UTF-8")
|
|
2148
|
-
flisttmp =
|
|
2243
|
+
flisttmp = MkTempFile()
|
|
2149
2244
|
flisttmp.write(fprejsoncontent.encode())
|
|
2150
2245
|
flisttmp.seek(0)
|
|
2151
2246
|
fjsoncontent = ReadFileHeaderData(flisttmp, fjsonlen, delimiter)
|
|
2152
2247
|
flisttmp.close()
|
|
2153
2248
|
fjsonrawcontent = fjsoncontent
|
|
2154
|
-
if(
|
|
2249
|
+
if(fjsonlen==1):
|
|
2155
2250
|
try:
|
|
2156
2251
|
fjsonrawcontent = base64.b64decode(fjsoncontent[0]).decode("UTF-8")
|
|
2157
2252
|
fjsoncontent = json.loads(base64.b64decode(fjsoncontent[0]).decode("UTF-8"))
|
|
2158
|
-
|
|
2253
|
+
fjsonlen = len(fjsoncontent)
|
|
2159
2254
|
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
2160
2255
|
try:
|
|
2161
2256
|
fjsonrawcontent = fjsoncontent[0]
|
|
@@ -2163,6 +2258,7 @@ def ReadFileHeaderDataWithContentToArray(fp, listonly=False, contentasfile=True,
|
|
|
2163
2258
|
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
2164
2259
|
pass
|
|
2165
2260
|
fp.seek(len(delimiter), 1)
|
|
2261
|
+
fjend = fp.tell() - 1
|
|
2166
2262
|
jsonfcs = GetFileChecksum(fprejsoncontent, fjsonchecksumtype, True, formatspecs)
|
|
2167
2263
|
if(jsonfcs != fjsonchecksum and not skipchecksum):
|
|
2168
2264
|
VerbosePrintOut("File JSON Data Checksum Error with file " +
|
|
@@ -2180,7 +2276,7 @@ def ReadFileHeaderDataWithContentToArray(fp, listonly=False, contentasfile=True,
|
|
|
2180
2276
|
return False
|
|
2181
2277
|
fhend = fp.tell() - 1
|
|
2182
2278
|
fcontentstart = fp.tell()
|
|
2183
|
-
fcontents =
|
|
2279
|
+
fcontents = MkTempFile()
|
|
2184
2280
|
pyhascontents = False
|
|
2185
2281
|
if(fsize > 0 and not listonly):
|
|
2186
2282
|
if(fcompression == "none" or fcompression == "" or fcompression == "auto"):
|
|
@@ -2197,6 +2293,7 @@ def ReadFileHeaderDataWithContentToArray(fp, listonly=False, contentasfile=True,
|
|
|
2197
2293
|
fcontents.seek(0, 0)
|
|
2198
2294
|
newfccs = GetFileChecksum(
|
|
2199
2295
|
fcontents.read(), HeaderOut[-3].lower(), False, formatspecs)
|
|
2296
|
+
fcontents.seek(0, 0)
|
|
2200
2297
|
if(fccs != newfccs and not skipchecksum and not listonly):
|
|
2201
2298
|
VerbosePrintOut("File Content Checksum Error with file " +
|
|
2202
2299
|
fname + " at offset " + str(fcontentstart))
|
|
@@ -2210,7 +2307,7 @@ def ReadFileHeaderDataWithContentToArray(fp, listonly=False, contentasfile=True,
|
|
|
2210
2307
|
cfcontents = UncompressFileAlt(
|
|
2211
2308
|
fcontents, formatspecs)
|
|
2212
2309
|
cfcontents.seek(0, 0)
|
|
2213
|
-
fcontents =
|
|
2310
|
+
fcontents = MkTempFile()
|
|
2214
2311
|
shutil.copyfileobj(cfcontents, fcontents)
|
|
2215
2312
|
cfcontents.close()
|
|
2216
2313
|
fcontents.seek(0, 0)
|
|
@@ -2238,7 +2335,7 @@ def ReadFileHeaderDataWithContentToArray(fp, listonly=False, contentasfile=True,
|
|
|
2238
2335
|
if(not contentasfile):
|
|
2239
2336
|
fcontents = fcontents.read()
|
|
2240
2337
|
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,
|
|
2241
|
-
'fdev': fdev, 'fminor': fdev_minor, 'fmajor': fdev_major, 'fseeknextfile': fseeknextfile, 'fheaderchecksumtype': HeaderOut[-4], 'fjsonchecksumtype':
|
|
2338
|
+
'fdev': fdev, 'fminor': fdev_minor, 'fmajor': fdev_major, 'fseeknextfile': fseeknextfile, 'fheaderchecksumtype': HeaderOut[-4], 'fjsonchecksumtype': fjsonchecksumtype, 'fcontentchecksumtype': HeaderOut[-3], 'fnumfields': fnumfields + 2, 'frawheader': HeaderOut, 'fextrafields': fextrafields, 'fextrafieldsize': fextrasize, 'fextradata': fextrafieldslist, 'fjsontype': fjsontype, 'fjsonlen': fjsonlen, 'fjsonsize': fjsonsize, 'fjsonrawdata': fjsonrawcontent, 'fjsondata': fjsoncontent, 'fjstart': fjstart, 'fjend': fjend, 'fheaderchecksum': fcs, 'fjsonchecksum': fjsonchecksum, 'fcontentchecksum': fccs, 'fhascontents': pyhascontents, 'fcontentstart': fcontentstart, 'fcontentend': fcontentend, 'fcontentasfile': contentasfile, 'fcontents': fcontents}
|
|
2242
2339
|
return outlist
|
|
2243
2340
|
|
|
2244
2341
|
|
|
@@ -2329,17 +2426,17 @@ def ReadFileHeaderDataWithContentToList(fp, listonly=False, contentasfile=False,
|
|
|
2329
2426
|
fjsoncontent = {}
|
|
2330
2427
|
elif(fjsontype=="list"):
|
|
2331
2428
|
fprejsoncontent = fp.read(fjsonsize).decode("UTF-8")
|
|
2332
|
-
flisttmp =
|
|
2429
|
+
flisttmp = MkTempFile()
|
|
2333
2430
|
flisttmp.write(fprejsoncontent.encode())
|
|
2334
2431
|
flisttmp.seek(0)
|
|
2335
2432
|
fjsoncontent = ReadFileHeaderData(flisttmp, fjsonlen, delimiter)
|
|
2336
2433
|
flisttmp.close()
|
|
2337
2434
|
fjsonrawcontent = fjsoncontent
|
|
2338
|
-
if(
|
|
2435
|
+
if(fjsonlen==1):
|
|
2339
2436
|
try:
|
|
2340
2437
|
fjsonrawcontent = base64.b64decode(fjsoncontent[0]).decode("UTF-8")
|
|
2341
2438
|
fjsoncontent = json.loads(base64.b64decode(fjsoncontent[0]).decode("UTF-8"))
|
|
2342
|
-
|
|
2439
|
+
fjsonlen = len(fjsoncontent)
|
|
2343
2440
|
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
|
|
2344
2441
|
try:
|
|
2345
2442
|
fjsonrawcontent = fjsoncontent[0]
|
|
@@ -2364,7 +2461,7 @@ def ReadFileHeaderDataWithContentToList(fp, listonly=False, contentasfile=False,
|
|
|
2364
2461
|
return False
|
|
2365
2462
|
fhend = fp.tell() - 1
|
|
2366
2463
|
fcontentstart = fp.tell()
|
|
2367
|
-
fcontents =
|
|
2464
|
+
fcontents = MkTempFile()
|
|
2368
2465
|
pyhascontents = False
|
|
2369
2466
|
if(fsize > 0 and not listonly):
|
|
2370
2467
|
if(fcompression == "none" or fcompression == "" or fcompression == "auto"):
|
|
@@ -2394,7 +2491,7 @@ def ReadFileHeaderDataWithContentToList(fp, listonly=False, contentasfile=False,
|
|
|
2394
2491
|
cfcontents = UncompressFileAlt(
|
|
2395
2492
|
fcontents, formatspecs)
|
|
2396
2493
|
cfcontents.seek(0, 0)
|
|
2397
|
-
fcontents =
|
|
2494
|
+
fcontents = MkTempFile()
|
|
2398
2495
|
shutil.copyfileobj(cfcontents, fcontents)
|
|
2399
2496
|
cfcontents.close()
|
|
2400
2497
|
fcontents.seek(0, 0)
|
|
@@ -2549,11 +2646,11 @@ def ReadFileDataWithContentToArray(fp, seekstart=0, seekend=0, listonly=False, c
|
|
|
2549
2646
|
formversions = re.search('(.*?)(\\d+)', formstring).groups()
|
|
2550
2647
|
fcompresstype = ""
|
|
2551
2648
|
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': []}
|
|
2552
|
-
if(seekstart < 0
|
|
2649
|
+
if (seekstart < 0) or (seekstart > fnumfiles):
|
|
2553
2650
|
seekstart = 0
|
|
2554
|
-
if(seekend == 0 or seekend > fnumfiles
|
|
2651
|
+
if (seekend == 0) or (seekend > fnumfiles) or (seekend < seekstart):
|
|
2555
2652
|
seekend = fnumfiles
|
|
2556
|
-
elif(seekend < 0 and abs(seekend) <= fnumfiles and abs(seekend) >= seekstart):
|
|
2653
|
+
elif (seekend < 0) and (abs(seekend) <= fnumfiles) and (abs(seekend) >= seekstart):
|
|
2557
2654
|
seekend = fnumfiles - abs(seekend)
|
|
2558
2655
|
if(seekstart > 0):
|
|
2559
2656
|
il = 0
|
|
@@ -2564,14 +2661,18 @@ def ReadFileDataWithContentToArray(fp, seekstart=0, seekend=0, listonly=False, c
|
|
|
2564
2661
|
if(len(preheaderdata) == 0):
|
|
2565
2662
|
break
|
|
2566
2663
|
prefsize = int(preheaderdata[5], 16)
|
|
2664
|
+
if(re.findall("^[.|/]", preheaderdata[5])):
|
|
2665
|
+
prefname = preheaderdata[5]
|
|
2666
|
+
else:
|
|
2667
|
+
prefname = "./"+preheaderdata[5]
|
|
2567
2668
|
prefseeknextfile = preheaderdata[26]
|
|
2568
2669
|
prefjsonlen = int(preheaderdata[28], 16)
|
|
2569
2670
|
prefjsonsize = int(preheaderdata[29], 16)
|
|
2570
2671
|
prefjsonchecksumtype = preheaderdata[30]
|
|
2571
2672
|
prefjsonchecksum = preheaderdata[31]
|
|
2572
|
-
|
|
2673
|
+
prejsoncontent = fp.read(prefjsonsize).decode("UTF-8")
|
|
2573
2674
|
fp.seek(len(delimiter), 1)
|
|
2574
|
-
prejsonfcs = GetFileChecksum(
|
|
2675
|
+
prejsonfcs = GetFileChecksum(prejsoncontent, prefjsonchecksumtype, True, formatspecs)
|
|
2575
2676
|
if(prejsonfcs != prefjsonchecksum and not skipchecksum):
|
|
2576
2677
|
VerbosePrintOut("File JSON Data Checksum Error with file " +
|
|
2577
2678
|
prefname + " at offset " + str(prefhstart))
|
|
@@ -2581,7 +2682,7 @@ def ReadFileDataWithContentToArray(fp, seekstart=0, seekend=0, listonly=False, c
|
|
|
2581
2682
|
preheaderdata[:-2], preheaderdata[-4].lower(), True, formatspecs)
|
|
2582
2683
|
prefcs = preheaderdata[-2]
|
|
2583
2684
|
if(prefcs != prenewfcs and not skipchecksum):
|
|
2584
|
-
|
|
2685
|
+
VerbosePrintOut("File Header Checksum Error with file " +
|
|
2585
2686
|
prefname + " at offset " + str(prefhstart))
|
|
2586
2687
|
VerbosePrintOut("'" + prefcs + "' != " +
|
|
2587
2688
|
"'" + prenewfcs + "'")
|
|
@@ -2590,7 +2691,7 @@ def ReadFileDataWithContentToArray(fp, seekstart=0, seekend=0, listonly=False, c
|
|
|
2590
2691
|
invalid_archive = True
|
|
2591
2692
|
prefhend = fp.tell() - 1
|
|
2592
2693
|
prefcontentstart = fp.tell()
|
|
2593
|
-
prefcontents =
|
|
2694
|
+
prefcontents = MkTempFile()
|
|
2594
2695
|
pyhascontents = False
|
|
2595
2696
|
if(prefsize > 0):
|
|
2596
2697
|
prefcontents.write(fp.read(prefsize))
|
|
@@ -2704,11 +2805,11 @@ def ReadFileDataWithContentToList(fp, seekstart=0, seekend=0, listonly=False, co
|
|
|
2704
2805
|
return False
|
|
2705
2806
|
formversions = re.search('(.*?)(\\d+)', formstring).groups()
|
|
2706
2807
|
outlist = []
|
|
2707
|
-
if(seekstart < 0
|
|
2808
|
+
if (seekstart < 0) or (seekstart > fnumfiles):
|
|
2708
2809
|
seekstart = 0
|
|
2709
|
-
if(seekend == 0 or seekend > fnumfiles
|
|
2810
|
+
if (seekend == 0) or (seekend > fnumfiles) or (seekend < seekstart):
|
|
2710
2811
|
seekend = fnumfiles
|
|
2711
|
-
elif(seekend < 0 and abs(seekend) <= fnumfiles and abs(seekend) >= seekstart):
|
|
2812
|
+
elif (seekend < 0) and (abs(seekend) <= fnumfiles) and (abs(seekend) >= seekstart):
|
|
2712
2813
|
seekend = fnumfiles - abs(seekend)
|
|
2713
2814
|
if(seekstart > 0):
|
|
2714
2815
|
il = 0
|
|
@@ -2723,16 +2824,20 @@ def ReadFileDataWithContentToList(fp, seekstart=0, seekend=0, listonly=False, co
|
|
|
2723
2824
|
if(len(preheaderdata) == 0):
|
|
2724
2825
|
break
|
|
2725
2826
|
prefsize = int(preheaderdata[5], 16)
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2827
|
+
if(re.findall("^[.|/]", preheaderdata[5])):
|
|
2828
|
+
prefname = preheaderdata[5]
|
|
2829
|
+
else:
|
|
2830
|
+
prefname = "./"+preheaderdata[5]
|
|
2831
|
+
prefcompression = preheaderdata[14]
|
|
2832
|
+
prefcsize = int(preheaderdata[15], 16)
|
|
2833
|
+
prefseeknextfile = preheaderdata[26]
|
|
2729
2834
|
prefjsonlen = int(preheaderdata[28], 16)
|
|
2730
2835
|
prefjsonsize = int(preheaderdata[29], 16)
|
|
2731
2836
|
prefjsonchecksumtype = preheaderdata[30]
|
|
2732
2837
|
prefjsonchecksum = preheaderdata[31]
|
|
2733
2838
|
prefprejsoncontent = fp.read(prefjsonsize).decode("UTF-8")
|
|
2734
2839
|
fp.seek(len(delimiter), 1)
|
|
2735
|
-
prejsonfcs = GetFileChecksum(
|
|
2840
|
+
prejsonfcs = GetFileChecksum(prefprejsoncontent, prefjsonchecksumtype, True, formatspecs)
|
|
2736
2841
|
if(prejsonfcs != prefjsonchecksum and not skipchecksum):
|
|
2737
2842
|
VerbosePrintOut("File JSON Data Checksum Error with file " +
|
|
2738
2843
|
prefname + " at offset " + str(prefhstart))
|
|
@@ -2819,13 +2924,13 @@ def ReadInFileWithContentToArray(infile, fmttype="auto", seekstart=0, seekend=0,
|
|
|
2819
2924
|
fp = UncompressFileAlt(fp, formatspecs)
|
|
2820
2925
|
checkcompressfile = CheckCompressionSubType(fp, formatspecs, True)
|
|
2821
2926
|
if(checkcompressfile == "tarfile" and TarFileCheck(infile)):
|
|
2822
|
-
return TarFileToArray(infile, seekstart, seekend, listonly, contentasfile, skipchecksum, formatspecs, seektoend,
|
|
2927
|
+
return TarFileToArray(infile, seekstart, seekend, listonly, contentasfile, skipchecksum, formatspecs, seektoend, True)
|
|
2823
2928
|
elif(checkcompressfile == "zipfile" and zipfile.is_zipfile(infile)):
|
|
2824
|
-
return ZipFileToArray(infile, seekstart, seekend, listonly, contentasfile, skipchecksum, formatspecs, seektoend,
|
|
2929
|
+
return ZipFileToArray(infile, seekstart, seekend, listonly, contentasfile, skipchecksum, formatspecs, seektoend, True)
|
|
2825
2930
|
elif(rarfile_support and checkcompressfile == "rarfile" and (rarfile.is_rarfile(infile) or rarfile.is_rarfile_sfx(infile))):
|
|
2826
|
-
return RarFileToArray(infile, seekstart, seekend, listonly, contentasfile, skipchecksum, formatspecs, seektoend,
|
|
2931
|
+
return RarFileToArray(infile, seekstart, seekend, listonly, contentasfile, skipchecksum, formatspecs, seektoend, True)
|
|
2827
2932
|
elif(py7zr_support and checkcompressfile == "7zipfile" and py7zr.is_7zfile(infile)):
|
|
2828
|
-
return SevenZipFileToArray(infile, seekstart, seekend, listonly, contentasfile, skipchecksum, formatspecs, seektoend,
|
|
2933
|
+
return SevenZipFileToArray(infile, seekstart, seekend, listonly, contentasfile, skipchecksum, formatspecs, seektoend, True)
|
|
2829
2934
|
elif(IsSingleDict(formatspecs) and checkcompressfile != formatspecs['format_magic']):
|
|
2830
2935
|
return False
|
|
2831
2936
|
elif(IsNestedDict(formatspecs) and checkcompressfile not in formatspecs):
|
|
@@ -2854,7 +2959,7 @@ def ReadInFileWithContentToArray(infile, fmttype="auto", seekstart=0, seekend=0,
|
|
|
2854
2959
|
return False
|
|
2855
2960
|
fp.seek(0, 0)
|
|
2856
2961
|
elif(infile == "-"):
|
|
2857
|
-
fp =
|
|
2962
|
+
fp = MkTempFile()
|
|
2858
2963
|
if(hasattr(sys.stdin, "buffer")):
|
|
2859
2964
|
shutil.copyfileobj(sys.stdin.buffer, fp)
|
|
2860
2965
|
else:
|
|
@@ -2875,7 +2980,7 @@ def ReadInFileWithContentToArray(infile, fmttype="auto", seekstart=0, seekend=0,
|
|
|
2875
2980
|
return False
|
|
2876
2981
|
fp.seek(0, 0)
|
|
2877
2982
|
elif(isinstance(infile, bytes) and sys.version_info[0] >= 3):
|
|
2878
|
-
fp =
|
|
2983
|
+
fp = MkTempFile()
|
|
2879
2984
|
fp.write(infile)
|
|
2880
2985
|
fp.seek(0, 0)
|
|
2881
2986
|
fp = UncompressFileAlt(fp, formatspecs)
|
|
@@ -2935,13 +3040,13 @@ def ReadInFileWithContentToArray(infile, fmttype="auto", seekstart=0, seekend=0,
|
|
|
2935
3040
|
if(IsNestedDict(formatspecs) and checkcompressfile in formatspecs):
|
|
2936
3041
|
formatspecs = formatspecs[checkcompressfile]
|
|
2937
3042
|
if(checkcompressfile == "tarfile" and TarFileCheck(infile)):
|
|
2938
|
-
return TarFileToArray(infile, seekstart, seekend, listonly, skipchecksum, formatspecs, seektoend,
|
|
3043
|
+
return TarFileToArray(infile, seekstart, seekend, listonly, skipchecksum, formatspecs, seektoend, True)
|
|
2939
3044
|
elif(checkcompressfile == "zipfile" and zipfile.is_zipfile(infile)):
|
|
2940
|
-
return ZipFileToArray(infile, seekstart, seekend, listonly, skipchecksum, formatspecs, seektoend,
|
|
3045
|
+
return ZipFileToArray(infile, seekstart, seekend, listonly, skipchecksum, formatspecs, seektoend, True)
|
|
2941
3046
|
elif(rarfile_support and checkcompressfile == "rarfile" and (rarfile.is_rarfile(infile) or rarfile.is_rarfile_sfx(infile))):
|
|
2942
|
-
return RarFileToArray(infile, seekstart, seekend, listonly, skipchecksum, formatspecs, seektoend,
|
|
3047
|
+
return RarFileToArray(infile, seekstart, seekend, listonly, skipchecksum, formatspecs, seektoend, True)
|
|
2943
3048
|
elif(py7zr_support and checkcompressfile == "7zipfile" and py7zr.is_7zfile(infile)):
|
|
2944
|
-
return SevenZipFileToArray(infile, seekstart, seekend, listonly, skipchecksum, formatspecs, seektoend,
|
|
3049
|
+
return SevenZipFileToArray(infile, seekstart, seekend, listonly, skipchecksum, formatspecs, seektoend, True)
|
|
2945
3050
|
elif(IsSingleDict(formatspecs) and checkcompressfile != formatspecs['format_magic']):
|
|
2946
3051
|
return False
|
|
2947
3052
|
elif(IsNestedDict(formatspecs) and checkcompressfile not in formatspecs):
|
|
@@ -2980,7 +3085,7 @@ def ReadInMultipleFileWithContentToArray(infile, fmttype="auto", seekstart=0, se
|
|
|
2980
3085
|
infile = [infile]
|
|
2981
3086
|
outretval = {}
|
|
2982
3087
|
for curfname in infile:
|
|
2983
|
-
|
|
3088
|
+
outretval[curfname] = ReadInFileWithContentToArray(curfname, fmttype, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, formatspecs, seektoend)
|
|
2984
3089
|
return outretval
|
|
2985
3090
|
|
|
2986
3091
|
def ReadInMultipleFilesWithContentToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=False, contentasfile=True, uncompress=True, skipchecksum=False, formatspecs=__file_format_multi_dict__, seektoend=False):
|
|
@@ -3007,13 +3112,13 @@ def ReadInFileWithContentToList(infile, fmttype="auto", seekstart=0, seekend=0,
|
|
|
3007
3112
|
fp = UncompressFileAlt(fp, formatspecs)
|
|
3008
3113
|
checkcompressfile = CheckCompressionSubType(fp, formatspecs, True)
|
|
3009
3114
|
if(checkcompressfile == "tarfile" and TarFileCheck(infile)):
|
|
3010
|
-
return TarFileToArray(infile, seekstart, seekend, listonly, contentasfile, skipchecksum, formatspecs, seektoend,
|
|
3115
|
+
return TarFileToArray(infile, seekstart, seekend, listonly, contentasfile, skipchecksum, formatspecs, seektoend, True)
|
|
3011
3116
|
elif(checkcompressfile == "zipfile" and zipfile.is_zipfile(infile)):
|
|
3012
|
-
return ZipFileToArray(infile, seekstart, seekend, listonly, contentasfile, skipchecksum, formatspecs, seektoend,
|
|
3117
|
+
return ZipFileToArray(infile, seekstart, seekend, listonly, contentasfile, skipchecksum, formatspecs, seektoend, True)
|
|
3013
3118
|
elif(rarfile_support and checkcompressfile == "rarfile" and (rarfile.is_rarfile(infile) or rarfile.is_rarfile_sfx(infile))):
|
|
3014
|
-
return RarFileToArray(infile, seekstart, seekend, listonly, contentasfile, skipchecksum, formatspecs, seektoend,
|
|
3119
|
+
return RarFileToArray(infile, seekstart, seekend, listonly, contentasfile, skipchecksum, formatspecs, seektoend, True)
|
|
3015
3120
|
elif(py7zr_support and checkcompressfile == "7zipfile" and py7zr.is_7zfile(infile)):
|
|
3016
|
-
return SevenZipFileToArray(infile, seekstart, seekend, listonly, contentasfile, skipchecksum, formatspecs, seektoend,
|
|
3121
|
+
return SevenZipFileToArray(infile, seekstart, seekend, listonly, contentasfile, skipchecksum, formatspecs, seektoend, True)
|
|
3017
3122
|
elif(IsSingleDict(formatspecs) and checkcompressfile != formatspecs['format_magic']):
|
|
3018
3123
|
return False
|
|
3019
3124
|
elif(IsNestedDict(formatspecs) and checkcompressfile not in formatspecs):
|
|
@@ -3042,7 +3147,7 @@ def ReadInFileWithContentToList(infile, fmttype="auto", seekstart=0, seekend=0,
|
|
|
3042
3147
|
return False
|
|
3043
3148
|
fp.seek(0, 0)
|
|
3044
3149
|
elif(infile == "-"):
|
|
3045
|
-
fp =
|
|
3150
|
+
fp = MkTempFile()
|
|
3046
3151
|
if(hasattr(sys.stdin, "buffer")):
|
|
3047
3152
|
shutil.copyfileobj(sys.stdin.buffer, fp)
|
|
3048
3153
|
else:
|
|
@@ -3063,7 +3168,7 @@ def ReadInFileWithContentToList(infile, fmttype="auto", seekstart=0, seekend=0,
|
|
|
3063
3168
|
return False
|
|
3064
3169
|
fp.seek(0, 0)
|
|
3065
3170
|
elif(isinstance(infile, bytes) and sys.version_info[0] >= 3):
|
|
3066
|
-
fp =
|
|
3171
|
+
fp = MkTempFile()
|
|
3067
3172
|
fp.write(infile)
|
|
3068
3173
|
fp.seek(0, 0)
|
|
3069
3174
|
fp = UncompressFileAlt(fp, formatspecs)
|
|
@@ -3123,13 +3228,13 @@ def ReadInFileWithContentToList(infile, fmttype="auto", seekstart=0, seekend=0,
|
|
|
3123
3228
|
if(IsNestedDict(formatspecs) and checkcompressfile in formatspecs):
|
|
3124
3229
|
formatspecs = formatspecs[checkcompressfile]
|
|
3125
3230
|
if(checkcompressfile == "tarfile" and TarFileCheck(infile)):
|
|
3126
|
-
return TarFileToArray(infile, seekstart, seekend, listonly, skipchecksum, formatspecs, seektoend,
|
|
3231
|
+
return TarFileToArray(infile, seekstart, seekend, listonly, skipchecksum, formatspecs, seektoend, True)
|
|
3127
3232
|
elif(checkcompressfile == "zipfile" and zipfile.is_zipfile(infile)):
|
|
3128
|
-
return ZipFileToArray(infile, seekstart, seekend, listonly, skipchecksum, formatspecs, seektoend,
|
|
3233
|
+
return ZipFileToArray(infile, seekstart, seekend, listonly, skipchecksum, formatspecs, seektoend, True)
|
|
3129
3234
|
elif(rarfile_support and checkcompressfile == "rarfile" and (rarfile.is_rarfile(infile) or rarfile.is_rarfile_sfx(infile))):
|
|
3130
|
-
return RarFileToArray(infile, seekstart, seekend, listonly, skipchecksum, formatspecs, seektoend,
|
|
3235
|
+
return RarFileToArray(infile, seekstart, seekend, listonly, skipchecksum, formatspecs, seektoend, True)
|
|
3131
3236
|
elif(py7zr_support and checkcompressfile == "7zipfile" and py7zr.is_7zfile(infile)):
|
|
3132
|
-
return SevenZipFileToArray(infile, seekstart, seekend, listonly, skipchecksum, formatspecs, seektoend,
|
|
3237
|
+
return SevenZipFileToArray(infile, seekstart, seekend, listonly, skipchecksum, formatspecs, seektoend, True)
|
|
3133
3238
|
elif(IsSingleDict(formatspecs) and checkcompressfile != formatspecs['format_magic']):
|
|
3134
3239
|
return False
|
|
3135
3240
|
elif(IsNestedDict(formatspecs) and checkcompressfile not in formatspecs):
|
|
@@ -3168,7 +3273,7 @@ def ReadInMultipleFileWithContentToList(infile, fmttype="auto", seekstart=0, see
|
|
|
3168
3273
|
infile = [infile]
|
|
3169
3274
|
outretval = {}
|
|
3170
3275
|
for curfname in infile:
|
|
3171
|
-
curretfile =
|
|
3276
|
+
curretfile[curfname] = ReadInFileWithContentToList(curfname, fmttype, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, formatspecs, seektoend)
|
|
3172
3277
|
return outretval
|
|
3173
3278
|
|
|
3174
3279
|
def ReadInMultipleFilesWithContentToList(infile, fmttype="auto", seekstart=0, seekend=0, listonly=False, contentasfile=True, uncompress=True, skipchecksum=False, formatspecs=__file_format_multi_dict__, seektoend=False):
|
|
@@ -3213,7 +3318,7 @@ def AppendFileHeader(fp, numfiles, fencoding, extradata=[], checksumtype="crc32"
|
|
|
3213
3318
|
tmpoutlist = []
|
|
3214
3319
|
tmpoutlist.append(extrasizelen)
|
|
3215
3320
|
tmpoutlist.append(extrafields)
|
|
3216
|
-
fnumfiles = format(
|
|
3321
|
+
fnumfiles = format(numfiles, 'x').lower()
|
|
3217
3322
|
tmpoutlen = 3 + len(tmpoutlist) + len(extradata) + 2
|
|
3218
3323
|
tmpoutlenhex = format(tmpoutlen, 'x').lower()
|
|
3219
3324
|
fnumfilesa = AppendNullBytes(
|
|
@@ -3271,7 +3376,7 @@ def MakeEmptyCatFilePointer(fp, fmttype=__file_format_default__, checksumtype="c
|
|
|
3271
3376
|
return MakeEmptyFilePointer(fp, fmttype, checksumtype, formatspecs)
|
|
3272
3377
|
|
|
3273
3378
|
|
|
3274
|
-
def MakeEmptyFile(outfile, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, checksumtype="crc32", formatspecs=__file_format_multi_dict__, returnfp=False):
|
|
3379
|
+
def MakeEmptyFile(outfile, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, compressionuselist=compressionlistalt, checksumtype="crc32", formatspecs=__file_format_multi_dict__, returnfp=False):
|
|
3275
3380
|
if(IsNestedDict(formatspecs) and fmttype=="auto" and
|
|
3276
3381
|
(outfile != "-" and outfile is not None and not hasattr(outfile, "read") and not hasattr(outfile, "write"))):
|
|
3277
3382
|
get_in_ext = os.path.splitext(outfile)
|
|
@@ -3298,11 +3403,11 @@ def MakeEmptyFile(outfile, fmttype="auto", compression="auto", compresswholefile
|
|
|
3298
3403
|
pass
|
|
3299
3404
|
if(outfile == "-" or outfile is None):
|
|
3300
3405
|
verbose = False
|
|
3301
|
-
fp =
|
|
3406
|
+
fp = MkTempFile()
|
|
3302
3407
|
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
3303
3408
|
fp = outfile
|
|
3304
3409
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
|
|
3305
|
-
fp =
|
|
3410
|
+
fp = MkTempFile()
|
|
3306
3411
|
else:
|
|
3307
3412
|
fbasename = os.path.splitext(outfile)[0]
|
|
3308
3413
|
fextname = os.path.splitext(outfile)[1]
|
|
@@ -3315,7 +3420,7 @@ def MakeEmptyFile(outfile, fmttype="auto", compression="auto", compresswholefile
|
|
|
3315
3420
|
AppendFileHeader(fp, 0, "UTF-8", [], checksumtype, formatspecs)
|
|
3316
3421
|
if(outfile == "-" or outfile is None or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
3317
3422
|
fp = CompressOpenFileAlt(
|
|
3318
|
-
fp, compression, compressionlevel, formatspecs)
|
|
3423
|
+
fp, compression, compressionlevel, compressionuselist, formatspecs)
|
|
3319
3424
|
try:
|
|
3320
3425
|
fp.flush()
|
|
3321
3426
|
if(hasattr(os, "sync")):
|
|
@@ -3339,7 +3444,7 @@ def MakeEmptyFile(outfile, fmttype="auto", compression="auto", compresswholefile
|
|
|
3339
3444
|
return outvar
|
|
3340
3445
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
|
|
3341
3446
|
fp = CompressOpenFileAlt(
|
|
3342
|
-
fp, compression, compressionlevel, formatspecs)
|
|
3447
|
+
fp, compression, compressionlevel, compressionuselist, formatspecs)
|
|
3343
3448
|
fp.seek(0, 0)
|
|
3344
3449
|
upload_file_to_internet_file(fp, outfile)
|
|
3345
3450
|
if(returnfp):
|
|
@@ -3350,8 +3455,8 @@ def MakeEmptyFile(outfile, fmttype="auto", compression="auto", compresswholefile
|
|
|
3350
3455
|
return True
|
|
3351
3456
|
|
|
3352
3457
|
|
|
3353
|
-
def MakeEmptyCatFile(outfile, compression="auto", compresswholefile=True, compressionlevel=None, checksumtype="crc32", formatspecs=__file_format_dict__, returnfp=False):
|
|
3354
|
-
return MakeEmptyFile(outfile, compression, compresswholefile, compressionlevel, checksumtype, formatspecs, returnfp)
|
|
3458
|
+
def MakeEmptyCatFile(outfile, compression="auto", compresswholefile=True, compressionlevel=None, compressionuselist=compressionlistalt, checksumtype="crc32", formatspecs=__file_format_dict__, returnfp=False):
|
|
3459
|
+
return MakeEmptyFile(outfile, "auto", compression, compresswholefile, compressionlevel, compressionuselist, checksumtype, formatspecs, returnfp)
|
|
3355
3460
|
|
|
3356
3461
|
|
|
3357
3462
|
def AppendFileHeaderWithContent(fp, filevalues=[], extradata=[], jsondata={}, filecontent="", checksumtype=["crc32", "crc32", "crc32"], formatspecs=__file_format_dict__):
|
|
@@ -3450,6 +3555,7 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
|
|
|
3450
3555
|
if(verbose):
|
|
3451
3556
|
logging.basicConfig(format="%(message)s",
|
|
3452
3557
|
stream=sys.stdout, level=logging.DEBUG)
|
|
3558
|
+
infilelist = []
|
|
3453
3559
|
if(infiles == "-"):
|
|
3454
3560
|
for line in sys.stdin:
|
|
3455
3561
|
infilelist.append(line.strip())
|
|
@@ -3490,7 +3596,7 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
|
|
|
3490
3596
|
inodetoforminode = {}
|
|
3491
3597
|
numfiles = int(len(GetDirList))
|
|
3492
3598
|
fnumfiles = format(numfiles, 'x').lower()
|
|
3493
|
-
AppendFileHeader(fp,
|
|
3599
|
+
AppendFileHeader(fp, numfiles, "UTF-8", [], checksumtype[0], formatspecs)
|
|
3494
3600
|
FullSizeFilesAlt = 0
|
|
3495
3601
|
for curfname in GetDirList:
|
|
3496
3602
|
fencoding = "UTF-8"
|
|
@@ -3588,7 +3694,7 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
|
|
|
3588
3694
|
elif ftype in data_types:
|
|
3589
3695
|
fsize = format(int(fstatinfo.st_size), 'x').lower()
|
|
3590
3696
|
else:
|
|
3591
|
-
fsize = format(int(fstatinfo.st_size)).lower()
|
|
3697
|
+
fsize = format(int(fstatinfo.st_size), 'x').lower()
|
|
3592
3698
|
fatime = format(int(fstatinfo.st_atime), 'x').lower()
|
|
3593
3699
|
fmtime = format(int(fstatinfo.st_mtime), 'x').lower()
|
|
3594
3700
|
fctime = format(int(fstatinfo.st_ctime), 'x').lower()
|
|
@@ -3633,7 +3739,7 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
|
|
|
3633
3739
|
fwinattributes = format(int(0), 'x').lower()
|
|
3634
3740
|
fcompression = ""
|
|
3635
3741
|
fcsize = format(int(0), 'x').lower()
|
|
3636
|
-
fcontents =
|
|
3742
|
+
fcontents = MkTempFile()
|
|
3637
3743
|
chunk_size = 1024
|
|
3638
3744
|
fcencoding = "UTF-8"
|
|
3639
3745
|
curcompression = "none"
|
|
@@ -3652,13 +3758,13 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
|
|
|
3652
3758
|
ilmin = 0
|
|
3653
3759
|
ilcsize = []
|
|
3654
3760
|
while(ilmin < ilsize):
|
|
3655
|
-
cfcontents =
|
|
3761
|
+
cfcontents = MkTempFile()
|
|
3656
3762
|
fcontents.seek(0, 0)
|
|
3657
3763
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
3658
3764
|
fcontents.seek(0, 0)
|
|
3659
3765
|
cfcontents.seek(0, 0)
|
|
3660
3766
|
cfcontents = CompressOpenFileAlt(
|
|
3661
|
-
cfcontents, compressionuselist[ilmin], compressionlevel, formatspecs)
|
|
3767
|
+
cfcontents, compressionuselist[ilmin], compressionlevel, compressionuselist, formatspecs)
|
|
3662
3768
|
if(cfcontents):
|
|
3663
3769
|
cfcontents.seek(0, 2)
|
|
3664
3770
|
ilcsize.append(cfcontents.tell())
|
|
@@ -3669,11 +3775,11 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
|
|
|
3669
3775
|
ilcmin = ilcsize.index(min(ilcsize))
|
|
3670
3776
|
curcompression = compressionuselist[ilcmin]
|
|
3671
3777
|
fcontents.seek(0, 0)
|
|
3672
|
-
cfcontents =
|
|
3778
|
+
cfcontents = MkTempFile()
|
|
3673
3779
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
3674
3780
|
cfcontents.seek(0, 0)
|
|
3675
3781
|
cfcontents = CompressOpenFileAlt(
|
|
3676
|
-
cfcontents, curcompression, compressionlevel, formatspecs)
|
|
3782
|
+
cfcontents, curcompression, compressionlevel, compressionuselist, formatspecs)
|
|
3677
3783
|
cfcontents.seek(0, 2)
|
|
3678
3784
|
cfsize = cfcontents.tell()
|
|
3679
3785
|
if(ucfsize > cfsize):
|
|
@@ -3699,13 +3805,13 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
|
|
|
3699
3805
|
ilmin = 0
|
|
3700
3806
|
ilcsize = []
|
|
3701
3807
|
while(ilmin < ilsize):
|
|
3702
|
-
cfcontents =
|
|
3808
|
+
cfcontents = MkTempFile()
|
|
3703
3809
|
fcontents.seek(0, 0)
|
|
3704
3810
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
3705
3811
|
fcontents.seek(0, 0)
|
|
3706
3812
|
cfcontents.seek(0, 0)
|
|
3707
3813
|
cfcontents = CompressOpenFileAlt(
|
|
3708
|
-
cfcontents, compressionuselist[ilmin], compressionlevel, formatspecs)
|
|
3814
|
+
cfcontents, compressionuselist[ilmin], compressionlevel, compressionuselist, formatspecs)
|
|
3709
3815
|
if(cfcontents):
|
|
3710
3816
|
cfcontents.seek(0, 2)
|
|
3711
3817
|
ilcsize.append(cfcontents.tell())
|
|
@@ -3716,11 +3822,11 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
|
|
|
3716
3822
|
ilcmin = ilcsize.index(min(ilcsize))
|
|
3717
3823
|
curcompression = compressionuselist[ilcmin]
|
|
3718
3824
|
fcontents.seek(0, 0)
|
|
3719
|
-
cfcontents =
|
|
3825
|
+
cfcontents = MkTempFile()
|
|
3720
3826
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
3721
3827
|
cfcontents.seek(0, 0)
|
|
3722
3828
|
cfcontents = CompressOpenFileAlt(
|
|
3723
|
-
cfcontents, curcompression, compressionlevel, formatspecs)
|
|
3829
|
+
cfcontents, curcompression, compressionlevel, compressionuselist, formatspecs)
|
|
3724
3830
|
cfcontents.seek(0, 2)
|
|
3725
3831
|
cfsize = cfcontents.tell()
|
|
3726
3832
|
if(ucfsize > cfsize):
|
|
@@ -3762,7 +3868,7 @@ def AppendListsWithContent(inlist, fp, dirlistfromtxt=False, filevalues=[], extr
|
|
|
3762
3868
|
inodetoforminode = {}
|
|
3763
3869
|
numfiles = int(len(GetDirList))
|
|
3764
3870
|
fnumfiles = format(numfiles, 'x').lower()
|
|
3765
|
-
AppendFileHeader(fp,
|
|
3871
|
+
AppendFileHeader(fp, numfiles, "UTF-8", [], checksumtype[0], formatspecs)
|
|
3766
3872
|
for curfname in GetDirList:
|
|
3767
3873
|
ftype = format(curfname[0], 'x').lower()
|
|
3768
3874
|
fencoding = curfname[1]
|
|
@@ -3846,11 +3952,11 @@ def AppendFilesWithContentToOutFile(infiles, outfile, dirlistfromtxt=False, fmtt
|
|
|
3846
3952
|
pass
|
|
3847
3953
|
if(outfile == "-" or outfile is None):
|
|
3848
3954
|
verbose = False
|
|
3849
|
-
fp =
|
|
3955
|
+
fp = MkTempFile()
|
|
3850
3956
|
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
3851
3957
|
fp = outfile
|
|
3852
3958
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
|
|
3853
|
-
fp =
|
|
3959
|
+
fp = MkTempFile()
|
|
3854
3960
|
else:
|
|
3855
3961
|
fbasename = os.path.splitext(outfile)[0]
|
|
3856
3962
|
fextname = os.path.splitext(outfile)[1]
|
|
@@ -3864,7 +3970,7 @@ def AppendFilesWithContentToOutFile(infiles, outfile, dirlistfromtxt=False, fmtt
|
|
|
3864
3970
|
compresswholefile, compressionlevel, compressionuselist, followlink, checksumtype, formatspecs, verbose)
|
|
3865
3971
|
if(outfile == "-" or outfile is None or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
3866
3972
|
fp = CompressOpenFileAlt(
|
|
3867
|
-
fp, compression, compressionlevel, formatspecs)
|
|
3973
|
+
fp, compression, compressionlevel, compressionuselist, formatspecs)
|
|
3868
3974
|
try:
|
|
3869
3975
|
fp.flush()
|
|
3870
3976
|
if(hasattr(os, "sync")):
|
|
@@ -3888,7 +3994,7 @@ def AppendFilesWithContentToOutFile(infiles, outfile, dirlistfromtxt=False, fmtt
|
|
|
3888
3994
|
return outvar
|
|
3889
3995
|
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
|
|
3890
3996
|
fp = CompressOpenFileAlt(
|
|
3891
|
-
fp, compression, compressionlevel, formatspecs)
|
|
3997
|
+
fp, compression, compressionlevel, compressionuselist, formatspecs)
|
|
3892
3998
|
fp.seek(0, 0)
|
|
3893
3999
|
upload_file_to_internet_file(fp, outfile)
|
|
3894
4000
|
if(returnfp):
|
|
@@ -3926,11 +4032,11 @@ def AppendListsWithContentToOutFile(inlist, outfile, dirlistfromtxt=False, fmtty
|
|
|
3926
4032
|
pass
|
|
3927
4033
|
if(outfile == "-" or outfile is None):
|
|
3928
4034
|
verbose = False
|
|
3929
|
-
fp =
|
|
4035
|
+
fp = MkTempFile()
|
|
3930
4036
|
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
3931
4037
|
fp = outfile
|
|
3932
4038
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
|
|
3933
|
-
fp =
|
|
4039
|
+
fp = MkTempFile()
|
|
3934
4040
|
else:
|
|
3935
4041
|
fbasename = os.path.splitext(outfile)[0]
|
|
3936
4042
|
fextname = os.path.splitext(outfile)[1]
|
|
@@ -3944,7 +4050,7 @@ def AppendListsWithContentToOutFile(inlist, outfile, dirlistfromtxt=False, fmtty
|
|
|
3944
4050
|
compresswholefile, compressionlevel, followlink, checksumtype, formatspecs, verbose)
|
|
3945
4051
|
if(outfile == "-" or outfile is None or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
3946
4052
|
fp = CompressOpenFileAlt(
|
|
3947
|
-
fp, compression, compressionlevel, formatspecs)
|
|
4053
|
+
fp, compression, compressionlevel, compressionuselist, formatspecs)
|
|
3948
4054
|
try:
|
|
3949
4055
|
fp.flush()
|
|
3950
4056
|
if(hasattr(os, "sync")):
|
|
@@ -3968,7 +4074,7 @@ def AppendListsWithContentToOutFile(inlist, outfile, dirlistfromtxt=False, fmtty
|
|
|
3968
4074
|
return outvar
|
|
3969
4075
|
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
|
|
3970
4076
|
fp = CompressOpenFileAlt(
|
|
3971
|
-
fp, compression, compressionlevel, formatspecs)
|
|
4077
|
+
fp, compression, compressionlevel, compressionuselist, formatspecs)
|
|
3972
4078
|
fp.seek(0, 0)
|
|
3973
4079
|
upload_file_to_internet_file(fp, outfile)
|
|
3974
4080
|
if(returnfp):
|
|
@@ -4047,7 +4153,7 @@ def GzipCompressData(data, compresslevel=9):
|
|
|
4047
4153
|
compressed_data = gzip.compress(data, compresslevel=compresslevel)
|
|
4048
4154
|
except AttributeError:
|
|
4049
4155
|
# Fallback to older method for Python 2.x and older 3.x versions
|
|
4050
|
-
out =
|
|
4156
|
+
out = MkTempFile()
|
|
4051
4157
|
with gzip.GzipFile(fileobj=out, mode="wb", compresslevel=compresslevel) as f:
|
|
4052
4158
|
f.write(data)
|
|
4053
4159
|
compressed_data = out.getvalue()
|
|
@@ -4060,7 +4166,7 @@ def GzipDecompressData(compressed_data):
|
|
|
4060
4166
|
decompressed_data = gzip.decompress(compressed_data)
|
|
4061
4167
|
except AttributeError:
|
|
4062
4168
|
# Fallback to older method for Python 2.x and older 3.x versions
|
|
4063
|
-
inp =
|
|
4169
|
+
inp = MkTempFile(compressed_data)
|
|
4064
4170
|
with gzip.GzipFile(fileobj=inp, mode="rb") as f:
|
|
4065
4171
|
decompressed_data = f.read()
|
|
4066
4172
|
return decompressed_data
|
|
@@ -4193,9 +4299,9 @@ def GetFileEncoding(infile, closefp=True):
|
|
|
4193
4299
|
|
|
4194
4300
|
def GetFileEncodingFromString(instring, closefp=True):
|
|
4195
4301
|
try:
|
|
4196
|
-
instringsfile =
|
|
4302
|
+
instringsfile = MkTempFile(instring)
|
|
4197
4303
|
except TypeError:
|
|
4198
|
-
instringsfile =
|
|
4304
|
+
instringsfile = MkTempFile(instring.encode("UTF-8"))
|
|
4199
4305
|
return GetFileEncoding(instringsfile, closefp)
|
|
4200
4306
|
|
|
4201
4307
|
|
|
@@ -4458,17 +4564,17 @@ def CheckCompressionSubType(infile, formatspecs=__file_format_multi_dict__, clos
|
|
|
4458
4564
|
|
|
4459
4565
|
def CheckCompressionTypeFromString(instring, formatspecs=__file_format_multi_dict__, closefp=True):
|
|
4460
4566
|
try:
|
|
4461
|
-
instringsfile =
|
|
4567
|
+
instringsfile = MkTempFile(instring)
|
|
4462
4568
|
except TypeError:
|
|
4463
|
-
instringsfile =
|
|
4569
|
+
instringsfile = MkTempFile(instring.encode("UTF-8"))
|
|
4464
4570
|
return CheckCompressionType(instringsfile, formatspecs, closefp)
|
|
4465
4571
|
|
|
4466
4572
|
|
|
4467
4573
|
def CheckCompressionTypeFromBytes(instring, formatspecs=__file_format_multi_dict__, closefp=True):
|
|
4468
4574
|
try:
|
|
4469
|
-
instringsfile =
|
|
4575
|
+
instringsfile = MkTempFile(instring)
|
|
4470
4576
|
except TypeError:
|
|
4471
|
-
instringsfile =
|
|
4577
|
+
instringsfile = MkTempFile(instring.decode("UTF-8"))
|
|
4472
4578
|
return CheckCompressionType(instringsfile, formatspecs, closefp)
|
|
4473
4579
|
|
|
4474
4580
|
|
|
@@ -4635,7 +4741,7 @@ def UncompressBytes(infile, formatspecs=__file_format_multi_dict__):
|
|
|
4635
4741
|
|
|
4636
4742
|
|
|
4637
4743
|
def UncompressBytesAlt(inbytes, formatspecs=__file_format_multi_dict__):
|
|
4638
|
-
filefp =
|
|
4744
|
+
filefp = MkTempFile()
|
|
4639
4745
|
outstring = UncompressBytes(inbytes, formatspecs)
|
|
4640
4746
|
filefp.write(outstring)
|
|
4641
4747
|
filefp.seek(0, 0)
|
|
@@ -4651,7 +4757,7 @@ def UncompressBytesAltFP(fp, formatspecs=__file_format_multi_dict__):
|
|
|
4651
4757
|
fp.seek(0, 0)
|
|
4652
4758
|
if(prechck!="zstd"):
|
|
4653
4759
|
return UncompressFileAlt(fp, formatspecs)
|
|
4654
|
-
filefp =
|
|
4760
|
+
filefp = MkTempFile()
|
|
4655
4761
|
fp.seek(0, 0)
|
|
4656
4762
|
outstring = UncompressBytes(fp.read(), formatspecs)
|
|
4657
4763
|
filefp.write(outstring)
|
|
@@ -4659,16 +4765,16 @@ def UncompressBytesAltFP(fp, formatspecs=__file_format_multi_dict__):
|
|
|
4659
4765
|
return filefp
|
|
4660
4766
|
|
|
4661
4767
|
|
|
4662
|
-
def CompressOpenFileAlt(fp, compression="auto", compressionlevel=None, formatspecs=__file_format_dict__):
|
|
4768
|
+
def CompressOpenFileAlt(fp, compression="auto", compressionlevel=None, compressionuselist=compressionlistalt, formatspecs=__file_format_dict__):
|
|
4663
4769
|
if(not hasattr(fp, "read")):
|
|
4664
4770
|
return False
|
|
4665
4771
|
fp.seek(0, 0)
|
|
4666
4772
|
if(not compression or compression == formatspecs['format_magic']):
|
|
4667
4773
|
compression = "auto"
|
|
4668
|
-
if(compression not in
|
|
4774
|
+
if(compression not in compressionuselist and compression is None):
|
|
4669
4775
|
compression = "auto"
|
|
4670
4776
|
if(compression == "gzip" and compression in compressionsupport):
|
|
4671
|
-
bytesfp =
|
|
4777
|
+
bytesfp = MkTempFile()
|
|
4672
4778
|
if(compressionlevel is None):
|
|
4673
4779
|
compressionlevel = 9
|
|
4674
4780
|
else:
|
|
@@ -4676,7 +4782,7 @@ def CompressOpenFileAlt(fp, compression="auto", compressionlevel=None, formatspe
|
|
|
4676
4782
|
bytesfp.write(GzipCompressData(
|
|
4677
4783
|
fp.read(), compresslevel=compressionlevel))
|
|
4678
4784
|
elif(compression == "bzip2" and compression in compressionsupport):
|
|
4679
|
-
bytesfp =
|
|
4785
|
+
bytesfp = MkTempFile()
|
|
4680
4786
|
if(compressionlevel is None):
|
|
4681
4787
|
compressionlevel = 9
|
|
4682
4788
|
else:
|
|
@@ -4684,7 +4790,7 @@ def CompressOpenFileAlt(fp, compression="auto", compressionlevel=None, formatspe
|
|
|
4684
4790
|
bytesfp.write(BzipCompressData(
|
|
4685
4791
|
fp.read(), compresslevel=compressionlevel))
|
|
4686
4792
|
elif(compression == "lz4" and compression in compressionsupport):
|
|
4687
|
-
bytesfp =
|
|
4793
|
+
bytesfp = MkTempFile()
|
|
4688
4794
|
if(compressionlevel is None):
|
|
4689
4795
|
compressionlevel = 9
|
|
4690
4796
|
else:
|
|
@@ -4692,14 +4798,14 @@ def CompressOpenFileAlt(fp, compression="auto", compressionlevel=None, formatspe
|
|
|
4692
4798
|
bytesfp.write(lz4.frame.compress(
|
|
4693
4799
|
fp.read(), compression_level=compressionlevel))
|
|
4694
4800
|
elif((compression == "lzo" or compression == "lzop") and compression in compressionsupport):
|
|
4695
|
-
bytesfp =
|
|
4801
|
+
bytesfp = MkTempFile()
|
|
4696
4802
|
if(compressionlevel is None):
|
|
4697
4803
|
compressionlevel = 9
|
|
4698
4804
|
else:
|
|
4699
4805
|
compressionlevel = int(compressionlevel)
|
|
4700
4806
|
bytesfp.write(lzo.compress(fp.read(), compressionlevel))
|
|
4701
4807
|
elif(compression == "zstd" and compression in compressionsupport):
|
|
4702
|
-
bytesfp =
|
|
4808
|
+
bytesfp = MkTempFile()
|
|
4703
4809
|
if(compressionlevel is None):
|
|
4704
4810
|
compressionlevel = 9
|
|
4705
4811
|
else:
|
|
@@ -4707,7 +4813,7 @@ def CompressOpenFileAlt(fp, compression="auto", compressionlevel=None, formatspe
|
|
|
4707
4813
|
compressor = zstandard.ZstdCompressor(compressionlevel, threads=get_default_threads())
|
|
4708
4814
|
bytesfp.write(compressor.compress(fp.read()))
|
|
4709
4815
|
elif(compression == "lzma" and compression in compressionsupport):
|
|
4710
|
-
bytesfp =
|
|
4816
|
+
bytesfp = MkTempFile()
|
|
4711
4817
|
if(compressionlevel is None):
|
|
4712
4818
|
compressionlevel = 9
|
|
4713
4819
|
else:
|
|
@@ -4717,7 +4823,7 @@ def CompressOpenFileAlt(fp, compression="auto", compressionlevel=None, formatspe
|
|
|
4717
4823
|
except (NotImplementedError, lzma.LZMAError):
|
|
4718
4824
|
bytesfp.write(lzma.compress(fp.read(), format=lzma.FORMAT_ALONE))
|
|
4719
4825
|
elif(compression == "xz" and compression in compressionsupport):
|
|
4720
|
-
bytesfp =
|
|
4826
|
+
bytesfp = MkTempFile()
|
|
4721
4827
|
if(compressionlevel is None):
|
|
4722
4828
|
compressionlevel = 9
|
|
4723
4829
|
else:
|
|
@@ -4727,7 +4833,7 @@ def CompressOpenFileAlt(fp, compression="auto", compressionlevel=None, formatspe
|
|
|
4727
4833
|
except (NotImplementedError, lzma.LZMAError):
|
|
4728
4834
|
bytesfp.write(lzma.compress(fp.read(), format=lzma.FORMAT_XZ))
|
|
4729
4835
|
elif(compression == "zlib" and compression in compressionsupport):
|
|
4730
|
-
bytesfp =
|
|
4836
|
+
bytesfp = MkTempFile()
|
|
4731
4837
|
if(compressionlevel is None):
|
|
4732
4838
|
compressionlevel = 9
|
|
4733
4839
|
else:
|
|
@@ -4884,7 +4990,7 @@ def PackCatFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", compress
|
|
|
4884
4990
|
outfile = RemoveWindowsPath(outfile)
|
|
4885
4991
|
if(not compression or compression == formatspecs['format_magic']):
|
|
4886
4992
|
compression = "auto"
|
|
4887
|
-
if(compression not in
|
|
4993
|
+
if(compression not in compressionuselist and compression is None):
|
|
4888
4994
|
compression = "auto"
|
|
4889
4995
|
if(verbose):
|
|
4890
4996
|
logging.basicConfig(format="%(message)s",
|
|
@@ -4897,11 +5003,11 @@ def PackCatFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", compress
|
|
|
4897
5003
|
pass
|
|
4898
5004
|
if(outfile == "-" or outfile is None):
|
|
4899
5005
|
verbose = False
|
|
4900
|
-
fp =
|
|
5006
|
+
fp = MkTempFile()
|
|
4901
5007
|
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
4902
5008
|
fp = outfile
|
|
4903
5009
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
|
|
4904
|
-
fp =
|
|
5010
|
+
fp = MkTempFile()
|
|
4905
5011
|
else:
|
|
4906
5012
|
fbasename = os.path.splitext(outfile)[0]
|
|
4907
5013
|
fextname = os.path.splitext(outfile)[1]
|
|
@@ -5051,7 +5157,7 @@ def PackCatFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", compress
|
|
|
5051
5157
|
elif ftype in data_types:
|
|
5052
5158
|
fsize = format(int(fstatinfo.st_size), 'x').lower()
|
|
5053
5159
|
else:
|
|
5054
|
-
fsize = format(int(fstatinfo.st_size)).lower()
|
|
5160
|
+
fsize = format(int(fstatinfo.st_size), 'x').lower()
|
|
5055
5161
|
fatime = format(int(fstatinfo.st_atime), 'x').lower()
|
|
5056
5162
|
fmtime = format(int(fstatinfo.st_mtime), 'x').lower()
|
|
5057
5163
|
fctime = format(int(fstatinfo.st_ctime), 'x').lower()
|
|
@@ -5096,7 +5202,7 @@ def PackCatFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", compress
|
|
|
5096
5202
|
fwinattributes = format(int(0), 'x').lower()
|
|
5097
5203
|
fcompression = ""
|
|
5098
5204
|
fcsize = format(int(0), 'x').lower()
|
|
5099
|
-
fcontents =
|
|
5205
|
+
fcontents = MkTempFile()
|
|
5100
5206
|
fcencoding = "UTF-8"
|
|
5101
5207
|
curcompression = "none"
|
|
5102
5208
|
if not followlink and ftype in data_types:
|
|
@@ -5114,13 +5220,13 @@ def PackCatFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", compress
|
|
|
5114
5220
|
ilmin = 0
|
|
5115
5221
|
ilcsize = []
|
|
5116
5222
|
while(ilmin < ilsize):
|
|
5117
|
-
cfcontents =
|
|
5223
|
+
cfcontents = MkTempFile()
|
|
5118
5224
|
fcontents.seek(0, 0)
|
|
5119
5225
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
5120
5226
|
fcontents.seek(0, 0)
|
|
5121
5227
|
cfcontents.seek(0, 0)
|
|
5122
5228
|
cfcontents = CompressOpenFileAlt(
|
|
5123
|
-
cfcontents, compressionuselist[ilmin], compressionlevel, formatspecs)
|
|
5229
|
+
cfcontents, compressionuselist[ilmin], compressionlevel, compressionuselist, formatspecs)
|
|
5124
5230
|
if(cfcontents):
|
|
5125
5231
|
cfcontents.seek(0, 2)
|
|
5126
5232
|
ilcsize.append(cfcontents.tell())
|
|
@@ -5131,11 +5237,11 @@ def PackCatFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", compress
|
|
|
5131
5237
|
ilcmin = ilcsize.index(min(ilcsize))
|
|
5132
5238
|
curcompression = compressionuselist[ilcmin]
|
|
5133
5239
|
fcontents.seek(0, 0)
|
|
5134
|
-
cfcontents =
|
|
5240
|
+
cfcontents = MkTempFile()
|
|
5135
5241
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
5136
5242
|
cfcontents.seek(0, 0)
|
|
5137
5243
|
cfcontents = CompressOpenFileAlt(
|
|
5138
|
-
cfcontents, curcompression, compressionlevel, formatspecs)
|
|
5244
|
+
cfcontents, curcompression, compressionlevel, compressionuselist, formatspecs)
|
|
5139
5245
|
cfcontents.seek(0, 2)
|
|
5140
5246
|
cfsize = cfcontents.tell()
|
|
5141
5247
|
if(ucfsize > cfsize):
|
|
@@ -5161,13 +5267,13 @@ def PackCatFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", compress
|
|
|
5161
5267
|
ilmin = 0
|
|
5162
5268
|
ilcsize = []
|
|
5163
5269
|
while(ilmin < ilsize):
|
|
5164
|
-
cfcontents =
|
|
5270
|
+
cfcontents = MkTempFile()
|
|
5165
5271
|
fcontents.seek(0, 0)
|
|
5166
5272
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
5167
5273
|
fcontents.seek(0, 0)
|
|
5168
5274
|
cfcontents.seek(0, 0)
|
|
5169
5275
|
cfcontents = CompressOpenFileAlt(
|
|
5170
|
-
cfcontents, compressionuselist[ilmin], compressionlevel, formatspecs)
|
|
5276
|
+
cfcontents, compressionuselist[ilmin], compressionlevel, compressionuselist, formatspecs)
|
|
5171
5277
|
if(cfcontents):
|
|
5172
5278
|
cfcontents.seek(0, 2)
|
|
5173
5279
|
ilcsize.append(cfcontents.tell())
|
|
@@ -5178,11 +5284,11 @@ def PackCatFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", compress
|
|
|
5178
5284
|
ilcmin = ilcsize.index(min(ilcsize))
|
|
5179
5285
|
curcompression = compressionuselist[ilcmin]
|
|
5180
5286
|
fcontents.seek(0, 0)
|
|
5181
|
-
cfcontents =
|
|
5287
|
+
cfcontents = MkTempFile()
|
|
5182
5288
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
5183
5289
|
cfcontents.seek(0, 0)
|
|
5184
5290
|
cfcontents = CompressOpenFileAlt(
|
|
5185
|
-
cfcontents, curcompression, compressionlevel, formatspecs)
|
|
5291
|
+
cfcontents, curcompression, compressionlevel, compressionuselist, formatspecs)
|
|
5186
5292
|
cfcontents.seek(0, 2)
|
|
5187
5293
|
cfsize = cfcontents.tell()
|
|
5188
5294
|
if(ucfsize > cfsize):
|
|
@@ -5207,7 +5313,7 @@ def PackCatFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", compress
|
|
|
5207
5313
|
return False
|
|
5208
5314
|
if(outfile == "-" or outfile is None or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
5209
5315
|
fp = CompressOpenFileAlt(
|
|
5210
|
-
fp, compression, compressionlevel, formatspecs)
|
|
5316
|
+
fp, compression, compressionlevel, compressionuselist, formatspecs)
|
|
5211
5317
|
try:
|
|
5212
5318
|
fp.flush()
|
|
5213
5319
|
if(hasattr(os, "sync")):
|
|
@@ -5231,7 +5337,7 @@ def PackCatFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", compress
|
|
|
5231
5337
|
return outvar
|
|
5232
5338
|
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
|
|
5233
5339
|
fp = CompressOpenFileAlt(
|
|
5234
|
-
fp, compression, compressionlevel, formatspecs)
|
|
5340
|
+
fp, compression, compressionlevel, compressionuselist, formatspecs)
|
|
5235
5341
|
fp.seek(0, 0)
|
|
5236
5342
|
upload_file_to_internet_file(fp, outfile)
|
|
5237
5343
|
if(returnfp):
|
|
@@ -5269,7 +5375,7 @@ def PackCatFileFromTarFile(infile, outfile, fmttype="auto", compression="auto",
|
|
|
5269
5375
|
outfile = RemoveWindowsPath(outfile)
|
|
5270
5376
|
if(not compression or compression == formatspecs['format_magic']):
|
|
5271
5377
|
compression = "auto"
|
|
5272
|
-
if(compression not in
|
|
5378
|
+
if(compression not in compressionuselist and compression is None):
|
|
5273
5379
|
compression = "auto"
|
|
5274
5380
|
if(verbose):
|
|
5275
5381
|
logging.basicConfig(format="%(message)s", stream=sys.stdout, level=logging.DEBUG)
|
|
@@ -5281,11 +5387,11 @@ def PackCatFileFromTarFile(infile, outfile, fmttype="auto", compression="auto",
|
|
|
5281
5387
|
pass
|
|
5282
5388
|
if(outfile == "-" or outfile is None):
|
|
5283
5389
|
verbose = False
|
|
5284
|
-
fp =
|
|
5390
|
+
fp = MkTempFile()
|
|
5285
5391
|
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
5286
5392
|
fp = outfile
|
|
5287
5393
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
|
|
5288
|
-
fp =
|
|
5394
|
+
fp = MkTempFile()
|
|
5289
5395
|
else:
|
|
5290
5396
|
fbasename = os.path.splitext(outfile)[0]
|
|
5291
5397
|
fextname = os.path.splitext(outfile)[1]
|
|
@@ -5304,7 +5410,7 @@ def PackCatFileFromTarFile(infile, outfile, fmttype="auto", compression="auto",
|
|
|
5304
5410
|
filetoinode = {}
|
|
5305
5411
|
inodetoforminode = {}
|
|
5306
5412
|
if(infile == "-"):
|
|
5307
|
-
infile =
|
|
5413
|
+
infile = MkTempFile()
|
|
5308
5414
|
if(hasattr(sys.stdin, "buffer")):
|
|
5309
5415
|
shutil.copyfileobj(sys.stdin.buffer, infile)
|
|
5310
5416
|
else:
|
|
@@ -5344,7 +5450,7 @@ def PackCatFileFromTarFile(infile, outfile, fmttype="auto", compression="auto",
|
|
|
5344
5450
|
if 'zstandard' in sys.modules:
|
|
5345
5451
|
infile = ZstdFile(fileobj=infile, mode="rb")
|
|
5346
5452
|
elif 'pyzstd' in sys.modules:
|
|
5347
|
-
|
|
5453
|
+
infile = pyzstd.zstdfile.ZstdFile(fileobj=infile, mode="rb")
|
|
5348
5454
|
tarfp = tarfile.open(fileobj=infile, mode="r")
|
|
5349
5455
|
else:
|
|
5350
5456
|
tarfp = tarfile.open(fileobj=infile, mode="r")
|
|
@@ -5356,7 +5462,7 @@ def PackCatFileFromTarFile(infile, outfile, fmttype="auto", compression="auto",
|
|
|
5356
5462
|
if 'zstandard' in sys.modules:
|
|
5357
5463
|
infile = ZstdFile(fileobj=infile, mode="rb")
|
|
5358
5464
|
elif 'pyzstd' in sys.modules:
|
|
5359
|
-
|
|
5465
|
+
infile = pyzstd.zstdfile.ZstdFile(fileobj=infile, mode="rb")
|
|
5360
5466
|
tarfp = tarfile.open(fileobj=infile, mode="r")
|
|
5361
5467
|
else:
|
|
5362
5468
|
tarfp = tarfile.open(infile, "r")
|
|
@@ -5443,12 +5549,13 @@ def PackCatFileFromTarFile(infile, outfile, fmttype="auto", compression="auto",
|
|
|
5443
5549
|
fwinattributes = format(int(0), 'x').lower()
|
|
5444
5550
|
fcompression = ""
|
|
5445
5551
|
fcsize = format(int(0), 'x').lower()
|
|
5446
|
-
fcontents =
|
|
5552
|
+
fcontents = MkTempFile()
|
|
5447
5553
|
fcencoding = "UTF-8"
|
|
5448
5554
|
curcompression = "none"
|
|
5449
5555
|
if ftype in data_types:
|
|
5450
5556
|
fpc = tarfp.extractfile(member)
|
|
5451
5557
|
shutil.copyfileobj(fpc, fcontents)
|
|
5558
|
+
fpc.close()
|
|
5452
5559
|
typechecktest = CheckCompressionType(fcontents, closefp=False)
|
|
5453
5560
|
fcontents.seek(0, 0)
|
|
5454
5561
|
fcencoding = GetFileEncoding(fcontents, False)
|
|
@@ -5461,13 +5568,13 @@ def PackCatFileFromTarFile(infile, outfile, fmttype="auto", compression="auto",
|
|
|
5461
5568
|
ilmin = 0
|
|
5462
5569
|
ilcsize = []
|
|
5463
5570
|
while(ilmin < ilsize):
|
|
5464
|
-
cfcontents =
|
|
5571
|
+
cfcontents = MkTempFile()
|
|
5465
5572
|
fcontents.seek(0, 0)
|
|
5466
5573
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
5467
5574
|
fcontents.seek(0, 0)
|
|
5468
5575
|
cfcontents.seek(0, 0)
|
|
5469
5576
|
cfcontents = CompressOpenFileAlt(
|
|
5470
|
-
cfcontents, compressionuselist[ilmin], compressionlevel, formatspecs)
|
|
5577
|
+
cfcontents, compressionuselist[ilmin], compressionlevel, compressionuselist, formatspecs)
|
|
5471
5578
|
if(cfcontents):
|
|
5472
5579
|
cfcontents.seek(0, 2)
|
|
5473
5580
|
ilcsize.append(cfcontents.tell())
|
|
@@ -5478,11 +5585,11 @@ def PackCatFileFromTarFile(infile, outfile, fmttype="auto", compression="auto",
|
|
|
5478
5585
|
ilcmin = ilcsize.index(min(ilcsize))
|
|
5479
5586
|
curcompression = compressionuselist[ilcmin]
|
|
5480
5587
|
fcontents.seek(0, 0)
|
|
5481
|
-
cfcontents =
|
|
5588
|
+
cfcontents = MkTempFile()
|
|
5482
5589
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
5483
5590
|
cfcontents.seek(0, 0)
|
|
5484
5591
|
cfcontents = CompressOpenFileAlt(
|
|
5485
|
-
cfcontents, curcompression, compressionlevel, formatspecs)
|
|
5592
|
+
cfcontents, curcompression, compressionlevel, compressionuselist, formatspecs)
|
|
5486
5593
|
cfcontents.seek(0, 2)
|
|
5487
5594
|
cfsize = cfcontents.tell()
|
|
5488
5595
|
if(ucfsize > cfsize):
|
|
@@ -5507,7 +5614,7 @@ def PackCatFileFromTarFile(infile, outfile, fmttype="auto", compression="auto",
|
|
|
5507
5614
|
return False
|
|
5508
5615
|
if(outfile == "-" or outfile is None or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
5509
5616
|
fp = CompressOpenFileAlt(
|
|
5510
|
-
fp, compression, compressionlevel, formatspecs)
|
|
5617
|
+
fp, compression, compressionlevel, compressionuselist, formatspecs)
|
|
5511
5618
|
try:
|
|
5512
5619
|
fp.flush()
|
|
5513
5620
|
if(hasattr(os, "sync")):
|
|
@@ -5531,7 +5638,7 @@ def PackCatFileFromTarFile(infile, outfile, fmttype="auto", compression="auto",
|
|
|
5531
5638
|
return outvar
|
|
5532
5639
|
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
|
|
5533
5640
|
fp = CompressOpenFileAlt(
|
|
5534
|
-
fp, compression, compressionlevel, formatspecs)
|
|
5641
|
+
fp, compression, compressionlevel, compressionuselist, formatspecs)
|
|
5535
5642
|
fp.seek(0, 0)
|
|
5536
5643
|
upload_file_to_internet_file(fp, outfile)
|
|
5537
5644
|
if(returnfp):
|
|
@@ -5565,7 +5672,7 @@ def PackCatFileFromZipFile(infile, outfile, fmttype="auto", compression="auto",
|
|
|
5565
5672
|
outfile = RemoveWindowsPath(outfile)
|
|
5566
5673
|
if(not compression or compression == formatspecs['format_magic']):
|
|
5567
5674
|
compression = "auto"
|
|
5568
|
-
if(compression not in
|
|
5675
|
+
if(compression not in compressionuselist and compression is None):
|
|
5569
5676
|
compression = "auto"
|
|
5570
5677
|
if(verbose):
|
|
5571
5678
|
logging.basicConfig(format="%(message)s", stream=sys.stdout, level=logging.DEBUG)
|
|
@@ -5577,11 +5684,11 @@ def PackCatFileFromZipFile(infile, outfile, fmttype="auto", compression="auto",
|
|
|
5577
5684
|
pass
|
|
5578
5685
|
if(outfile == "-" or outfile is None):
|
|
5579
5686
|
verbose = False
|
|
5580
|
-
fp =
|
|
5687
|
+
fp = MkTempFile()
|
|
5581
5688
|
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
5582
5689
|
fp = outfile
|
|
5583
5690
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
|
|
5584
|
-
fp =
|
|
5691
|
+
fp = MkTempFile()
|
|
5585
5692
|
else:
|
|
5586
5693
|
fbasename = os.path.splitext(outfile)[0]
|
|
5587
5694
|
fextname = os.path.splitext(outfile)[1]
|
|
@@ -5600,7 +5707,7 @@ def PackCatFileFromZipFile(infile, outfile, fmttype="auto", compression="auto",
|
|
|
5600
5707
|
filetoinode = {}
|
|
5601
5708
|
inodetoforminode = {}
|
|
5602
5709
|
if(infile == "-"):
|
|
5603
|
-
infile =
|
|
5710
|
+
infile = MkTempFile()
|
|
5604
5711
|
if(hasattr(sys.stdin, "buffer")):
|
|
5605
5712
|
shutil.copyfileobj(sys.stdin.buffer, infile)
|
|
5606
5713
|
else:
|
|
@@ -5741,7 +5848,7 @@ def PackCatFileFromZipFile(infile, outfile, fmttype="auto", compression="auto",
|
|
|
5741
5848
|
fgname = ""
|
|
5742
5849
|
except ImportError:
|
|
5743
5850
|
fgname = ""
|
|
5744
|
-
fcontents =
|
|
5851
|
+
fcontents = MkTempFile()
|
|
5745
5852
|
fcencoding = "UTF-8"
|
|
5746
5853
|
curcompression = "none"
|
|
5747
5854
|
if ftype == 0:
|
|
@@ -5758,13 +5865,13 @@ def PackCatFileFromZipFile(infile, outfile, fmttype="auto", compression="auto",
|
|
|
5758
5865
|
ilmin = 0
|
|
5759
5866
|
ilcsize = []
|
|
5760
5867
|
while(ilmin < ilsize):
|
|
5761
|
-
cfcontents =
|
|
5868
|
+
cfcontents = MkTempFile()
|
|
5762
5869
|
fcontents.seek(0, 0)
|
|
5763
5870
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
5764
5871
|
fcontents.seek(0, 0)
|
|
5765
5872
|
cfcontents.seek(0, 0)
|
|
5766
5873
|
cfcontents = CompressOpenFileAlt(
|
|
5767
|
-
cfcontents, compressionuselist[ilmin], compressionlevel, formatspecs)
|
|
5874
|
+
cfcontents, compressionuselist[ilmin], compressionlevel, compressionuselist, formatspecs)
|
|
5768
5875
|
cfcontents.seek(0, 2)
|
|
5769
5876
|
ilcsize.append(cfcontents.tell())
|
|
5770
5877
|
cfcontents.close()
|
|
@@ -5772,11 +5879,11 @@ def PackCatFileFromZipFile(infile, outfile, fmttype="auto", compression="auto",
|
|
|
5772
5879
|
ilcmin = ilcsize.index(min(ilcsize))
|
|
5773
5880
|
curcompression = compressionuselist[ilcmin]
|
|
5774
5881
|
fcontents.seek(0, 0)
|
|
5775
|
-
cfcontents =
|
|
5882
|
+
cfcontents = MkTempFile()
|
|
5776
5883
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
5777
5884
|
cfcontents.seek(0, 0)
|
|
5778
5885
|
cfcontents = CompressOpenFileAlt(
|
|
5779
|
-
cfcontents, curcompression, compressionlevel, formatspecs)
|
|
5886
|
+
cfcontents, curcompression, compressionlevel, compressionuselist, formatspecs)
|
|
5780
5887
|
cfcontents.seek(0, 2)
|
|
5781
5888
|
cfsize = cfcontents.tell()
|
|
5782
5889
|
if(ucfsize > cfsize):
|
|
@@ -5801,7 +5908,7 @@ def PackCatFileFromZipFile(infile, outfile, fmttype="auto", compression="auto",
|
|
|
5801
5908
|
return False
|
|
5802
5909
|
if(outfile == "-" or outfile is None or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
5803
5910
|
fp = CompressOpenFileAlt(
|
|
5804
|
-
fp, compression, compressionlevel, formatspecs)
|
|
5911
|
+
fp, compression, compressionlevel, compressionuselist, formatspecs)
|
|
5805
5912
|
try:
|
|
5806
5913
|
fp.flush()
|
|
5807
5914
|
if(hasattr(os, "sync")):
|
|
@@ -5825,7 +5932,7 @@ def PackCatFileFromZipFile(infile, outfile, fmttype="auto", compression="auto",
|
|
|
5825
5932
|
return outvar
|
|
5826
5933
|
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
|
|
5827
5934
|
fp = CompressOpenFileAlt(
|
|
5828
|
-
fp, compression, compressionlevel, formatspecs)
|
|
5935
|
+
fp, compression, compressionlevel, compressionuselist, formatspecs)
|
|
5829
5936
|
fp.seek(0, 0)
|
|
5830
5937
|
upload_file_to_internet_file(fp, outfile)
|
|
5831
5938
|
if(returnfp):
|
|
@@ -5864,7 +5971,7 @@ if(rarfile_support):
|
|
|
5864
5971
|
outfile = RemoveWindowsPath(outfile)
|
|
5865
5972
|
if(not compression or compression == formatspecs['format_magic']):
|
|
5866
5973
|
compression = "auto"
|
|
5867
|
-
if(compression not in
|
|
5974
|
+
if(compression not in compressionuselist and compression is None):
|
|
5868
5975
|
compression = "auto"
|
|
5869
5976
|
if(verbose):
|
|
5870
5977
|
logging.basicConfig(format="%(message)s", stream=sys.stdout, level=logging.DEBUG)
|
|
@@ -5876,11 +5983,11 @@ if(rarfile_support):
|
|
|
5876
5983
|
pass
|
|
5877
5984
|
if(outfile == "-" or outfile is None):
|
|
5878
5985
|
verbose = False
|
|
5879
|
-
fp =
|
|
5986
|
+
fp = MkTempFile()
|
|
5880
5987
|
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
5881
5988
|
fp = outfile
|
|
5882
5989
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
|
|
5883
|
-
fp =
|
|
5990
|
+
fp = MkTempFile()
|
|
5884
5991
|
else:
|
|
5885
5992
|
fbasename = os.path.splitext(outfile)[0]
|
|
5886
5993
|
fextname = os.path.splitext(outfile)[1]
|
|
@@ -6058,7 +6165,7 @@ if(rarfile_support):
|
|
|
6058
6165
|
fgname = ""
|
|
6059
6166
|
except ImportError:
|
|
6060
6167
|
fgname = ""
|
|
6061
|
-
fcontents =
|
|
6168
|
+
fcontents = MkTempFile()
|
|
6062
6169
|
fcencoding = "UTF-8"
|
|
6063
6170
|
curcompression = "none"
|
|
6064
6171
|
if ftype == 0:
|
|
@@ -6075,13 +6182,13 @@ if(rarfile_support):
|
|
|
6075
6182
|
ilmin = 0
|
|
6076
6183
|
ilcsize = []
|
|
6077
6184
|
while(ilmin < ilsize):
|
|
6078
|
-
cfcontents =
|
|
6185
|
+
cfcontents = MkTempFile()
|
|
6079
6186
|
fcontents.seek(0, 0)
|
|
6080
6187
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
6081
6188
|
fcontents.seek(0, 0)
|
|
6082
6189
|
cfcontents.seek(0, 0)
|
|
6083
6190
|
cfcontents = CompressOpenFileAlt(
|
|
6084
|
-
cfcontents, compressionuselist[ilmin], compressionlevel, formatspecs)
|
|
6191
|
+
cfcontents, compressionuselist[ilmin], compressionlevel, compressionuselist, formatspecs)
|
|
6085
6192
|
if(cfcontents):
|
|
6086
6193
|
cfcontents.seek(0, 2)
|
|
6087
6194
|
ilcsize.append(cfcontents.tell())
|
|
@@ -6092,16 +6199,16 @@ if(rarfile_support):
|
|
|
6092
6199
|
ilcmin = ilcsize.index(min(ilcsize))
|
|
6093
6200
|
curcompression = compressionuselist[ilcmin]
|
|
6094
6201
|
fcontents.seek(0, 0)
|
|
6095
|
-
cfcontents =
|
|
6202
|
+
cfcontents = MkTempFile()
|
|
6096
6203
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
6097
6204
|
cfcontents.seek(0, 0)
|
|
6098
6205
|
cfcontents = CompressOpenFileAlt(
|
|
6099
|
-
cfcontents, curcompression, compressionlevel, formatspecs)
|
|
6206
|
+
cfcontents, curcompression, compressionlevel, compressionuselist, formatspecs)
|
|
6100
6207
|
cfcontents.seek(0, 2)
|
|
6101
6208
|
cfsize = cfcontents.tell()
|
|
6102
6209
|
if(ucfsize > cfsize):
|
|
6103
6210
|
fcsize = format(int(cfsize), 'x').lower()
|
|
6104
|
-
fcompression =
|
|
6211
|
+
fcompression = curcompression
|
|
6105
6212
|
fcontents.close()
|
|
6106
6213
|
fcontents = cfcontents
|
|
6107
6214
|
if(fcompression == "none"):
|
|
@@ -6121,7 +6228,7 @@ if(rarfile_support):
|
|
|
6121
6228
|
return False
|
|
6122
6229
|
if(outfile == "-" or outfile is None or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
6123
6230
|
fp = CompressOpenFileAlt(
|
|
6124
|
-
fp, compression, compressionlevel, formatspecs)
|
|
6231
|
+
fp, compression, compressionlevel, compressionuselist, formatspecs)
|
|
6125
6232
|
try:
|
|
6126
6233
|
fp.flush()
|
|
6127
6234
|
if(hasattr(os, "sync")):
|
|
@@ -6145,7 +6252,7 @@ if(rarfile_support):
|
|
|
6145
6252
|
return outvar
|
|
6146
6253
|
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
|
|
6147
6254
|
fp = CompressOpenFileAlt(
|
|
6148
|
-
fp, compression, compressionlevel, formatspecs)
|
|
6255
|
+
fp, compression, compressionlevel, compressionuselist, formatspecs)
|
|
6149
6256
|
fp.seek(0, 0)
|
|
6150
6257
|
upload_file_to_internet_file(fp, outfile)
|
|
6151
6258
|
if(returnfp):
|
|
@@ -6184,7 +6291,7 @@ if(py7zr_support):
|
|
|
6184
6291
|
outfile = RemoveWindowsPath(outfile)
|
|
6185
6292
|
if(not compression or compression == formatspecs['format_magic']):
|
|
6186
6293
|
compression = "auto"
|
|
6187
|
-
if(compression not in
|
|
6294
|
+
if(compression not in compressionuselist and compression is None):
|
|
6188
6295
|
compression = "auto"
|
|
6189
6296
|
if(verbose):
|
|
6190
6297
|
logging.basicConfig(format="%(message)s", stream=sys.stdout, level=logging.DEBUG)
|
|
@@ -6196,11 +6303,11 @@ if(py7zr_support):
|
|
|
6196
6303
|
pass
|
|
6197
6304
|
if(outfile == "-" or outfile is None):
|
|
6198
6305
|
verbose = False
|
|
6199
|
-
fp =
|
|
6306
|
+
fp = MkTempFile()
|
|
6200
6307
|
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
6201
6308
|
fp = outfile
|
|
6202
6309
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
|
|
6203
|
-
fp =
|
|
6310
|
+
fp = MkTempFile()
|
|
6204
6311
|
else:
|
|
6205
6312
|
fbasename = os.path.splitext(outfile)[0]
|
|
6206
6313
|
fextname = os.path.splitext(outfile)[1]
|
|
@@ -6309,15 +6416,16 @@ if(py7zr_support):
|
|
|
6309
6416
|
fgname = ""
|
|
6310
6417
|
except ImportError:
|
|
6311
6418
|
fgname = ""
|
|
6312
|
-
fcontents =
|
|
6419
|
+
fcontents = MkTempFile()
|
|
6313
6420
|
fcencoding = "UTF-8"
|
|
6314
6421
|
curcompression = "none"
|
|
6315
6422
|
if ftype == 0:
|
|
6316
6423
|
fcontents.write(file_content[member.filename].read())
|
|
6424
|
+
fsize = format(fcontents.tell(), 'x').lower()
|
|
6425
|
+
fcontents.seek(0, 0)
|
|
6317
6426
|
typechecktest = CheckCompressionType(fcontents, closefp=False)
|
|
6318
6427
|
fcontents.seek(0, 0)
|
|
6319
6428
|
fcencoding = GetFileEncoding(fcontents, False)
|
|
6320
|
-
fsize = format(fcontents.tell(), 'x').lower()
|
|
6321
6429
|
file_content[member.filename].close()
|
|
6322
6430
|
if(typechecktest is False and not compresswholefile):
|
|
6323
6431
|
fcontents.seek(0, 2)
|
|
@@ -6328,13 +6436,13 @@ if(py7zr_support):
|
|
|
6328
6436
|
ilmin = 0
|
|
6329
6437
|
ilcsize = []
|
|
6330
6438
|
while(ilmin < ilsize):
|
|
6331
|
-
cfcontents =
|
|
6439
|
+
cfcontents = MkTempFile()
|
|
6332
6440
|
fcontents.seek(0, 0)
|
|
6333
6441
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
6334
6442
|
fcontents.seek(0, 0)
|
|
6335
6443
|
cfcontents.seek(0, 0)
|
|
6336
6444
|
cfcontents = CompressOpenFileAlt(
|
|
6337
|
-
cfcontents, compressionuselist[ilmin], compressionlevel, formatspecs)
|
|
6445
|
+
cfcontents, compressionuselist[ilmin], compressionlevel, compressionuselist, formatspecs)
|
|
6338
6446
|
if(cfcontents):
|
|
6339
6447
|
cfcontents.seek(0, 2)
|
|
6340
6448
|
ilcsize.append(cfcontents.tell())
|
|
@@ -6345,11 +6453,11 @@ if(py7zr_support):
|
|
|
6345
6453
|
ilcmin = ilcsize.index(min(ilcsize))
|
|
6346
6454
|
curcompression = compressionuselist[ilcmin]
|
|
6347
6455
|
fcontents.seek(0, 0)
|
|
6348
|
-
cfcontents =
|
|
6456
|
+
cfcontents = MkTempFile()
|
|
6349
6457
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
6350
6458
|
cfcontents.seek(0, 0)
|
|
6351
6459
|
cfcontents = CompressOpenFileAlt(
|
|
6352
|
-
cfcontents, curcompression, compressionlevel, formatspecs)
|
|
6460
|
+
cfcontents, curcompression, compressionlevel, compressionuselist, formatspecs)
|
|
6353
6461
|
cfcontents.seek(0, 2)
|
|
6354
6462
|
cfsize = cfcontents.tell()
|
|
6355
6463
|
if(ucfsize > cfsize):
|
|
@@ -6374,7 +6482,7 @@ if(py7zr_support):
|
|
|
6374
6482
|
return False
|
|
6375
6483
|
if(outfile == "-" or outfile is None or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
6376
6484
|
fp = CompressOpenFileAlt(
|
|
6377
|
-
fp, compression, compressionlevel, formatspecs)
|
|
6485
|
+
fp, compression, compressionlevel, compressionuselist, formatspecs)
|
|
6378
6486
|
try:
|
|
6379
6487
|
fp.flush()
|
|
6380
6488
|
if(hasattr(os, "sync")):
|
|
@@ -6398,7 +6506,7 @@ if(py7zr_support):
|
|
|
6398
6506
|
return outvar
|
|
6399
6507
|
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
|
|
6400
6508
|
fp = CompressOpenFileAlt(
|
|
6401
|
-
fp, compression, compressionlevel, formatspecs)
|
|
6509
|
+
fp, compression, compressionlevel, compressionuselist, formatspecs)
|
|
6402
6510
|
fp.seek(0, 0)
|
|
6403
6511
|
upload_file_to_internet_file(fp, outfile)
|
|
6404
6512
|
if(returnfp):
|
|
@@ -6460,7 +6568,7 @@ def CatFileSeekToFileNum(infile, fmttype="auto", seekto=0, listonly=False, conte
|
|
|
6460
6568
|
return False
|
|
6461
6569
|
fp.seek(0, 0)
|
|
6462
6570
|
elif(infile == "-"):
|
|
6463
|
-
fp =
|
|
6571
|
+
fp = MkTempFile()
|
|
6464
6572
|
if(hasattr(sys.stdin, "buffer")):
|
|
6465
6573
|
shutil.copyfileobj(sys.stdin.buffer, fp)
|
|
6466
6574
|
else:
|
|
@@ -6474,7 +6582,7 @@ def CatFileSeekToFileNum(infile, fmttype="auto", seekto=0, listonly=False, conte
|
|
|
6474
6582
|
return False
|
|
6475
6583
|
fp.seek(0, 0)
|
|
6476
6584
|
elif(isinstance(infile, bytes) and sys.version_info[0] >= 3):
|
|
6477
|
-
fp =
|
|
6585
|
+
fp = MkTempFile()
|
|
6478
6586
|
fp.write(infile)
|
|
6479
6587
|
fp.seek(0, 0)
|
|
6480
6588
|
fp = UncompressFileAlt(fp, formatspecs)
|
|
@@ -6775,7 +6883,7 @@ def CatFileSeekToFileName(infile, fmttype="auto", seekfile=None, listonly=False,
|
|
|
6775
6883
|
return False
|
|
6776
6884
|
fp.seek(0, 0)
|
|
6777
6885
|
elif(infile == "-"):
|
|
6778
|
-
fp =
|
|
6886
|
+
fp = MkTempFile()
|
|
6779
6887
|
if(hasattr(sys.stdin, "buffer")):
|
|
6780
6888
|
shutil.copyfileobj(sys.stdin.buffer, fp)
|
|
6781
6889
|
else:
|
|
@@ -6789,7 +6897,7 @@ def CatFileSeekToFileName(infile, fmttype="auto", seekfile=None, listonly=False,
|
|
|
6789
6897
|
return False
|
|
6790
6898
|
fp.seek(0, 0)
|
|
6791
6899
|
elif(isinstance(infile, bytes) and sys.version_info[0] >= 3):
|
|
6792
|
-
fp =
|
|
6900
|
+
fp = MkTempFile()
|
|
6793
6901
|
fp.write(infile)
|
|
6794
6902
|
fp.seek(0, 0)
|
|
6795
6903
|
fp = UncompressFileAlt(fp, formatspecs)
|
|
@@ -7096,7 +7204,7 @@ def CatFileValidate(infile, fmttype="auto", formatspecs=__file_format_multi_dict
|
|
|
7096
7204
|
return False
|
|
7097
7205
|
fp.seek(0, 0)
|
|
7098
7206
|
elif(infile == "-"):
|
|
7099
|
-
fp =
|
|
7207
|
+
fp = MkTempFile()
|
|
7100
7208
|
if(hasattr(sys.stdin, "buffer")):
|
|
7101
7209
|
shutil.copyfileobj(sys.stdin.buffer, fp)
|
|
7102
7210
|
else:
|
|
@@ -7110,7 +7218,7 @@ def CatFileValidate(infile, fmttype="auto", formatspecs=__file_format_multi_dict
|
|
|
7110
7218
|
return False
|
|
7111
7219
|
fp.seek(0, 0)
|
|
7112
7220
|
elif(isinstance(infile, bytes) and sys.version_info[0] >= 3):
|
|
7113
|
-
fp =
|
|
7221
|
+
fp = MkTempFile()
|
|
7114
7222
|
fp.write(infile)
|
|
7115
7223
|
fp.seek(0, 0)
|
|
7116
7224
|
fp = UncompressFileAlt(fp, formatspecs)
|
|
@@ -7448,7 +7556,7 @@ def CatFileToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=Fals
|
|
|
7448
7556
|
return False
|
|
7449
7557
|
fp.seek(0, 0)
|
|
7450
7558
|
elif(infile == "-"):
|
|
7451
|
-
fp =
|
|
7559
|
+
fp = MkTempFile()
|
|
7452
7560
|
if(hasattr(sys.stdin, "buffer")):
|
|
7453
7561
|
shutil.copyfileobj(sys.stdin.buffer, fp)
|
|
7454
7562
|
else:
|
|
@@ -7462,7 +7570,7 @@ def CatFileToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=Fals
|
|
|
7462
7570
|
return False
|
|
7463
7571
|
fp.seek(0, 0)
|
|
7464
7572
|
elif(isinstance(infile, bytes) and sys.version_info[0] >= 3):
|
|
7465
|
-
fp =
|
|
7573
|
+
fp = MkTempFile()
|
|
7466
7574
|
fp.write(infile)
|
|
7467
7575
|
fp.seek(0, 0)
|
|
7468
7576
|
fp = UncompressFileAlt(fp, formatspecs)
|
|
@@ -7595,11 +7703,11 @@ def CatFileToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=Fals
|
|
|
7595
7703
|
if(fcompresstype==formatspecs['format_magic']):
|
|
7596
7704
|
fcompresstype = ""
|
|
7597
7705
|
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': []}
|
|
7598
|
-
if(seekstart < 0
|
|
7706
|
+
if (seekstart < 0) or (seekstart > fnumfiles):
|
|
7599
7707
|
seekstart = 0
|
|
7600
|
-
if(seekend == 0 or seekend > fnumfiles
|
|
7708
|
+
if (seekend == 0) or (seekend > fnumfiles) or (seekend < seekstart):
|
|
7601
7709
|
seekend = fnumfiles
|
|
7602
|
-
elif(seekend < 0 and abs(seekend) <= fnumfiles and abs(seekend) >= seekstart):
|
|
7710
|
+
elif (seekend < 0) and (abs(seekend) <= fnumfiles) and (abs(seekend) >= seekstart):
|
|
7603
7711
|
seekend = fnumfiles - abs(seekend)
|
|
7604
7712
|
if(seekstart > 0):
|
|
7605
7713
|
il = 0
|
|
@@ -7762,7 +7870,7 @@ def CatFileToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=Fals
|
|
|
7762
7870
|
outfjsoncontent = {}
|
|
7763
7871
|
elif(outfjsontype=="list"):
|
|
7764
7872
|
outfprejsoncontent = fp.read(outfjsonsize).decode("UTF-8")
|
|
7765
|
-
flisttmp =
|
|
7873
|
+
flisttmp = MkTempFile()
|
|
7766
7874
|
flisttmp.write(outfprejsoncontent.encode())
|
|
7767
7875
|
flisttmp.seek(0)
|
|
7768
7876
|
outfjsoncontent = ReadFileHeaderData(flisttmp, outfjsonlen, formatspecs['format_delimiter'])
|
|
@@ -7815,7 +7923,7 @@ def CatFileToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=Fals
|
|
|
7815
7923
|
VerbosePrintOut("'" + outfjsonchecksum + "' != " + "'" + injsonfcs + "'")
|
|
7816
7924
|
return False
|
|
7817
7925
|
outfcontentstart = fp.tell()
|
|
7818
|
-
outfcontents =
|
|
7926
|
+
outfcontents = MkTempFile()
|
|
7819
7927
|
pyhascontents = False
|
|
7820
7928
|
if(outfsize > 0 and not listonly):
|
|
7821
7929
|
if(outfcompression == "none" or outfcompression == "" or outfcompression == "auto"):
|
|
@@ -7840,7 +7948,7 @@ def CatFileToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=Fals
|
|
|
7840
7948
|
cfcontents = UncompressFileAlt(
|
|
7841
7949
|
outfcontents, formatspecs)
|
|
7842
7950
|
cfcontents.seek(0, 0)
|
|
7843
|
-
outfcontents =
|
|
7951
|
+
outfcontents = MkTempFile()
|
|
7844
7952
|
shutil.copyfileobj(cfcontents, outfcontents)
|
|
7845
7953
|
cfcontents.close()
|
|
7846
7954
|
outfcontents.seek(0, 0)
|
|
@@ -7890,7 +7998,7 @@ def MultipleCatFileToArray(infile, fmttype="auto", seekstart=0, seekend=0, listo
|
|
|
7890
7998
|
infile = [infile]
|
|
7891
7999
|
outretval = {}
|
|
7892
8000
|
for curfname in infile:
|
|
7893
|
-
curretfile =
|
|
8001
|
+
curretfile[curfname] = CatFileToArray(curfname, fmttype, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, formatspecs, seektoend, returnfp)
|
|
7894
8002
|
return outretval
|
|
7895
8003
|
|
|
7896
8004
|
def MultipleCatFilesToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=False, contentasfile=True, uncompress=True, skipchecksum=False, formatspecs=__file_format_multi_dict__, seektoend=False, returnfp=False):
|
|
@@ -7901,31 +8009,31 @@ def CatFileStringToArray(instr, seekstart=0, seekend=0, listonly=False, contenta
|
|
|
7901
8009
|
checkcompressfile = CheckCompressionSubType(infile, formatspecs, True)
|
|
7902
8010
|
if(IsNestedDict(formatspecs) and checkcompressfile in formatspecs):
|
|
7903
8011
|
formatspecs = formatspecs[checkcompressfile]
|
|
7904
|
-
fp =
|
|
7905
|
-
|
|
7906
|
-
return
|
|
8012
|
+
fp = MkTempFile(instr)
|
|
8013
|
+
listcatfiles = CatFileToArray(fp, "auto", seekstart, seekend, listonly, contentasfile, True, skipchecksum, formatspecs, seektoend, returnfp)
|
|
8014
|
+
return listcatfiles
|
|
7907
8015
|
|
|
7908
8016
|
|
|
7909
8017
|
def TarFileToArray(infile, seekstart=0, seekend=0, listonly=False, contentasfile=True, skipchecksum=False, formatspecs=__file_format_dict__, seektoend=False, returnfp=False):
|
|
7910
8018
|
checkcompressfile = CheckCompressionSubType(infile, formatspecs, True)
|
|
7911
8019
|
if(IsNestedDict(formatspecs) and checkcompressfile in formatspecs):
|
|
7912
8020
|
formatspecs = formatspecs[checkcompressfile]
|
|
7913
|
-
fp =
|
|
8021
|
+
fp = MkTempFile()
|
|
7914
8022
|
fp = PackCatFileFromTarFile(
|
|
7915
8023
|
infile, fp, "auto", True, None, compressionlistalt, "crc32", [], formatspecs, False, True)
|
|
7916
|
-
|
|
7917
|
-
return
|
|
8024
|
+
listcatfiles = CatFileToArray(fp, "auto", seekstart, seekend, listonly, contentasfile, True, skipchecksum, formatspecs, seektoend, returnfp)
|
|
8025
|
+
return listcatfiles
|
|
7918
8026
|
|
|
7919
8027
|
|
|
7920
8028
|
def ZipFileToArray(infile, seekstart=0, seekend=0, listonly=False, contentasfile=True, skipchecksum=False, formatspecs=__file_format_dict__, seektoend=False, returnfp=False):
|
|
7921
8029
|
checkcompressfile = CheckCompressionSubType(infile, formatspecs, True)
|
|
7922
8030
|
if(IsNestedDict(formatspecs) and checkcompressfile in formatspecs):
|
|
7923
8031
|
formatspecs = formatspecs[checkcompressfile]
|
|
7924
|
-
fp =
|
|
8032
|
+
fp = MkTempFile()
|
|
7925
8033
|
fp = PackCatFileFromZipFile(
|
|
7926
8034
|
infile, fp, "auto", True, None, compressionlistalt, "crc32", [], formatspecs, False, True)
|
|
7927
|
-
|
|
7928
|
-
return
|
|
8035
|
+
listcatfiles = CatFileToArray(fp, "auto", seekstart, seekend, listonly, contentasfile, True, skipchecksum, formatspecs, seektoend, returnfp)
|
|
8036
|
+
return listcatfiles
|
|
7929
8037
|
|
|
7930
8038
|
|
|
7931
8039
|
if(not rarfile_support):
|
|
@@ -7937,11 +8045,11 @@ if(rarfile_support):
|
|
|
7937
8045
|
checkcompressfile = CheckCompressionSubType(infile, formatspecs, True)
|
|
7938
8046
|
if(IsNestedDict(formatspecs) and checkcompressfile in formatspecs):
|
|
7939
8047
|
formatspecs = formatspecs[checkcompressfile]
|
|
7940
|
-
fp =
|
|
8048
|
+
fp = MkTempFile()
|
|
7941
8049
|
fp = PackCatFileFromRarFile(
|
|
7942
8050
|
infile, fp, "auto", True, None, compressionlistalt, "crc32", [], formatspecs, False, True)
|
|
7943
|
-
|
|
7944
|
-
return
|
|
8051
|
+
listcatfiles = CatFileToArray(fp, "auto", seekstart, seekend, listonly, contentasfile, True, skipchecksum, formatspecs, seektoend, returnfp)
|
|
8052
|
+
return listcatfiles
|
|
7945
8053
|
|
|
7946
8054
|
if(not py7zr_support):
|
|
7947
8055
|
def SevenZipFileToArray(infile, seekstart=0, seekend=0, listonly=False, contentasfile=True, skipchecksum=False, formatspecs=__file_format_dict__, seektoend=False, returnfp=False):
|
|
@@ -7952,11 +8060,11 @@ if(py7zr_support):
|
|
|
7952
8060
|
checkcompressfile = CheckCompressionSubType(infile, formatspecs, True)
|
|
7953
8061
|
if(IsNestedDict(formatspecs) and checkcompressfile in formatspecs):
|
|
7954
8062
|
formatspecs = formatspecs[checkcompressfile]
|
|
7955
|
-
fp =
|
|
8063
|
+
fp = MkTempFile()
|
|
7956
8064
|
fp = PackCatFileFromSevenZipFile(
|
|
7957
8065
|
infile, fp, "auto", True, None, compressionlistalt, "crc32", [], formatspecs, False, True)
|
|
7958
|
-
|
|
7959
|
-
return
|
|
8066
|
+
listcatfiles = CatFileToArray(fp, "auto", seekstart, seekend, listonly, contentasfile, True, skipchecksum, formatspecs, seektoend, returnfp)
|
|
8067
|
+
return listcatfiles
|
|
7960
8068
|
|
|
7961
8069
|
|
|
7962
8070
|
def InFileToArray(infile, seekstart=0, seekend=0, listonly=False, contentasfile=True, skipchecksum=False, formatspecs=__file_format_multi_dict__, seektoend=False, returnfp=False):
|
|
@@ -7979,71 +8087,71 @@ def InFileToArray(infile, seekstart=0, seekend=0, listonly=False, contentasfile=
|
|
|
7979
8087
|
|
|
7980
8088
|
|
|
7981
8089
|
def ListDirToArray(infiles, dirlistfromtxt=False, fmttype=__file_format_default__, compression="auto", compresswholefile=True, compressionlevel=None, followlink=False, seekstart=0, seekend=0, listonly=False, skipchecksum=False, checksumtype=["crc32", "crc32", "crc32"], extradata=[], formatspecs=__file_format_dict__, verbose=False, seektoend=False, returnfp=False):
|
|
7982
|
-
outarray =
|
|
8090
|
+
outarray = MkTempFile()
|
|
7983
8091
|
packform = PackCatFile(infiles, outarray, dirlistfromtxt, fmttype, compression, compresswholefile,
|
|
7984
8092
|
compressionlevel, followlink, checksumtype, extradata, formatspecs, verbose, True)
|
|
7985
|
-
|
|
7986
|
-
return
|
|
8093
|
+
listcatfiles = CatFileToArray(outarray, "auto", seekstart, seekend, listonly, True, skipchecksum, formatspecs, seektoend, returnfp)
|
|
8094
|
+
return listcatfiles
|
|
7987
8095
|
|
|
7988
8096
|
|
|
7989
8097
|
def CatFileArrayToArrayIndex(inarray, returnfp=False):
|
|
7990
8098
|
if(isinstance(inarray, dict)):
|
|
7991
|
-
|
|
8099
|
+
listcatfiles = inarray
|
|
7992
8100
|
else:
|
|
7993
8101
|
return False
|
|
7994
|
-
if(not
|
|
8102
|
+
if(not listcatfiles):
|
|
7995
8103
|
return False
|
|
7996
|
-
outarray = {'list':
|
|
8104
|
+
outarray = {'list': listcatfiles, 'filetoid': {}, 'idtofile': {}, 'filetypes': {'directories': {'filetoid': {}, 'idtofile': {}}, 'files': {'filetoid': {}, 'idtofile': {}}, 'links': {'filetoid': {}, 'idtofile': {}}, 'symlinks': {'filetoid': {
|
|
7997
8105
|
}, 'idtofile': {}}, 'hardlinks': {'filetoid': {}, 'idtofile': {}}, 'character': {'filetoid': {}, 'idtofile': {}}, 'block': {'filetoid': {}, 'idtofile': {}}, 'fifo': {'filetoid': {}, 'idtofile': {}}, 'devices': {'filetoid': {}, 'idtofile': {}}}}
|
|
7998
8106
|
if(returnfp):
|
|
7999
|
-
outarray.update({'fp':
|
|
8000
|
-
lenlist = len(
|
|
8107
|
+
outarray.update({'fp': listcatfiles['fp']})
|
|
8108
|
+
lenlist = len(listcatfiles['ffilelist'])
|
|
8001
8109
|
lcfi = 0
|
|
8002
|
-
lcfx = int(
|
|
8003
|
-
if(lenlist >
|
|
8110
|
+
lcfx = int(listcatfiles['fnumfiles'])
|
|
8111
|
+
if(lenlist > listcatfiles['fnumfiles'] or lenlist < listcatfiles['fnumfiles']):
|
|
8004
8112
|
lcfx = int(lenlist)
|
|
8005
8113
|
else:
|
|
8006
|
-
lcfx = int(
|
|
8114
|
+
lcfx = int(listcatfiles['fnumfiles'])
|
|
8007
8115
|
while(lcfi < lcfx):
|
|
8008
|
-
filetoidarray = {
|
|
8009
|
-
['fname']:
|
|
8010
|
-
idtofilearray = {
|
|
8011
|
-
['fid']:
|
|
8116
|
+
filetoidarray = {listcatfiles['ffilelist'][lcfi]
|
|
8117
|
+
['fname']: listcatfiles['ffilelist'][lcfi]['fid']}
|
|
8118
|
+
idtofilearray = {listcatfiles['ffilelist'][lcfi]
|
|
8119
|
+
['fid']: listcatfiles['ffilelist'][lcfi]['fname']}
|
|
8012
8120
|
outarray['filetoid'].update(filetoidarray)
|
|
8013
8121
|
outarray['idtofile'].update(idtofilearray)
|
|
8014
|
-
if(
|
|
8122
|
+
if(listcatfiles['ffilelist'][lcfi]['ftype'] == 0 or listcatfiles['ffilelist'][lcfi]['ftype'] == 7):
|
|
8015
8123
|
outarray['filetypes']['files']['filetoid'].update(filetoidarray)
|
|
8016
8124
|
outarray['filetypes']['files']['idtofile'].update(idtofilearray)
|
|
8017
|
-
if(
|
|
8125
|
+
if(listcatfiles['ffilelist'][lcfi]['ftype'] == 1):
|
|
8018
8126
|
outarray['filetypes']['hardlinks']['filetoid'].update(
|
|
8019
8127
|
filetoidarray)
|
|
8020
8128
|
outarray['filetypes']['hardlinks']['idtofile'].update(
|
|
8021
8129
|
idtofilearray)
|
|
8022
8130
|
outarray['filetypes']['links']['filetoid'].update(filetoidarray)
|
|
8023
8131
|
outarray['filetypes']['links']['idtofile'].update(idtofilearray)
|
|
8024
|
-
if(
|
|
8132
|
+
if(listcatfiles['ffilelist'][lcfi]['ftype'] == 2):
|
|
8025
8133
|
outarray['filetypes']['symlinks']['filetoid'].update(filetoidarray)
|
|
8026
8134
|
outarray['filetypes']['symlinks']['idtofile'].update(idtofilearray)
|
|
8027
8135
|
outarray['filetypes']['links']['filetoid'].update(filetoidarray)
|
|
8028
8136
|
outarray['filetypes']['links']['idtofile'].update(idtofilearray)
|
|
8029
|
-
if(
|
|
8137
|
+
if(listcatfiles['ffilelist'][lcfi]['ftype'] == 3):
|
|
8030
8138
|
outarray['filetypes']['character']['filetoid'].update(
|
|
8031
8139
|
filetoidarray)
|
|
8032
8140
|
outarray['filetypes']['character']['idtofile'].update(
|
|
8033
8141
|
idtofilearray)
|
|
8034
8142
|
outarray['filetypes']['devices']['filetoid'].update(filetoidarray)
|
|
8035
8143
|
outarray['filetypes']['devices']['idtofile'].update(idtofilearray)
|
|
8036
|
-
if(
|
|
8144
|
+
if(listcatfiles['ffilelist'][lcfi]['ftype'] == 4):
|
|
8037
8145
|
outarray['filetypes']['block']['filetoid'].update(filetoidarray)
|
|
8038
8146
|
outarray['filetypes']['block']['idtofile'].update(idtofilearray)
|
|
8039
8147
|
outarray['filetypes']['devices']['filetoid'].update(filetoidarray)
|
|
8040
8148
|
outarray['filetypes']['devices']['idtofile'].update(idtofilearray)
|
|
8041
|
-
if(
|
|
8149
|
+
if(listcatfiles['ffilelist'][lcfi]['ftype'] == 5):
|
|
8042
8150
|
outarray['filetypes']['directories']['filetoid'].update(
|
|
8043
8151
|
filetoidarray)
|
|
8044
8152
|
outarray['filetypes']['directories']['idtofile'].update(
|
|
8045
8153
|
idtofilearray)
|
|
8046
|
-
if(
|
|
8154
|
+
if(listcatfiles['ffilelist'][lcfi]['ftype'] == 6):
|
|
8047
8155
|
outarray['filetypes']['symlinks']['filetoid'].update(filetoidarray)
|
|
8048
8156
|
outarray['filetypes']['symlinks']['idtofile'].update(idtofilearray)
|
|
8049
8157
|
outarray['filetypes']['devices']['filetoid'].update(filetoidarray)
|
|
@@ -8054,11 +8162,11 @@ def CatFileArrayToArrayIndex(inarray, returnfp=False):
|
|
|
8054
8162
|
|
|
8055
8163
|
def RePackCatFile(infile, outfile, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, compressionuselist=compressionlistalt, followlink=False, seekstart=0, seekend=0, checksumtype=["crc32", "crc32", "crc32", "crc32"], skipchecksum=False, extradata=[], jsondata={}, formatspecs=__file_format_dict__, seektoend=False, verbose=False, returnfp=False):
|
|
8056
8164
|
if(isinstance(infile, dict)):
|
|
8057
|
-
|
|
8165
|
+
listcatfiles = infile
|
|
8058
8166
|
else:
|
|
8059
8167
|
if(infile != "-" and not isinstance(infile, bytes) and not hasattr(infile, "read") and not hasattr(infile, "write")):
|
|
8060
8168
|
infile = RemoveWindowsPath(infile)
|
|
8061
|
-
|
|
8169
|
+
listcatfiles = CatFileToArray(infile, "auto", seekstart, seekend, False, True, skipchecksum, formatspecs, seektoend, returnfp)
|
|
8062
8170
|
if(IsNestedDict(formatspecs) and fmttype in formatspecs):
|
|
8063
8171
|
formatspecs = formatspecs[fmttype]
|
|
8064
8172
|
elif(IsNestedDict(formatspecs) and fmttype not in formatspecs):
|
|
@@ -8074,7 +8182,7 @@ def RePackCatFile(infile, outfile, fmttype="auto", compression="auto", compressw
|
|
|
8074
8182
|
outfile = RemoveWindowsPath(outfile)
|
|
8075
8183
|
if(not compression or compression == formatspecs['format_magic']):
|
|
8076
8184
|
compression = "auto"
|
|
8077
|
-
if(compression not in
|
|
8185
|
+
if(compression not in compressionuselist and compression is None):
|
|
8078
8186
|
compression = "auto"
|
|
8079
8187
|
if(verbose):
|
|
8080
8188
|
logging.basicConfig(format="%(message)s", stream=sys.stdout, level=logging.DEBUG)
|
|
@@ -8084,15 +8192,15 @@ def RePackCatFile(infile, outfile, fmttype="auto", compression="auto", compressw
|
|
|
8084
8192
|
os.unlink(outfile)
|
|
8085
8193
|
except OSError:
|
|
8086
8194
|
pass
|
|
8087
|
-
if(not
|
|
8195
|
+
if(not listcatfiles):
|
|
8088
8196
|
return False
|
|
8089
8197
|
if(outfile == "-" or outfile is None):
|
|
8090
8198
|
verbose = False
|
|
8091
|
-
fp =
|
|
8199
|
+
fp = MkTempFile()
|
|
8092
8200
|
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
8093
8201
|
fp = outfile
|
|
8094
8202
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
|
|
8095
|
-
fp =
|
|
8203
|
+
fp = MkTempFile()
|
|
8096
8204
|
else:
|
|
8097
8205
|
fbasename = os.path.splitext(outfile)[0]
|
|
8098
8206
|
fextname = os.path.splitext(outfile)[1]
|
|
@@ -8104,19 +8212,19 @@ def RePackCatFile(infile, outfile, fmttype="auto", compression="auto", compressw
|
|
|
8104
8212
|
return False
|
|
8105
8213
|
formver = formatspecs['format_ver']
|
|
8106
8214
|
fileheaderver = str(int(formver.replace(".", "")))
|
|
8107
|
-
lenlist = len(
|
|
8108
|
-
fnumfiles = int(
|
|
8215
|
+
lenlist = len(listcatfiles['ffilelist'])
|
|
8216
|
+
fnumfiles = int(listcatfiles['fnumfiles'])
|
|
8109
8217
|
if(lenlist > fnumfiles or lenlist < fnumfiles):
|
|
8110
8218
|
fnumfiles = lenlist
|
|
8111
|
-
AppendFileHeader(fp, fnumfiles,
|
|
8112
|
-
lenlist = len(
|
|
8113
|
-
fnumfiles = int(
|
|
8219
|
+
AppendFileHeader(fp, fnumfiles, listcatfiles['fencoding'], [], checksumtype[0], formatspecs)
|
|
8220
|
+
lenlist = len(listcatfiles['ffilelist'])
|
|
8221
|
+
fnumfiles = int(listcatfiles['fnumfiles'])
|
|
8114
8222
|
lcfi = 0
|
|
8115
|
-
lcfx = int(
|
|
8116
|
-
if(lenlist >
|
|
8223
|
+
lcfx = int(listcatfiles['fnumfiles'])
|
|
8224
|
+
if(lenlist > listcatfiles['fnumfiles'] or lenlist < listcatfiles['fnumfiles']):
|
|
8117
8225
|
lcfx = int(lenlist)
|
|
8118
8226
|
else:
|
|
8119
|
-
lcfx = int(
|
|
8227
|
+
lcfx = int(listcatfiles['fnumfiles'])
|
|
8120
8228
|
curinode = 0
|
|
8121
8229
|
curfid = 0
|
|
8122
8230
|
inodelist = []
|
|
@@ -8124,63 +8232,63 @@ def RePackCatFile(infile, outfile, fmttype="auto", compression="auto", compressw
|
|
|
8124
8232
|
filetoinode = {}
|
|
8125
8233
|
reallcfi = 0
|
|
8126
8234
|
while(lcfi < lcfx):
|
|
8127
|
-
fencoding =
|
|
8128
|
-
fcencoding =
|
|
8129
|
-
if(re.findall("^[.|/]",
|
|
8130
|
-
fname =
|
|
8235
|
+
fencoding = listcatfiles['ffilelist'][reallcfi]['fencoding']
|
|
8236
|
+
fcencoding = listcatfiles['ffilelist'][reallcfi]['fencoding']
|
|
8237
|
+
if(re.findall("^[.|/]", listcatfiles['ffilelist'][reallcfi]['fname'])):
|
|
8238
|
+
fname = listcatfiles['ffilelist'][reallcfi]['fname']
|
|
8131
8239
|
else:
|
|
8132
|
-
fname = "./"+
|
|
8240
|
+
fname = "./"+listcatfiles['ffilelist'][reallcfi]['fname']
|
|
8133
8241
|
if(verbose):
|
|
8134
8242
|
VerbosePrintOut(fname)
|
|
8135
8243
|
fheadersize = format(
|
|
8136
|
-
int(
|
|
8244
|
+
int(listcatfiles['ffilelist'][reallcfi]['fheadersize']), 'x').lower()
|
|
8137
8245
|
fsize = format(
|
|
8138
|
-
int(
|
|
8139
|
-
flinkname =
|
|
8246
|
+
int(listcatfiles['ffilelist'][reallcfi]['fsize']), 'x').lower()
|
|
8247
|
+
flinkname = listcatfiles['ffilelist'][reallcfi]['flinkname']
|
|
8140
8248
|
fatime = format(
|
|
8141
|
-
int(
|
|
8249
|
+
int(listcatfiles['ffilelist'][reallcfi]['fatime']), 'x').lower()
|
|
8142
8250
|
fmtime = format(
|
|
8143
|
-
int(
|
|
8251
|
+
int(listcatfiles['ffilelist'][reallcfi]['fmtime']), 'x').lower()
|
|
8144
8252
|
fctime = format(
|
|
8145
|
-
int(
|
|
8253
|
+
int(listcatfiles['ffilelist'][reallcfi]['fctime']), 'x').lower()
|
|
8146
8254
|
fbtime = format(
|
|
8147
|
-
int(
|
|
8255
|
+
int(listcatfiles['ffilelist'][reallcfi]['fbtime']), 'x').lower()
|
|
8148
8256
|
fmode = format(
|
|
8149
|
-
int(
|
|
8257
|
+
int(listcatfiles['ffilelist'][reallcfi]['fmode']), 'x').lower()
|
|
8150
8258
|
fchmode = format(
|
|
8151
|
-
int(
|
|
8259
|
+
int(listcatfiles['ffilelist'][reallcfi]['fchmode']), 'x').lower()
|
|
8152
8260
|
fuid = format(
|
|
8153
|
-
int(
|
|
8154
|
-
funame =
|
|
8261
|
+
int(listcatfiles['ffilelist'][reallcfi]['fuid']), 'x').lower()
|
|
8262
|
+
funame = listcatfiles['ffilelist'][reallcfi]['funame']
|
|
8155
8263
|
fgid = format(
|
|
8156
|
-
int(
|
|
8157
|
-
fgname =
|
|
8264
|
+
int(listcatfiles['ffilelist'][reallcfi]['fgid']), 'x').lower()
|
|
8265
|
+
fgname = listcatfiles['ffilelist'][reallcfi]['fgname']
|
|
8158
8266
|
finode = format(
|
|
8159
|
-
int(
|
|
8267
|
+
int(listcatfiles['ffilelist'][reallcfi]['finode']), 'x').lower()
|
|
8160
8268
|
flinkcount = format(
|
|
8161
|
-
int(
|
|
8269
|
+
int(listcatfiles['ffilelist'][reallcfi]['flinkcount']), 'x').lower()
|
|
8162
8270
|
fwinattributes = format(
|
|
8163
|
-
int(
|
|
8164
|
-
fcompression =
|
|
8271
|
+
int(listcatfiles['ffilelist'][reallcfi]['fwinattributes']), 'x').lower()
|
|
8272
|
+
fcompression = listcatfiles['ffilelist'][reallcfi]['fcompression']
|
|
8165
8273
|
fcsize = format(
|
|
8166
|
-
int(
|
|
8274
|
+
int(listcatfiles['ffilelist'][reallcfi]['fcsize']), 'x').lower()
|
|
8167
8275
|
fdev = format(
|
|
8168
|
-
int(
|
|
8276
|
+
int(listcatfiles['ffilelist'][reallcfi]['fdev']), 'x').lower()
|
|
8169
8277
|
fdev_minor = format(
|
|
8170
|
-
int(
|
|
8278
|
+
int(listcatfiles['ffilelist'][reallcfi]['fminor']), 'x').lower()
|
|
8171
8279
|
fdev_major = format(
|
|
8172
|
-
int(
|
|
8173
|
-
fseeknextfile =
|
|
8174
|
-
if(len(
|
|
8175
|
-
|
|
8176
|
-
|
|
8280
|
+
int(listcatfiles['ffilelist'][reallcfi]['fmajor']), 'x').lower()
|
|
8281
|
+
fseeknextfile = listcatfiles['ffilelist'][reallcfi]['fseeknextfile']
|
|
8282
|
+
if(len(listcatfiles['ffilelist'][reallcfi]['fextralist']) > listcatfiles['ffilelist'][reallcfi]['fextrafields'] and len(listcatfiles['ffilelist'][reallcfi]['fextralist']) > 0):
|
|
8283
|
+
listcatfiles['ffilelist'][reallcfi]['fextrafields'] = len(
|
|
8284
|
+
listcatfiles['ffilelist'][reallcfi]['fextralist'])
|
|
8177
8285
|
if(not followlink and len(extradata) <= 0):
|
|
8178
|
-
extradata =
|
|
8286
|
+
extradata = listcatfiles['ffilelist'][reallcfi]['fextralist']
|
|
8179
8287
|
if(not followlink and len(jsondata) <= 0):
|
|
8180
|
-
jsondata =
|
|
8181
|
-
fcontents =
|
|
8182
|
-
if(not
|
|
8183
|
-
fcontents =
|
|
8288
|
+
jsondata = listcatfiles['ffilelist'][reallcfi]['fjsondata']
|
|
8289
|
+
fcontents = listcatfiles['ffilelist'][reallcfi]['fcontents']
|
|
8290
|
+
if(not listcatfiles['ffilelist'][reallcfi]['fcontentasfile']):
|
|
8291
|
+
fcontents = MkTempFile(fcontents)
|
|
8184
8292
|
typechecktest = CheckCompressionType(fcontents, closefp=False)
|
|
8185
8293
|
fcontents.seek(0, 0)
|
|
8186
8294
|
fcencoding = GetFileEncoding(fcontents, False)
|
|
@@ -8196,13 +8304,13 @@ def RePackCatFile(infile, outfile, fmttype="auto", compression="auto", compressw
|
|
|
8196
8304
|
ilmin = 0
|
|
8197
8305
|
ilcsize = []
|
|
8198
8306
|
while(ilmin < ilsize):
|
|
8199
|
-
cfcontents =
|
|
8307
|
+
cfcontents = MkTempFile()
|
|
8200
8308
|
fcontents.seek(0, 0)
|
|
8201
8309
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
8202
8310
|
fcontents.seek(0, 0)
|
|
8203
8311
|
cfcontents.seek(0, 0)
|
|
8204
8312
|
cfcontents = CompressOpenFileAlt(
|
|
8205
|
-
cfcontents, compressionuselist[ilmin], compressionlevel, formatspecs)
|
|
8313
|
+
cfcontents, compressionuselist[ilmin], compressionlevel, compressionuselist, formatspecs)
|
|
8206
8314
|
if(cfcontents):
|
|
8207
8315
|
cfcontents.seek(0, 2)
|
|
8208
8316
|
ilcsize.append(cfcontents.tell())
|
|
@@ -8213,11 +8321,11 @@ def RePackCatFile(infile, outfile, fmttype="auto", compression="auto", compressw
|
|
|
8213
8321
|
ilcmin = ilcsize.index(min(ilcsize))
|
|
8214
8322
|
curcompression = compressionuselist[ilcmin]
|
|
8215
8323
|
fcontents.seek(0, 0)
|
|
8216
|
-
cfcontents =
|
|
8324
|
+
cfcontents = MkTempFile()
|
|
8217
8325
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
8218
8326
|
cfcontents.seek(0, 0)
|
|
8219
8327
|
cfcontents = CompressOpenFileAlt(
|
|
8220
|
-
cfcontents, curcompression, compressionlevel, formatspecs)
|
|
8328
|
+
cfcontents, curcompression, compressionlevel, compressionuselist, formatspecs)
|
|
8221
8329
|
cfcontents.seek(0, 2)
|
|
8222
8330
|
cfsize = cfcontents.tell()
|
|
8223
8331
|
if(ucfsize > cfsize):
|
|
@@ -8226,10 +8334,10 @@ def RePackCatFile(infile, outfile, fmttype="auto", compression="auto", compressw
|
|
|
8226
8334
|
fcontents.close()
|
|
8227
8335
|
fcontents = cfcontents
|
|
8228
8336
|
if followlink:
|
|
8229
|
-
if(
|
|
8230
|
-
getflinkpath =
|
|
8231
|
-
flinkid =
|
|
8232
|
-
flinkinfo =
|
|
8337
|
+
if(listcatfiles['ffilelist'][reallcfi]['ftype'] == 1 or listcatfiles['ffilelist'][reallcfi]['ftype'] == 2):
|
|
8338
|
+
getflinkpath = listcatfiles['ffilelist'][reallcfi]['flinkname']
|
|
8339
|
+
flinkid = prelistcatfiles['filetoid'][getflinkpath]
|
|
8340
|
+
flinkinfo = listcatfiles['ffilelist'][flinkid]
|
|
8233
8341
|
fheadersize = format(
|
|
8234
8342
|
int(flinkinfo['fheadersize']), 'x').lower()
|
|
8235
8343
|
fsize = format(int(flinkinfo['fsize']), 'x').lower()
|
|
@@ -8262,14 +8370,14 @@ def RePackCatFile(infile, outfile, fmttype="auto", compression="auto", compressw
|
|
|
8262
8370
|
extradata = flinkinfo['fjsondata']
|
|
8263
8371
|
fcontents = flinkinfo['fcontents']
|
|
8264
8372
|
if(not flinkinfo['fcontentasfile']):
|
|
8265
|
-
fcontents =
|
|
8373
|
+
fcontents = MkTempFile(fcontents)
|
|
8266
8374
|
ftypehex = format(flinkinfo['ftype'], 'x').lower()
|
|
8267
8375
|
else:
|
|
8268
8376
|
ftypehex = format(
|
|
8269
|
-
|
|
8377
|
+
listcatfiles['ffilelist'][reallcfi]['ftype'], 'x').lower()
|
|
8270
8378
|
fcurfid = format(curfid, 'x').lower()
|
|
8271
8379
|
if(not followlink and finode != 0):
|
|
8272
|
-
if(
|
|
8380
|
+
if(listcatfiles['ffilelist'][reallcfi]['ftype'] != 1):
|
|
8273
8381
|
fcurinode = format(int(curinode), 'x').lower()
|
|
8274
8382
|
inodetofile.update({curinode: fname})
|
|
8275
8383
|
filetoinode.update({fname: curinode})
|
|
@@ -8297,7 +8405,7 @@ def RePackCatFile(infile, outfile, fmttype="auto", compression="auto", compressw
|
|
|
8297
8405
|
return False
|
|
8298
8406
|
if(outfile == "-" or outfile is None or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
8299
8407
|
fp = CompressOpenFileAlt(
|
|
8300
|
-
fp, compression, compressionlevel, formatspecs)
|
|
8408
|
+
fp, compression, compressionlevel, compressionuselist, formatspecs)
|
|
8301
8409
|
try:
|
|
8302
8410
|
fp.flush()
|
|
8303
8411
|
if(hasattr(os, "sync")):
|
|
@@ -8321,7 +8429,7 @@ def RePackCatFile(infile, outfile, fmttype="auto", compression="auto", compressw
|
|
|
8321
8429
|
return outvar
|
|
8322
8430
|
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
|
|
8323
8431
|
fp = CompressOpenFileAlt(
|
|
8324
|
-
fp, compression, compressionlevel, formatspecs)
|
|
8432
|
+
fp, compression, compressionlevel, compressionuselist, formatspecs)
|
|
8325
8433
|
fp.seek(0, 0)
|
|
8326
8434
|
upload_file_to_internet_file(fp, outfile)
|
|
8327
8435
|
if(returnfp):
|
|
@@ -8333,19 +8441,19 @@ def RePackCatFile(infile, outfile, fmttype="auto", compression="auto", compressw
|
|
|
8333
8441
|
|
|
8334
8442
|
|
|
8335
8443
|
def RePackCatFileFromString(instr, outfile, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, compressionuselist=compressionlistalt, checksumtype=["crc32", "crc32", "crc32"], skipchecksum=False, extradata=[], formatspecs=__file_format_dict__, verbose=False, returnfp=False):
|
|
8336
|
-
fp =
|
|
8337
|
-
|
|
8444
|
+
fp = MkTempFile(instr)
|
|
8445
|
+
listcatfiles = RePackCatFile(fp, outfile, fmttype, compression, compresswholefile, compressionlevel, compressionuselist,
|
|
8338
8446
|
checksumtype, skipchecksum, extradata, formatspecs, verbose, returnfp)
|
|
8339
|
-
return
|
|
8447
|
+
return listcatfiles
|
|
8340
8448
|
|
|
8341
8449
|
|
|
8342
8450
|
def PackCatFileFromListDir(infiles, outfile, dirlistfromtxt=False, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, compressionuselist=compressionlistalt, followlink=False, skipchecksum=False, checksumtype=["crc32", "crc32", "crc32"], extradata=[], formatspecs=__file_format_dict__, verbose=False, returnfp=False):
|
|
8343
|
-
outarray =
|
|
8451
|
+
outarray = MkTempFile()
|
|
8344
8452
|
packform = PackCatFile(infiles, outarray, dirlistfromtxt, fmttype, compression, compresswholefile,
|
|
8345
8453
|
compressionlevel, compressionuselist, followlink, checksumtype, extradata, formatspecs, verbose, True)
|
|
8346
|
-
|
|
8454
|
+
listcatfiles = RePackCatFile(outarray, outfile, fmttype, compression, compresswholefile,
|
|
8347
8455
|
compressionlevel, checksumtype, skipchecksum, extradata, formatspecs, verbose, returnfp)
|
|
8348
|
-
return
|
|
8456
|
+
return listcatfiles
|
|
8349
8457
|
|
|
8350
8458
|
|
|
8351
8459
|
def UnPackCatFile(infile, outdir=None, followlink=False, seekstart=0, seekend=0, skipchecksum=False, formatspecs=__file_format_multi_dict__, preservepermissions=True, preservetime=True, seektoend=False, verbose=False, returnfp=False):
|
|
@@ -8354,28 +8462,28 @@ def UnPackCatFile(infile, outdir=None, followlink=False, seekstart=0, seekend=0,
|
|
|
8354
8462
|
if(verbose):
|
|
8355
8463
|
logging.basicConfig(format="%(message)s", stream=sys.stdout, level=logging.DEBUG)
|
|
8356
8464
|
if(isinstance(infile, dict)):
|
|
8357
|
-
|
|
8465
|
+
listcatfiles = infile
|
|
8358
8466
|
else:
|
|
8359
8467
|
if(infile != "-" and not hasattr(infile, "read") and not hasattr(infile, "write") and not (sys.version_info[0] >= 3 and isinstance(infile, bytes))):
|
|
8360
8468
|
infile = RemoveWindowsPath(infile)
|
|
8361
|
-
|
|
8362
|
-
if(not
|
|
8469
|
+
listcatfiles = CatFileToArray(infile, "auto", seekstart, seekend, False, True, skipchecksum, formatspecs, seektoend, returnfp)
|
|
8470
|
+
if(not listcatfiles):
|
|
8363
8471
|
return False
|
|
8364
|
-
lenlist = len(
|
|
8365
|
-
fnumfiles = int(
|
|
8472
|
+
lenlist = len(listcatfiles['ffilelist'])
|
|
8473
|
+
fnumfiles = int(listcatfiles['fnumfiles'])
|
|
8366
8474
|
lcfi = 0
|
|
8367
|
-
lcfx = int(
|
|
8368
|
-
if(lenlist >
|
|
8475
|
+
lcfx = int(listcatfiles['fnumfiles'])
|
|
8476
|
+
if(lenlist > listcatfiles['fnumfiles'] or lenlist < listcatfiles['fnumfiles']):
|
|
8369
8477
|
lcfx = int(lenlist)
|
|
8370
8478
|
else:
|
|
8371
|
-
lcfx = int(
|
|
8479
|
+
lcfx = int(listcatfiles['fnumfiles'])
|
|
8372
8480
|
while(lcfi < lcfx):
|
|
8373
8481
|
funame = ""
|
|
8374
8482
|
try:
|
|
8375
8483
|
import pwd
|
|
8376
8484
|
try:
|
|
8377
8485
|
userinfo = pwd.getpwuid(
|
|
8378
|
-
|
|
8486
|
+
listcatfiles['ffilelist'][lcfi]['fuid'])
|
|
8379
8487
|
funame = userinfo.pw_name
|
|
8380
8488
|
except KeyError:
|
|
8381
8489
|
funame = ""
|
|
@@ -8386,7 +8494,7 @@ def UnPackCatFile(infile, outdir=None, followlink=False, seekstart=0, seekend=0,
|
|
|
8386
8494
|
import grp
|
|
8387
8495
|
try:
|
|
8388
8496
|
groupinfo = grp.getgrgid(
|
|
8389
|
-
|
|
8497
|
+
listcatfiles['ffilelist'][lcfi]['fgid'])
|
|
8390
8498
|
fgname = groupinfo.gr_name
|
|
8391
8499
|
except KeyError:
|
|
8392
8500
|
fgname = ""
|
|
@@ -8394,15 +8502,15 @@ def UnPackCatFile(infile, outdir=None, followlink=False, seekstart=0, seekend=0,
|
|
|
8394
8502
|
fgname = ""
|
|
8395
8503
|
if(verbose):
|
|
8396
8504
|
VerbosePrintOut(PrependPath(
|
|
8397
|
-
outdir,
|
|
8398
|
-
if(
|
|
8399
|
-
with open(PrependPath(outdir,
|
|
8400
|
-
if(not
|
|
8401
|
-
|
|
8402
|
-
|
|
8403
|
-
|
|
8505
|
+
outdir, listcatfiles['ffilelist'][lcfi]['fname']))
|
|
8506
|
+
if(listcatfiles['ffilelist'][lcfi]['ftype'] == 0 or listcatfiles['ffilelist'][lcfi]['ftype'] == 7):
|
|
8507
|
+
with open(PrependPath(outdir, listcatfiles['ffilelist'][lcfi]['fname']), "wb") as fpc:
|
|
8508
|
+
if(not listcatfiles['ffilelist'][lcfi]['fcontentasfile']):
|
|
8509
|
+
listcatfiles['ffilelist'][lcfi]['fcontents'] = MkTempFile(
|
|
8510
|
+
listcatfiles['ffilelist'][lcfi]['fcontents'])
|
|
8511
|
+
listcatfiles['ffilelist'][lcfi]['fcontents'].seek(0, 0)
|
|
8404
8512
|
shutil.copyfileobj(
|
|
8405
|
-
|
|
8513
|
+
listcatfiles['ffilelist'][lcfi]['fcontents'], fpc)
|
|
8406
8514
|
try:
|
|
8407
8515
|
fpc.flush()
|
|
8408
8516
|
if(hasattr(os, "sync")):
|
|
@@ -8413,20 +8521,20 @@ def UnPackCatFile(infile, outdir=None, followlink=False, seekstart=0, seekend=0,
|
|
|
8413
8521
|
pass
|
|
8414
8522
|
except OSError:
|
|
8415
8523
|
pass
|
|
8416
|
-
if(hasattr(os, "chown") and funame ==
|
|
8417
|
-
os.chown(PrependPath(outdir,
|
|
8418
|
-
|
|
8524
|
+
if(hasattr(os, "chown") and funame == listcatfiles['ffilelist'][lcfi]['funame'] and fgname == listcatfiles['ffilelist'][lcfi]['fgname'] and preservepermissions):
|
|
8525
|
+
os.chown(PrependPath(outdir, listcatfiles['ffilelist'][lcfi]['fname']),
|
|
8526
|
+
listcatfiles['ffilelist'][lcfi]['fuid'], listcatfiles['ffilelist'][lcfi]['fgid'])
|
|
8419
8527
|
if(preservepermissions):
|
|
8420
8528
|
os.chmod(PrependPath(
|
|
8421
|
-
outdir,
|
|
8529
|
+
outdir, listcatfiles['ffilelist'][lcfi]['fname']), listcatfiles['ffilelist'][lcfi]['fchmode'])
|
|
8422
8530
|
if(preservetime):
|
|
8423
|
-
os.utime(PrependPath(outdir,
|
|
8424
|
-
|
|
8425
|
-
if(
|
|
8531
|
+
os.utime(PrependPath(outdir, listcatfiles['ffilelist'][lcfi]['fname']), (
|
|
8532
|
+
listcatfiles['ffilelist'][lcfi]['fatime'], listcatfiles['ffilelist'][lcfi]['fmtime']))
|
|
8533
|
+
if(listcatfiles['ffilelist'][lcfi]['ftype'] == 1):
|
|
8426
8534
|
if(followlink):
|
|
8427
|
-
getflinkpath =
|
|
8428
|
-
flinkid =
|
|
8429
|
-
flinkinfo =
|
|
8535
|
+
getflinkpath = listcatfiles['ffilelist'][lcfi]['flinkname']
|
|
8536
|
+
flinkid = prelistcatfiles['filetoid'][getflinkpath]
|
|
8537
|
+
flinkinfo = listcatfiles['ffilelist'][flinkid]
|
|
8430
8538
|
funame = ""
|
|
8431
8539
|
try:
|
|
8432
8540
|
import pwd
|
|
@@ -8448,9 +8556,9 @@ def UnPackCatFile(infile, outdir=None, followlink=False, seekstart=0, seekend=0,
|
|
|
8448
8556
|
except ImportError:
|
|
8449
8557
|
fgname = ""
|
|
8450
8558
|
if(flinkinfo['ftype'] == 0 or flinkinfo['ftype'] == 7):
|
|
8451
|
-
with open(PrependPath(outdir,
|
|
8559
|
+
with open(PrependPath(outdir, listcatfiles['ffilelist'][lcfi]['fname']), "wb") as fpc:
|
|
8452
8560
|
if(not flinkinfo['fcontentasfile']):
|
|
8453
|
-
flinkinfo['fcontents'] =
|
|
8561
|
+
flinkinfo['fcontents'] = MkTempFile(
|
|
8454
8562
|
flinkinfo['fcontents'])
|
|
8455
8563
|
flinkinfo['fcontents'].seek(0, 0)
|
|
8456
8564
|
shutil.copyfileobj(flinkinfo['fcontents'], fpc)
|
|
@@ -8466,46 +8574,46 @@ def UnPackCatFile(infile, outdir=None, followlink=False, seekstart=0, seekend=0,
|
|
|
8466
8574
|
pass
|
|
8467
8575
|
if(hasattr(os, "chown") and funame == flinkinfo['funame'] and fgname == flinkinfo['fgname'] and preservepermissions):
|
|
8468
8576
|
os.chown(PrependPath(
|
|
8469
|
-
outdir,
|
|
8577
|
+
outdir, listcatfiles['ffilelist'][lcfi]['fname']), flinkinfo['fuid'], flinkinfo['fgid'])
|
|
8470
8578
|
if(preservepermissions):
|
|
8471
8579
|
os.chmod(PrependPath(
|
|
8472
|
-
outdir,
|
|
8580
|
+
outdir, listcatfiles['ffilelist'][lcfi]['fname']), flinkinfo['fchmode'])
|
|
8473
8581
|
if(preservetime):
|
|
8474
|
-
os.utime(PrependPath(outdir,
|
|
8582
|
+
os.utime(PrependPath(outdir, listcatfiles['ffilelist'][lcfi]['fname']), (
|
|
8475
8583
|
flinkinfo['fatime'], flinkinfo['fmtime']))
|
|
8476
8584
|
if(flinkinfo['ftype'] == 1):
|
|
8477
8585
|
os.link(flinkinfo['flinkname'], PrependPath(
|
|
8478
|
-
outdir,
|
|
8586
|
+
outdir, listcatfiles['ffilelist'][lcfi]['fname']))
|
|
8479
8587
|
if(flinkinfo['ftype'] == 2):
|
|
8480
8588
|
os.symlink(flinkinfo['flinkname'], PrependPath(
|
|
8481
|
-
outdir,
|
|
8589
|
+
outdir, listcatfiles['ffilelist'][lcfi]['fname']))
|
|
8482
8590
|
if(flinkinfo['ftype'] == 5):
|
|
8483
8591
|
if(preservepermissions):
|
|
8484
8592
|
os.mkdir(PrependPath(
|
|
8485
|
-
outdir,
|
|
8593
|
+
outdir, listcatfiles['ffilelist'][lcfi]['fname']), flinkinfo['fchmode'])
|
|
8486
8594
|
else:
|
|
8487
8595
|
os.mkdir(PrependPath(
|
|
8488
|
-
outdir,
|
|
8596
|
+
outdir, listcatfiles['ffilelist'][lcfi]['fname']))
|
|
8489
8597
|
if(hasattr(os, "chown") and funame == flinkinfo['funame'] and fgname == flinkinfo['fgname'] and preservepermissions):
|
|
8490
8598
|
os.chown(PrependPath(
|
|
8491
|
-
outdir,
|
|
8599
|
+
outdir, listcatfiles['ffilelist'][lcfi]['fname']), flinkinfo['fuid'], flinkinfo['fgid'])
|
|
8492
8600
|
if(preservepermissions):
|
|
8493
8601
|
os.chmod(PrependPath(
|
|
8494
|
-
outdir,
|
|
8602
|
+
outdir, listcatfiles['ffilelist'][lcfi]['fname']), flinkinfo['fchmode'])
|
|
8495
8603
|
if(preservetime):
|
|
8496
|
-
os.utime(PrependPath(outdir,
|
|
8604
|
+
os.utime(PrependPath(outdir, listcatfiles['ffilelist'][lcfi]['fname']), (
|
|
8497
8605
|
flinkinfo['fatime'], flinkinfo['fmtime']))
|
|
8498
8606
|
if(flinkinfo['ftype'] == 6 and hasattr(os, "mkfifo")):
|
|
8499
8607
|
os.mkfifo(PrependPath(
|
|
8500
|
-
outdir,
|
|
8608
|
+
outdir, listcatfiles['ffilelist'][lcfi]['fname']), flinkinfo['fchmode'])
|
|
8501
8609
|
else:
|
|
8502
|
-
os.link(
|
|
8503
|
-
outdir,
|
|
8504
|
-
if(
|
|
8610
|
+
os.link(listcatfiles['ffilelist'][lcfi]['flinkname'], PrependPath(
|
|
8611
|
+
outdir, listcatfiles['ffilelist'][lcfi]['fname']))
|
|
8612
|
+
if(listcatfiles['ffilelist'][lcfi]['ftype'] == 2):
|
|
8505
8613
|
if(followlink):
|
|
8506
|
-
getflinkpath =
|
|
8507
|
-
flinkid =
|
|
8508
|
-
flinkinfo =
|
|
8614
|
+
getflinkpath = listcatfiles['ffilelist'][lcfi]['flinkname']
|
|
8615
|
+
flinkid = prelistcatfiles['filetoid'][getflinkpath]
|
|
8616
|
+
flinkinfo = listcatfiles['ffilelist'][flinkid]
|
|
8509
8617
|
funame = ""
|
|
8510
8618
|
try:
|
|
8511
8619
|
import pwd
|
|
@@ -8527,9 +8635,9 @@ def UnPackCatFile(infile, outdir=None, followlink=False, seekstart=0, seekend=0,
|
|
|
8527
8635
|
except ImportError:
|
|
8528
8636
|
fgname = ""
|
|
8529
8637
|
if(flinkinfo['ftype'] == 0 or flinkinfo['ftype'] == 7):
|
|
8530
|
-
with open(PrependPath(outdir,
|
|
8638
|
+
with open(PrependPath(outdir, listcatfiles['ffilelist'][lcfi]['fname']), "wb") as fpc:
|
|
8531
8639
|
if(not flinkinfo['fcontentasfile']):
|
|
8532
|
-
flinkinfo['fcontents'] =
|
|
8640
|
+
flinkinfo['fcontents'] = MkTempFile(
|
|
8533
8641
|
flinkinfo['fcontents'])
|
|
8534
8642
|
flinkinfo['fcontents'].seek(0, 0)
|
|
8535
8643
|
shutil.copyfileobj(flinkinfo['fcontents'], fpc)
|
|
@@ -8545,71 +8653,71 @@ def UnPackCatFile(infile, outdir=None, followlink=False, seekstart=0, seekend=0,
|
|
|
8545
8653
|
pass
|
|
8546
8654
|
if(hasattr(os, "chown") and funame == flinkinfo['funame'] and fgname == flinkinfo['fgname'] and preservepermissions):
|
|
8547
8655
|
os.chown(PrependPath(
|
|
8548
|
-
outdir,
|
|
8656
|
+
outdir, listcatfiles['ffilelist'][lcfi]['fname']), flinkinfo['fuid'], flinkinfo['fgid'])
|
|
8549
8657
|
if(preservepermissions):
|
|
8550
8658
|
os.chmod(PrependPath(
|
|
8551
|
-
outdir,
|
|
8659
|
+
outdir, listcatfiles['ffilelist'][lcfi]['fname']), flinkinfo['fchmode'])
|
|
8552
8660
|
if(preservetime):
|
|
8553
|
-
os.utime(PrependPath(outdir,
|
|
8661
|
+
os.utime(PrependPath(outdir, listcatfiles['ffilelist'][lcfi]['fname']), (
|
|
8554
8662
|
flinkinfo['fatime'], flinkinfo['fmtime']))
|
|
8555
8663
|
if(flinkinfo['ftype'] == 1):
|
|
8556
8664
|
os.link(flinkinfo['flinkname'], PrependPath(
|
|
8557
|
-
outdir,
|
|
8665
|
+
outdir, listcatfiles['ffilelist'][lcfi]['fname']))
|
|
8558
8666
|
if(flinkinfo['ftype'] == 2):
|
|
8559
8667
|
os.symlink(flinkinfo['flinkname'], PrependPath(
|
|
8560
|
-
outdir,
|
|
8668
|
+
outdir, listcatfiles['ffilelist'][lcfi]['fname']))
|
|
8561
8669
|
if(flinkinfo['ftype'] == 5):
|
|
8562
8670
|
if(preservepermissions):
|
|
8563
8671
|
os.mkdir(PrependPath(
|
|
8564
|
-
outdir,
|
|
8672
|
+
outdir, listcatfiles['ffilelist'][lcfi]['fname']), flinkinfo['fchmode'])
|
|
8565
8673
|
else:
|
|
8566
8674
|
os.mkdir(PrependPath(
|
|
8567
|
-
outdir,
|
|
8675
|
+
outdir, listcatfiles['ffilelist'][lcfi]['fname']))
|
|
8568
8676
|
if(hasattr(os, "chown") and funame == flinkinfo['funame'] and fgname == flinkinfo['fgname'] and preservepermissions):
|
|
8569
8677
|
os.chown(PrependPath(
|
|
8570
|
-
outdir,
|
|
8678
|
+
outdir, listcatfiles['ffilelist'][lcfi]['fname']), flinkinfo['fuid'], flinkinfo['fgid'])
|
|
8571
8679
|
if(preservepermissions):
|
|
8572
8680
|
os.chmod(PrependPath(
|
|
8573
|
-
outdir,
|
|
8681
|
+
outdir, listcatfiles['ffilelist'][lcfi]['fname']), flinkinfo['fchmode'])
|
|
8574
8682
|
if(preservetime):
|
|
8575
|
-
os.utime(PrependPath(outdir,
|
|
8683
|
+
os.utime(PrependPath(outdir, listcatfiles['ffilelist'][lcfi]['fname']), (
|
|
8576
8684
|
flinkinfo['fatime'], flinkinfo['fmtime']))
|
|
8577
8685
|
if(flinkinfo['ftype'] == 6 and hasattr(os, "mkfifo")):
|
|
8578
8686
|
os.mkfifo(PrependPath(
|
|
8579
|
-
outdir,
|
|
8687
|
+
outdir, listcatfiles['ffilelist'][lcfi]['fname']), flinkinfo['fchmode'])
|
|
8580
8688
|
else:
|
|
8581
|
-
os.symlink(
|
|
8582
|
-
outdir,
|
|
8583
|
-
if(
|
|
8689
|
+
os.symlink(listcatfiles['ffilelist'][lcfi]['flinkname'], PrependPath(
|
|
8690
|
+
outdir, listcatfiles['ffilelist'][lcfi]['fname']))
|
|
8691
|
+
if(listcatfiles['ffilelist'][lcfi]['ftype'] == 5):
|
|
8584
8692
|
if(preservepermissions):
|
|
8585
8693
|
os.mkdir(PrependPath(
|
|
8586
|
-
outdir,
|
|
8694
|
+
outdir, listcatfiles['ffilelist'][lcfi]['fname']), listcatfiles['ffilelist'][lcfi]['fchmode'])
|
|
8587
8695
|
else:
|
|
8588
8696
|
os.mkdir(PrependPath(
|
|
8589
|
-
outdir,
|
|
8590
|
-
if(hasattr(os, "chown") and funame ==
|
|
8591
|
-
os.chown(PrependPath(outdir,
|
|
8592
|
-
|
|
8697
|
+
outdir, listcatfiles['ffilelist'][lcfi]['fname']))
|
|
8698
|
+
if(hasattr(os, "chown") and funame == listcatfiles['ffilelist'][lcfi]['funame'] and fgname == listcatfiles['ffilelist'][lcfi]['fgname'] and preservepermissions):
|
|
8699
|
+
os.chown(PrependPath(outdir, listcatfiles['ffilelist'][lcfi]['fname']),
|
|
8700
|
+
listcatfiles['ffilelist'][lcfi]['fuid'], listcatfiles['ffilelist'][lcfi]['fgid'])
|
|
8593
8701
|
if(preservepermissions):
|
|
8594
8702
|
os.chmod(PrependPath(
|
|
8595
|
-
outdir,
|
|
8703
|
+
outdir, listcatfiles['ffilelist'][lcfi]['fname']), listcatfiles['ffilelist'][lcfi]['fchmode'])
|
|
8596
8704
|
if(preservetime):
|
|
8597
|
-
os.utime(PrependPath(outdir,
|
|
8598
|
-
|
|
8599
|
-
if(
|
|
8705
|
+
os.utime(PrependPath(outdir, listcatfiles['ffilelist'][lcfi]['fname']), (
|
|
8706
|
+
listcatfiles['ffilelist'][lcfi]['fatime'], listcatfiles['ffilelist'][lcfi]['fmtime']))
|
|
8707
|
+
if(listcatfiles['ffilelist'][lcfi]['ftype'] == 6 and hasattr(os, "mkfifo")):
|
|
8600
8708
|
os.mkfifo(PrependPath(
|
|
8601
|
-
outdir,
|
|
8709
|
+
outdir, listcatfiles['ffilelist'][lcfi]['fname']), listcatfiles['ffilelist'][lcfi]['fchmode'])
|
|
8602
8710
|
lcfi = lcfi + 1
|
|
8603
8711
|
if(returnfp):
|
|
8604
|
-
return
|
|
8712
|
+
return listcatfiles['ffilelist']['fp']
|
|
8605
8713
|
else:
|
|
8606
8714
|
return True
|
|
8607
8715
|
|
|
8608
8716
|
|
|
8609
8717
|
def UnPackCatFileString(instr, outdir=None, followlink=False, seekstart=0, seekend=0, skipchecksum=False, formatspecs=__file_format_multi_dict__, seektoend=False, verbose=False, returnfp=False):
|
|
8610
|
-
fp =
|
|
8611
|
-
|
|
8612
|
-
return
|
|
8718
|
+
fp = MkTempFile(instr)
|
|
8719
|
+
listcatfiles = UnPackCatFile(fp, outdir, followlink, seekstart, seekend, skipchecksum, formatspecs, seektoend, verbose, returnfp)
|
|
8720
|
+
return listcatfiles
|
|
8613
8721
|
|
|
8614
8722
|
def ftype_to_str(ftype):
|
|
8615
8723
|
mapping = {
|
|
@@ -8630,67 +8738,67 @@ def CatFileListFiles(infile, fmttype="auto", seekstart=0, seekend=0, skipchecksu
|
|
|
8630
8738
|
if(verbose):
|
|
8631
8739
|
logging.basicConfig(format="%(message)s", stream=sys.stdout, level=logging.DEBUG)
|
|
8632
8740
|
if(isinstance(infile, dict)):
|
|
8633
|
-
|
|
8741
|
+
listcatfiles = infile
|
|
8634
8742
|
else:
|
|
8635
8743
|
if(infile != "-" and not hasattr(infile, "read") and not hasattr(infile, "write") and not (sys.version_info[0] >= 3 and isinstance(infile, bytes))):
|
|
8636
8744
|
infile = RemoveWindowsPath(infile)
|
|
8637
|
-
|
|
8638
|
-
if(not
|
|
8745
|
+
listcatfiles = CatFileToArray(infile, fmttype, seekstart, seekend, True, False, False, skipchecksum, formatspecs, seektoend, returnfp)
|
|
8746
|
+
if(not listcatfiles):
|
|
8639
8747
|
return False
|
|
8640
|
-
lenlist = len(
|
|
8641
|
-
fnumfiles = int(
|
|
8748
|
+
lenlist = len(listcatfiles['ffilelist'])
|
|
8749
|
+
fnumfiles = int(listcatfiles['fnumfiles'])
|
|
8642
8750
|
lcfi = 0
|
|
8643
|
-
lcfx = int(
|
|
8644
|
-
if(lenlist >
|
|
8751
|
+
lcfx = int(listcatfiles['fnumfiles'])
|
|
8752
|
+
if(lenlist > listcatfiles['fnumfiles'] or lenlist < listcatfiles['fnumfiles']):
|
|
8645
8753
|
lcfx = int(lenlist)
|
|
8646
8754
|
else:
|
|
8647
|
-
lcfx = int(
|
|
8755
|
+
lcfx = int(listcatfiles['fnumfiles'])
|
|
8648
8756
|
returnval = {}
|
|
8649
8757
|
while(lcfi < lcfx):
|
|
8650
|
-
returnval.update({lcfi:
|
|
8758
|
+
returnval.update({lcfi: listcatfiles['ffilelist'][lcfi]['fname']})
|
|
8651
8759
|
if(not verbose):
|
|
8652
|
-
VerbosePrintOut(
|
|
8760
|
+
VerbosePrintOut(listcatfiles['ffilelist'][lcfi]['fname'])
|
|
8653
8761
|
if(verbose):
|
|
8654
8762
|
permissions = {'access': {'0': ('---'), '1': ('--x'), '2': ('-w-'), '3': ('-wx'), '4': (
|
|
8655
8763
|
'r--'), '5': ('r-x'), '6': ('rw-'), '7': ('rwx')}, 'roles': {0: 'owner', 1: 'group', 2: 'other'}}
|
|
8656
|
-
printfname =
|
|
8657
|
-
if(
|
|
8658
|
-
printfname =
|
|
8659
|
-
" link to " +
|
|
8660
|
-
if(
|
|
8661
|
-
printfname =
|
|
8662
|
-
" -> " +
|
|
8663
|
-
fuprint =
|
|
8764
|
+
printfname = listcatfiles['ffilelist'][lcfi]['fname']
|
|
8765
|
+
if(listcatfiles['ffilelist'][lcfi]['ftype'] == 1):
|
|
8766
|
+
printfname = listcatfiles['ffilelist'][lcfi]['fname'] + \
|
|
8767
|
+
" link to " + listcatfiles['ffilelist'][lcfi]['flinkname']
|
|
8768
|
+
if(listcatfiles['ffilelist'][lcfi]['ftype'] == 2):
|
|
8769
|
+
printfname = listcatfiles['ffilelist'][lcfi]['fname'] + \
|
|
8770
|
+
" -> " + listcatfiles['ffilelist'][lcfi]['flinkname']
|
|
8771
|
+
fuprint = listcatfiles['ffilelist'][lcfi]['funame']
|
|
8664
8772
|
if(len(fuprint) <= 0):
|
|
8665
|
-
fuprint =
|
|
8666
|
-
fgprint =
|
|
8773
|
+
fuprint = listcatfiles['ffilelist'][lcfi]['fuid']
|
|
8774
|
+
fgprint = listcatfiles['ffilelist'][lcfi]['fgname']
|
|
8667
8775
|
if(len(fgprint) <= 0):
|
|
8668
|
-
fgprint =
|
|
8776
|
+
fgprint = listcatfiles['ffilelist'][lcfi]['fgid']
|
|
8669
8777
|
if(newstyle):
|
|
8670
|
-
VerbosePrintOut(ftype_to_str(
|
|
8671
|
-
|
|
8778
|
+
VerbosePrintOut(ftype_to_str(listcatfiles['ffilelist'][lcfi]['ftype']) + "\t" + listcatfiles['ffilelist'][lcfi]['fcompression'] + "\t" + str(
|
|
8779
|
+
listcatfiles['ffilelist'][lcfi]['fsize']).rjust(15) + "\t" + printfname)
|
|
8672
8780
|
else:
|
|
8673
|
-
VerbosePrintOut(PrintPermissionString(
|
|
8674
|
-
|
|
8781
|
+
VerbosePrintOut(PrintPermissionString(listcatfiles['ffilelist'][lcfi]['fmode'], listcatfiles['ffilelist'][lcfi]['ftype']) + " " + str(fuprint) + "/" + str(fgprint) + " " + str(
|
|
8782
|
+
listcatfiles['ffilelist'][lcfi]['fsize']).rjust(15) + " " + datetime.datetime.utcfromtimestamp(listcatfiles['ffilelist'][lcfi]['fmtime']).strftime('%Y-%m-%d %H:%M') + " " + printfname)
|
|
8675
8783
|
lcfi = lcfi + 1
|
|
8676
8784
|
if(returnfp):
|
|
8677
|
-
return
|
|
8785
|
+
return listcatfiles['fp']
|
|
8678
8786
|
else:
|
|
8679
8787
|
return True
|
|
8680
8788
|
|
|
8681
8789
|
|
|
8682
8790
|
def CatFileStringListFiles(instr, seekstart=0, seekend=0, skipchecksum=False, formatspecs=__file_format_multi_dict__, seektoend=False, verbose=False, newstyle=False, returnfp=False):
|
|
8683
|
-
fp =
|
|
8684
|
-
|
|
8791
|
+
fp = MkTempFile(instr)
|
|
8792
|
+
listcatfiles = CatFileListFiles(
|
|
8685
8793
|
instr, seekstart, seekend, skipchecksum, formatspecs, seektoend, verbose, newstyle, returnfp)
|
|
8686
|
-
return
|
|
8794
|
+
return listcatfiles
|
|
8687
8795
|
|
|
8688
8796
|
|
|
8689
8797
|
def TarFileListFiles(infile, verbose=False, returnfp=False):
|
|
8690
8798
|
if(verbose):
|
|
8691
8799
|
logging.basicConfig(format="%(message)s", stream=sys.stdout, level=logging.DEBUG)
|
|
8692
8800
|
if(infile == "-"):
|
|
8693
|
-
infile =
|
|
8801
|
+
infile = MkTempFile()
|
|
8694
8802
|
if(hasattr(sys.stdin, "buffer")):
|
|
8695
8803
|
shutil.copyfileobj(sys.stdin.buffer, infile)
|
|
8696
8804
|
else:
|
|
@@ -8730,7 +8838,7 @@ def TarFileListFiles(infile, verbose=False, returnfp=False):
|
|
|
8730
8838
|
if 'zstandard' in sys.modules:
|
|
8731
8839
|
infile = ZstdFile(fileobj=infile, mode="rb")
|
|
8732
8840
|
elif 'pyzstd' in sys.modules:
|
|
8733
|
-
|
|
8841
|
+
infile = pyzstd.zstdfile.ZstdFile(fileobj=infile, mode="rb")
|
|
8734
8842
|
tarfp = tarfile.open(fileobj=infile, mode="r")
|
|
8735
8843
|
else:
|
|
8736
8844
|
tarfp = tarfile.open(fileobj=infile, mode="r")
|
|
@@ -8742,7 +8850,7 @@ def TarFileListFiles(infile, verbose=False, returnfp=False):
|
|
|
8742
8850
|
if 'zstandard' in sys.modules:
|
|
8743
8851
|
infile = ZstdFile(fileobj=infile, mode="rb")
|
|
8744
8852
|
elif 'pyzstd' in sys.modules:
|
|
8745
|
-
|
|
8853
|
+
infile = pyzstd.zstdfile.ZstdFile(fileobj=infile, mode="rb")
|
|
8746
8854
|
tarfp = tarfile.open(fileobj=infile, mode="r")
|
|
8747
8855
|
else:
|
|
8748
8856
|
tarfp = tarfile.open(infile, "r")
|
|
@@ -8806,7 +8914,7 @@ def TarFileListFiles(infile, verbose=False, returnfp=False):
|
|
|
8806
8914
|
member.size).rjust(15) + " " + datetime.datetime.utcfromtimestamp(member.mtime).strftime('%Y-%m-%d %H:%M') + " " + printfname)
|
|
8807
8915
|
lcfi = lcfi + 1
|
|
8808
8916
|
if(returnfp):
|
|
8809
|
-
return
|
|
8917
|
+
return listcatfiles['fp']
|
|
8810
8918
|
else:
|
|
8811
8919
|
return True
|
|
8812
8920
|
|
|
@@ -8815,7 +8923,7 @@ def ZipFileListFiles(infile, verbose=False, returnfp=False):
|
|
|
8815
8923
|
if(verbose):
|
|
8816
8924
|
logging.basicConfig(format="%(message)s", stream=sys.stdout, level=logging.DEBUG)
|
|
8817
8925
|
if(infile == "-"):
|
|
8818
|
-
infile =
|
|
8926
|
+
infile = MkTempFile()
|
|
8819
8927
|
if(hasattr(sys.stdin, "buffer")):
|
|
8820
8928
|
shutil.copyfileobj(sys.stdin.buffer, infile)
|
|
8821
8929
|
else:
|
|
@@ -8939,7 +9047,7 @@ def ZipFileListFiles(infile, verbose=False, returnfp=False):
|
|
|
8939
9047
|
15) + " " + datetime.datetime.utcfromtimestamp(int(time.mktime(member.date_time + (0, 0, -1)))).strftime('%Y-%m-%d %H:%M') + " " + printfname)
|
|
8940
9048
|
lcfi = lcfi + 1
|
|
8941
9049
|
if(returnfp):
|
|
8942
|
-
return
|
|
9050
|
+
return listcatfiles['fp']
|
|
8943
9051
|
else:
|
|
8944
9052
|
return True
|
|
8945
9053
|
|
|
@@ -9077,7 +9185,7 @@ if(rarfile_support):
|
|
|
9077
9185
|
member.file_size).rjust(15) + " " + member.mtime.strftime('%Y-%m-%d %H:%M') + " " + printfname)
|
|
9078
9186
|
lcfi = lcfi + 1
|
|
9079
9187
|
if(returnfp):
|
|
9080
|
-
return
|
|
9188
|
+
return listcatfiles['fp']
|
|
9081
9189
|
else:
|
|
9082
9190
|
return True
|
|
9083
9191
|
|
|
@@ -9184,7 +9292,7 @@ if(py7zr_support):
|
|
|
9184
9292
|
fsize).rjust(15) + " " + member.creationtime.strftime('%Y-%m-%d %H:%M') + " " + printfname)
|
|
9185
9293
|
lcfi = lcfi + 1
|
|
9186
9294
|
if(returnfp):
|
|
9187
|
-
return
|
|
9295
|
+
return listcatfiles['fp']
|
|
9188
9296
|
else:
|
|
9189
9297
|
return True
|
|
9190
9298
|
|
|
@@ -9211,12 +9319,12 @@ def InFileListFiles(infile, verbose=False, formatspecs=__file_format_multi_dict_
|
|
|
9211
9319
|
|
|
9212
9320
|
|
|
9213
9321
|
def ListDirListFiles(infiles, dirlistfromtxt=False, compression="auto", compresswholefile=True, compressionlevel=None, followlink=False, seekstart=0, seekend=0, skipchecksum=False, checksumtype=["crc32", "crc32", "crc32"], formatspecs=__file_format_dict__, seektoend=False, verbose=False, returnfp=False):
|
|
9214
|
-
outarray =
|
|
9322
|
+
outarray = MkTempFile()
|
|
9215
9323
|
packform = PackCatFile(infiles, outarray, dirlistfromtxt, compression, compresswholefile,
|
|
9216
9324
|
compressionlevel, followlink, checksumtype, formatspecs, False, True)
|
|
9217
|
-
|
|
9325
|
+
listcatfiles = CatFileListFiles(
|
|
9218
9326
|
outarray, seekstart, seekend, skipchecksum, formatspecs, seektoend, verbose, returnfp)
|
|
9219
|
-
return
|
|
9327
|
+
return listcatfiles
|
|
9220
9328
|
|
|
9221
9329
|
"""
|
|
9222
9330
|
PyNeoFile compatibility layer
|
|
@@ -9229,32 +9337,32 @@ def make_empty_archive_file_pointer_neo(fp, fmttype=None, checksumtype='crc32',
|
|
|
9229
9337
|
return make_empty_file_pointer_neo(fp, fmttype, checksumtype, formatspecs, encoding)
|
|
9230
9338
|
|
|
9231
9339
|
def make_empty_file_neo(outfile=None, fmttype=None, checksumtype='crc32', formatspecs=__file_format_multi_dict__, encoding='UTF-8', returnfp=False):
|
|
9232
|
-
return MakeEmptyFile(outfile, fmttype, "auto", False, None, checksumtype, formatspecs, returnfp)
|
|
9340
|
+
return MakeEmptyFile(outfile, fmttype, "auto", False, None, compressionlistalt, checksumtype, formatspecs, returnfp)
|
|
9233
9341
|
|
|
9234
9342
|
def make_empty_archive_file_neo(outfile=None, fmttype=None, checksumtype='crc32', formatspecs=__file_format_multi_dict__, encoding='UTF-8', returnfp=False):
|
|
9235
9343
|
return make_empty_file_neo(outfile, fmttype, checksumtype, formatspecs, encoding, returnfp)
|
|
9236
9344
|
|
|
9237
9345
|
def pack_neo(infiles, outfile=None, formatspecs=__file_format_multi_dict__, checksumtypes=["crc32", "crc32", "crc32", "crc32"], encoding="UTF-8", compression="auto", compression_level=None, returnfp=False):
|
|
9238
|
-
return
|
|
9346
|
+
return PackArchiveFile(infiles, outfile, False, "auto", compression, False, compression_level, compressionlistalt, False, checksumtypes, [], {}, formatspecs, False, returnfp)
|
|
9239
9347
|
|
|
9240
9348
|
def archive_to_array_neo(infile, formatspecs=__file_format_multi_dict__, listonly=False, skipchecksum=False, uncompress=True, returnfp=False):
|
|
9241
|
-
return
|
|
9349
|
+
return ArchiveFileToArray(infile, "auto", 0, 0, listonly, True, uncompress, skipchecksum, formatspecs, False, returnfp)
|
|
9242
9350
|
|
|
9243
9351
|
def unpack_neo(infile, outdir='.', formatspecs=__file_format_multi_dict__, skipchecksum=False, uncompress=True, returnfp=False):
|
|
9244
|
-
return
|
|
9352
|
+
return UnPackArchiveFile(infile, outdir, False, 0, 0, skipchecksum, formatspecs, True, True, False, False, returnfp)
|
|
9245
9353
|
|
|
9246
9354
|
def repack_neo(infile, outfile=None, formatspecs=__file_format_dict__, checksumtypes=["crc32", "crc32", "crc32", "crc32"], compression="auto", compression_level=None, returnfp=False):
|
|
9247
|
-
return
|
|
9355
|
+
return RePackArchiveFile(infile, outfile, "auto", compression, False, compression_level, compressionlistalt, False, 0, 0, checksumtypes, False, [], {}, formatspecs, False, False, returnfp)
|
|
9248
9356
|
|
|
9249
9357
|
def archivefilevalidate_neo(infile, formatspecs=__file_format_multi_dict__, verbose=False, return_details=False, returnfp=False):
|
|
9250
|
-
return
|
|
9358
|
+
return ArchiveFileValidate(infile, "auto", formatspecs, False, verbose, returnfp)
|
|
9251
9359
|
|
|
9252
9360
|
def archivefilelistfiles_neo(infile, formatspecs=__file_format_multi_dict__, advanced=False, include_dirs=True, returnfp=False):
|
|
9253
|
-
return
|
|
9361
|
+
return ArchiveFileListFiles(infile, "auto", 0, 0, False, formatspecs, False, True, advanced, returnfp)
|
|
9254
9362
|
|
|
9255
9363
|
def convert_foreign_to_neo(infile, outfile=None, formatspecs=__file_format_multi_dict__, checksumtypes=["crc32", "crc32", "crc32", "crc32"], compression="auto", compression_level=None, returnfp=False):
|
|
9256
9364
|
intmp = InFileToArray(infile, 0, 0, False, True, False, formatspecs, False, False)
|
|
9257
|
-
return
|
|
9365
|
+
return RePackArchiveFile(intmp, outfile, "auto", compression, False, compression_level, compressionlistalt, False, 0, 0, checksumtypes, False, [], {}, formatspecs, False, False, returnfp)
|
|
9258
9366
|
|
|
9259
9367
|
def download_file_from_ftp_file(url):
|
|
9260
9368
|
urlparts = urlparse(url)
|
|
@@ -9297,7 +9405,7 @@ def download_file_from_ftp_file(url):
|
|
|
9297
9405
|
ftp.login(urlparts.username, urlparts.password)
|
|
9298
9406
|
if(urlparts.scheme == "ftps"):
|
|
9299
9407
|
ftp.prot_p()
|
|
9300
|
-
ftpfile =
|
|
9408
|
+
ftpfile = MkTempFile()
|
|
9301
9409
|
ftp.retrbinary("RETR "+urlparts.path, ftpfile.write)
|
|
9302
9410
|
#ftp.storbinary("STOR "+urlparts.path, ftpfile.write);
|
|
9303
9411
|
ftp.close()
|
|
@@ -9358,7 +9466,7 @@ def upload_file_to_ftp_file(ftpfile, url):
|
|
|
9358
9466
|
|
|
9359
9467
|
|
|
9360
9468
|
def upload_file_to_ftp_string(ftpstring, url):
|
|
9361
|
-
ftpfileo =
|
|
9469
|
+
ftpfileo = MkTempFile(ftpstring)
|
|
9362
9470
|
ftpfile = upload_file_to_ftp_file(ftpfileo, url)
|
|
9363
9471
|
ftpfileo.close()
|
|
9364
9472
|
return ftpfile
|
|
@@ -9410,7 +9518,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__):
|
|
|
9410
9518
|
return download_file_from_ftp_file(url)
|
|
9411
9519
|
|
|
9412
9520
|
# Create a temporary file object
|
|
9413
|
-
httpfile =
|
|
9521
|
+
httpfile = MkTempFile()
|
|
9414
9522
|
|
|
9415
9523
|
# 1) Requests branch
|
|
9416
9524
|
if usehttp == 'requests' and haverequests:
|
|
@@ -9518,7 +9626,7 @@ if(haveparamiko):
|
|
|
9518
9626
|
log.info("Error With URL "+url)
|
|
9519
9627
|
return False
|
|
9520
9628
|
sftp = ssh.open_sftp()
|
|
9521
|
-
sftpfile =
|
|
9629
|
+
sftpfile = MkTempFile()
|
|
9522
9630
|
sftp.getfo(urlparts.path, sftpfile)
|
|
9523
9631
|
sftp.close()
|
|
9524
9632
|
ssh.close()
|
|
@@ -9588,7 +9696,7 @@ else:
|
|
|
9588
9696
|
|
|
9589
9697
|
if(haveparamiko):
|
|
9590
9698
|
def upload_file_to_sftp_string(sftpstring, url):
|
|
9591
|
-
sftpfileo =
|
|
9699
|
+
sftpfileo = MkTempFile(sftpstring)
|
|
9592
9700
|
sftpfile = upload_file_to_sftp_files(sftpfileo, url)
|
|
9593
9701
|
sftpfileo.close()
|
|
9594
9702
|
return sftpfile
|
|
@@ -9634,7 +9742,7 @@ if(havepysftp):
|
|
|
9634
9742
|
log.info("Error With URL "+url)
|
|
9635
9743
|
return False
|
|
9636
9744
|
sftp = ssh.open_sftp()
|
|
9637
|
-
sftpfile =
|
|
9745
|
+
sftpfile = MkTempFile()
|
|
9638
9746
|
sftp.getfo(urlparts.path, sftpfile)
|
|
9639
9747
|
sftp.close()
|
|
9640
9748
|
ssh.close()
|
|
@@ -9701,7 +9809,7 @@ else:
|
|
|
9701
9809
|
|
|
9702
9810
|
if(havepysftp):
|
|
9703
9811
|
def upload_file_to_pysftp_string(sftpstring, url):
|
|
9704
|
-
sftpfileo =
|
|
9812
|
+
sftpfileo = MkTempFile(sftpstring)
|
|
9705
9813
|
sftpfile = upload_file_to_pysftp_file(ftpfileo, url)
|
|
9706
9814
|
sftpfileo.close()
|
|
9707
9815
|
return sftpfile
|
|
@@ -9776,10 +9884,10 @@ def upload_file_to_internet_file(ifp, url):
|
|
|
9776
9884
|
return False
|
|
9777
9885
|
|
|
9778
9886
|
|
|
9779
|
-
def upload_file_to_internet_compress_file(ifp, url, compression="auto", compressionlevel=None, formatspecs=__file_format_dict__):
|
|
9887
|
+
def upload_file_to_internet_compress_file(ifp, url, compression="auto", compressionlevel=None, compressionuselist=compressionlistalt, formatspecs=__file_format_dict__):
|
|
9780
9888
|
fp = CompressOpenFileAlt(
|
|
9781
|
-
fp, compression, compressionlevel, formatspecs)
|
|
9782
|
-
if(not
|
|
9889
|
+
fp, compression, compressionlevel, compressionuselist, formatspecs)
|
|
9890
|
+
if(not catfileout):
|
|
9783
9891
|
return False
|
|
9784
9892
|
fp.seek(0, 0)
|
|
9785
9893
|
upload_file_to_internet_file(fp, outfile)
|
|
@@ -9802,10 +9910,11 @@ def upload_file_to_internet_string(ifp, url):
|
|
|
9802
9910
|
return False
|
|
9803
9911
|
|
|
9804
9912
|
|
|
9805
|
-
def upload_file_to_internet_compress_string(ifp, url, compression="auto", compressionlevel=None, formatspecs=__file_format_dict__):
|
|
9913
|
+
def upload_file_to_internet_compress_string(ifp, url, compression="auto", compressionlevel=None, compressionuselist=compressionlistalt, formatspecs=__file_format_dict__):
|
|
9914
|
+
internetfileo = MkTempFile(ifp)
|
|
9806
9915
|
fp = CompressOpenFileAlt(
|
|
9807
|
-
|
|
9808
|
-
if(not
|
|
9916
|
+
internetfileo, compression, compressionlevel, compressionuselist, formatspecs)
|
|
9917
|
+
if(not catfileout):
|
|
9809
9918
|
return False
|
|
9810
9919
|
fp.seek(0, 0)
|
|
9811
9920
|
upload_file_to_internet_file(fp, outfile)
|