PyCatFile 0.15.8__tar.gz → 0.15.14__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pycatfile-0.15.8 → pycatfile-0.15.14}/PKG-INFO +1 -1
- {pycatfile-0.15.8 → pycatfile-0.15.14}/PyCatFile.egg-info/PKG-INFO +1 -1
- {pycatfile-0.15.8 → pycatfile-0.15.14}/catfile.py +26 -25
- {pycatfile-0.15.8 → pycatfile-0.15.14}/neocatfile.py +37 -17
- {pycatfile-0.15.8 → pycatfile-0.15.14}/pycatfile.py +210 -90
- {pycatfile-0.15.8 → pycatfile-0.15.14}/setup.py +1 -1
- {pycatfile-0.15.8 → pycatfile-0.15.14}/LICENSE +0 -0
- {pycatfile-0.15.8 → pycatfile-0.15.14}/PyCatFile.egg-info/SOURCES.txt +0 -0
- {pycatfile-0.15.8 → pycatfile-0.15.14}/PyCatFile.egg-info/dependency_links.txt +0 -0
- {pycatfile-0.15.8 → pycatfile-0.15.14}/PyCatFile.egg-info/top_level.txt +0 -0
- {pycatfile-0.15.8 → pycatfile-0.15.14}/PyCatFile.egg-info/zip-safe +0 -0
- {pycatfile-0.15.8 → pycatfile-0.15.14}/README.md +0 -0
- {pycatfile-0.15.8 → pycatfile-0.15.14}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PyCatFile
|
|
3
|
-
Version: 0.15.
|
|
3
|
+
Version: 0.15.14
|
|
4
4
|
Summary: A tar like file format name catfile after unix cat command (concatenate files) .
|
|
5
5
|
Home-page: https://github.com/GameMaker2k/PyCatFile
|
|
6
6
|
Download-URL: https://github.com/GameMaker2k/PyCatFile/archive/master.tar.gz
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PyCatFile
|
|
3
|
-
Version: 0.15.
|
|
3
|
+
Version: 0.15.14
|
|
4
4
|
Summary: A tar like file format name catfile after unix cat command (concatenate files) .
|
|
5
5
|
Home-page: https://github.com/GameMaker2k/PyCatFile
|
|
6
6
|
Download-URL: https://github.com/GameMaker2k/PyCatFile/archive/master.tar.gz
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
Copyright 2018-2024 Game Maker 2k - http://intdb.sourceforge.net/
|
|
15
15
|
Copyright 2018-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
|
|
16
16
|
|
|
17
|
-
$FileInfo: catfile.py - Last Update: 12/
|
|
17
|
+
$FileInfo: catfile.py - Last Update: 12/21/2024 Ver. 0.15.14 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
|
|
@@ -98,7 +98,7 @@ argparser.add_argument("-V", "--version", action="version",
|
|
|
98
98
|
version=__program_name__ + " " + __version__)
|
|
99
99
|
# Input and output specifications
|
|
100
100
|
argparser.add_argument(
|
|
101
|
-
"-i", "--input", help="Specify the file(s) to concatenate or the concatenated file to extract.", required=True)
|
|
101
|
+
"-i", "--input", nargs="+", help="Specify the file(s) to concatenate or the concatenated file to extract.", required=True)
|
|
102
102
|
argparser.add_argument("-o", "--output", default=None,
|
|
103
103
|
help="Specify the name for the extracted or output concatenated files.")
|
|
104
104
|
# Operations
|
|
@@ -161,19 +161,20 @@ fnamedict = {'format_name': fname, 'format_magic': fnamemagic, 'format_lower': f
|
|
|
161
161
|
actions = ['create', 'extract', 'list', 'repack', 'validate']
|
|
162
162
|
active_action = next(
|
|
163
163
|
(action for action in actions if getattr(getargs, action)), None)
|
|
164
|
+
input_file = getargs.input[0]
|
|
164
165
|
|
|
165
166
|
# Execute the appropriate functions based on determined actions and arguments
|
|
166
167
|
if active_action:
|
|
167
168
|
if active_action == 'create':
|
|
168
169
|
if getargs.convert:
|
|
169
170
|
checkcompressfile = pycatfile.CheckCompressionSubType(
|
|
170
|
-
|
|
171
|
+
input_file, fnamedict, True)
|
|
171
172
|
if(checkcompressfile == "catfile"):
|
|
172
|
-
tmpout = pycatfile.RePackArchiveFile(
|
|
173
|
+
tmpout = pycatfile.RePackArchiveFile(input_file, getargs.output, getargs.compression, getargs.wholefile,
|
|
173
174
|
getargs.level, False, 0, 0, getargs.checksum, getargs.skipchecksum, [], fnamedict, getargs.verbose, False)
|
|
174
175
|
else:
|
|
175
176
|
tmpout = pycatfile.PackArchiveFileFromInFile(
|
|
176
|
-
|
|
177
|
+
input_file, getargs.output, getargs.compression, getargs.wholefile, getargs.level, getargs.checksum, [], fnamedict, getargs.verbose, False)
|
|
177
178
|
if(not tmpout):
|
|
178
179
|
sys.exit(1)
|
|
179
180
|
else:
|
|
@@ -182,72 +183,72 @@ if active_action:
|
|
|
182
183
|
elif active_action == 'repack':
|
|
183
184
|
if getargs.convert:
|
|
184
185
|
checkcompressfile = pycatfile.CheckCompressionSubType(
|
|
185
|
-
|
|
186
|
+
input_file, fnamedict, True)
|
|
186
187
|
if(checkcompressfile == "catfile"):
|
|
187
|
-
pycatfile.RePackArchiveFile(
|
|
188
|
+
pycatfile.RePackArchiveFile(input_file, getargs.output, getargs.compression, getargs.wholefile, getargs.level,
|
|
188
189
|
False, 0, 0, getargs.checksum, getargs.skipchecksum, [], fnamedict, getargs.verbose, False)
|
|
189
190
|
else:
|
|
190
|
-
pycatfile.PackArchiveFileFromInFile(
|
|
191
|
+
pycatfile.PackArchiveFileFromInFile(input_file, getargs.output, getargs.compression,
|
|
191
192
|
getargs.wholefile, getargs.level, getargs.checksum, [], fnamedict, getargs.verbose, False)
|
|
192
193
|
if(not tmpout):
|
|
193
194
|
sys.exit(1)
|
|
194
195
|
else:
|
|
195
|
-
pycatfile.RePackArchiveFile(
|
|
196
|
+
pycatfile.RePackArchiveFile(input_file, getargs.output, getargs.compression, getargs.wholefile, getargs.level,
|
|
196
197
|
False, 0, 0, getargs.checksum, getargs.skipchecksum, [], fnamedict, getargs.verbose, False)
|
|
197
198
|
elif active_action == 'extract':
|
|
198
199
|
if getargs.convert:
|
|
199
200
|
checkcompressfile = pycatfile.CheckCompressionSubType(
|
|
200
|
-
|
|
201
|
+
input_file, fnamedict, True)
|
|
201
202
|
tempout = BytesIO()
|
|
202
203
|
if(checkcompressfile == "catfile"):
|
|
203
|
-
tmpout = pycatfile.RePackArchiveFile(
|
|
204
|
+
tmpout = pycatfile.RePackArchiveFile(input_file, tempout, getargs.compression, getargs.wholefile,
|
|
204
205
|
getargs.level, False, 0, 0, getargs.checksum, getargs.skipchecksum, [], fnamedict, False, False)
|
|
205
206
|
else:
|
|
206
207
|
tmpout = pycatfile.PackArchiveFileFromInFile(
|
|
207
|
-
|
|
208
|
+
input_file, tempout, getargs.compression, getargs.wholefile, getargs.level, getargs.checksum, [], fnamedict, False, False)
|
|
208
209
|
if(not tmpout):
|
|
209
210
|
sys.exit(1)
|
|
210
|
-
|
|
211
|
-
pycatfile.UnPackArchiveFile(
|
|
211
|
+
input_file = tempout
|
|
212
|
+
pycatfile.UnPackArchiveFile(input_file, getargs.output, False, 0, 0, getargs.skipchecksum,
|
|
212
213
|
fnamedict, getargs.verbose, getargs.preserve, getargs.preserve, False)
|
|
213
214
|
elif active_action == 'list':
|
|
214
215
|
if getargs.convert:
|
|
215
216
|
checkcompressfile = pycatfile.CheckCompressionSubType(
|
|
216
|
-
|
|
217
|
+
input_file, fnamedict, True)
|
|
217
218
|
if(checkcompressfile == "catfile"):
|
|
218
219
|
tmpout = pycatfile.ArchiveFileListFiles(
|
|
219
|
-
|
|
220
|
+
input_file, 0, 0, getargs.skipchecksum, fnamedict, getargs.verbose, False)
|
|
220
221
|
else:
|
|
221
222
|
tmpout = pycatfile.InFileListFiles(
|
|
222
|
-
|
|
223
|
+
input_file, getargs.verbose, fnamedict, False)
|
|
223
224
|
if(not tmpout):
|
|
224
225
|
sys.exit(1)
|
|
225
226
|
else:
|
|
226
227
|
pycatfile.ArchiveFileListFiles(
|
|
227
|
-
|
|
228
|
+
input_file, 0, 0, getargs.skipchecksum, fnamedict, getargs.verbose, False)
|
|
228
229
|
elif active_action == 'validate':
|
|
229
230
|
if getargs.convert:
|
|
230
231
|
checkcompressfile = pycatfile.CheckCompressionSubType(
|
|
231
|
-
|
|
232
|
+
input_file, fnamedict, True)
|
|
232
233
|
tempout = BytesIO()
|
|
233
234
|
if(checkcompressfile == "catfile"):
|
|
234
|
-
tmpout = pycatfile.RePackArchiveFile(
|
|
235
|
+
tmpout = pycatfile.RePackArchiveFile(input_file, tempout, getargs.compression, getargs.wholefile,
|
|
235
236
|
getargs.level, False, 0, 0, getargs.checksum, getargs.skipchecksum, [], fnamedict, False, False)
|
|
236
237
|
else:
|
|
237
238
|
tmpout = pycatfile.PackArchiveFileFromInFile(
|
|
238
|
-
|
|
239
|
-
|
|
239
|
+
input_file, tempout, getargs.compression, getargs.wholefile, getargs.level, getargs.checksum, [], fnamedict, False, False)
|
|
240
|
+
input_file = tempout
|
|
240
241
|
if(not tmpout):
|
|
241
242
|
sys.exit(1)
|
|
242
243
|
fvalid = pycatfile.ArchiveFileValidate(
|
|
243
|
-
|
|
244
|
+
input_file, fnamedict, getargs.verbose, False)
|
|
244
245
|
if(not getargs.verbose):
|
|
245
246
|
import sys
|
|
246
247
|
import logging
|
|
247
248
|
logging.basicConfig(format="%(message)s",
|
|
248
249
|
stream=sys.stdout, level=logging.DEBUG)
|
|
249
250
|
if(fvalid):
|
|
250
|
-
pycatfile.VerbosePrintOut("File is valid: \n" + str(
|
|
251
|
+
pycatfile.VerbosePrintOut("File is valid: \n" + str(input_file))
|
|
251
252
|
else:
|
|
252
253
|
pycatfile.VerbosePrintOut(
|
|
253
|
-
"File is invalid: \n" + str(
|
|
254
|
+
"File is invalid: \n" + str(input_file))
|
|
@@ -14,13 +14,32 @@
|
|
|
14
14
|
Copyright 2018-2024 Game Maker 2k - http://intdb.sourceforge.net/
|
|
15
15
|
Copyright 2018-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
|
|
16
16
|
|
|
17
|
-
$FileInfo: neocatfile.py - Last Update: 12/
|
|
17
|
+
$FileInfo: neocatfile.py - Last Update: 12/21/2024 Ver. 0.15.14 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
|
|
21
21
|
import argparse
|
|
22
22
|
import pycatfile
|
|
23
23
|
|
|
24
|
+
__project__ = pycatfile.__project__
|
|
25
|
+
__program_name__ = pycatfile.__program_name__
|
|
26
|
+
__file_format_name__ = pycatfile.__file_format_name__
|
|
27
|
+
__file_format_lower__ = pycatfile.__file_format_lower__
|
|
28
|
+
__file_format_magic__ = pycatfile.__file_format_magic__
|
|
29
|
+
__file_format_len__ = pycatfile.__file_format_len__
|
|
30
|
+
__file_format_hex__ = pycatfile.__file_format_hex__
|
|
31
|
+
__file_format_delimiter__ = pycatfile.__file_format_delimiter__
|
|
32
|
+
__file_format_list__ = pycatfile.__file_format_list__
|
|
33
|
+
__use_new_style__ = pycatfile.__use_new_style__
|
|
34
|
+
__use_advanced_list__ = pycatfile.__use_advanced_list__
|
|
35
|
+
__use_alt_inode__ = pycatfile.__use_alt_inode__
|
|
36
|
+
__project_url__ = pycatfile.__project_url__
|
|
37
|
+
__version_info__ = pycatfile.__version_info__
|
|
38
|
+
__version_date_info__ = pycatfile.__version_date_info__
|
|
39
|
+
__version_date__ = pycatfile.__version_date__
|
|
40
|
+
__version_date_plusrc__ = pycatfile.__version_date_plusrc__
|
|
41
|
+
__version__ = pycatfile.__version__
|
|
42
|
+
|
|
24
43
|
# Compatibility layer for Python 2 and 3 input
|
|
25
44
|
try:
|
|
26
45
|
input = raw_input
|
|
@@ -34,8 +53,9 @@ py7zr_support = pycatfile.py7zr_support
|
|
|
34
53
|
# Set up the argument parser
|
|
35
54
|
argparser = argparse.ArgumentParser(
|
|
36
55
|
description="Manipulates concatenated files for various operations like creation, extraction, and validation.")
|
|
37
|
-
argparser.add_argument("-V", "--version", action="version", version=
|
|
38
|
-
|
|
56
|
+
argparser.add_argument("-V", "--version", action="version", version="{0} {1}".format(
|
|
57
|
+
__program_name__, __version__), help="Displays the program's version.")
|
|
58
|
+
argparser.add_argument("-i", "--input", nargs="+", required=True,
|
|
39
59
|
help="Specifies input file(s) for processing.")
|
|
40
60
|
argparser.add_argument(
|
|
41
61
|
"-o", "--output", help="Specifies the output file name.")
|
|
@@ -74,43 +94,43 @@ elif args.list:
|
|
|
74
94
|
primary_action = 'list'
|
|
75
95
|
elif args.validate:
|
|
76
96
|
primary_action = 'validate'
|
|
77
|
-
|
|
97
|
+
input_file = args.input[0]
|
|
78
98
|
# Functionality mappings
|
|
79
99
|
if primary_action == 'create':
|
|
80
100
|
if args.convert == 'tar':
|
|
81
|
-
pycatfile.PackArchiveFileFromTarFile(
|
|
101
|
+
pycatfile.PackArchiveFileFromTarFile(input_file, args.output, args.compression, args.level, args.checksum, [
|
|
82
102
|
], pycatfile.__file_format_list__, args.verbose, False)
|
|
83
103
|
elif args.convert == 'zip':
|
|
84
|
-
pycatfile.PackArchiveFileFromZipFile(
|
|
104
|
+
pycatfile.PackArchiveFileFromZipFile(input_file, args.output, args.compression, args.level, args.checksum, [
|
|
85
105
|
], pycatfile.__file_format_list__, args.verbose, False)
|
|
86
106
|
elif py7zr_support and args.convert == '7zip':
|
|
87
|
-
pycatfile.PackArchiveFileFromSevenZipFile(
|
|
107
|
+
pycatfile.PackArchiveFileFromSevenZipFile(input_file, args.output, args.compression, args.level, args.checksum, [
|
|
88
108
|
], pycatfile.__file_format_list__, args.verbose, False)
|
|
89
109
|
elif rarfile_support and args.convert == 'rar':
|
|
90
|
-
pycatfile.PackArchiveFileFromRarFile(
|
|
110
|
+
pycatfile.PackArchiveFileFromRarFile(input_file, args.output, args.compression, args.level, args.checksum, [
|
|
91
111
|
], pycatfile.__file_format_list__, args.verbose, False)
|
|
92
112
|
else:
|
|
93
113
|
pycatfile.PackArchiveFile(args.input, args.output, args.verbose, args.compression, args.level,
|
|
94
114
|
False, args.checksum, [], pycatfile.__file_format_list__, args.verbose, False)
|
|
95
115
|
elif primary_action == 'repack':
|
|
96
116
|
pycatfile.RePackArchiveFile(
|
|
97
|
-
|
|
117
|
+
input_file, args.output, args.compression, args.level, args.checksum, args.verbose)
|
|
98
118
|
elif primary_action == 'extract':
|
|
99
119
|
pycatfile.UnPackArchiveFile(
|
|
100
|
-
|
|
120
|
+
input_file, args.output, args.verbose, args.preserve)
|
|
101
121
|
elif primary_action == 'list':
|
|
102
122
|
if args.convert == 'tar':
|
|
103
|
-
pycatfile.TarFileListFiles(
|
|
123
|
+
pycatfile.TarFileListFiles(input_file, verbose=args.verbose)
|
|
104
124
|
elif args.convert == 'zip':
|
|
105
|
-
pycatfile.ZipFileListFiles(
|
|
125
|
+
pycatfile.ZipFileListFiles(input_file, verbose=args.verbose)
|
|
106
126
|
elif args.convert == '7zip':
|
|
107
|
-
pycatfile.SevenZipFileListFiles(
|
|
127
|
+
pycatfile.SevenZipFileListFiles(input_file, verbose=args.verbose)
|
|
108
128
|
elif rarfile_support and args.convert == 'rar':
|
|
109
|
-
pycatfile.RarFileListFiles(
|
|
129
|
+
pycatfile.RarFileListFiles(input_file, verbose=args.verbose)
|
|
110
130
|
else:
|
|
111
|
-
pycatfile.ArchiveFileListFiles(
|
|
131
|
+
pycatfile.ArchiveFileListFiles(input_file, verbose=args.verbose)
|
|
112
132
|
elif primary_action == 'validate':
|
|
113
|
-
is_valid = pycatfile.ArchiveFileValidate(
|
|
133
|
+
is_valid = pycatfile.ArchiveFileValidate(input_file, args.verbose)
|
|
114
134
|
result_msg = "Validation result for {0}: {1}".format(
|
|
115
|
-
|
|
135
|
+
input_file, 'Valid' if is_valid else 'Invalid')
|
|
116
136
|
print(result_msg)
|
|
@@ -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: 12/
|
|
17
|
+
$FileInfo: pycatfile.py - Last Update: 12/21/2024 Ver. 0.15.14 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
|
|
@@ -304,12 +304,12 @@ __file_format_dict__ = {'format_name': __file_format_name__, 'format_magic': __f
|
|
|
304
304
|
'format_delimiter': __file_format_delimiter__, 'format_ver': __file_format_ver__, 'new_style': __use_new_style__, 'use_advanced_list': __use_advanced_list__, 'use_alt_inode': __use_alt_inode__}
|
|
305
305
|
__project__ = __program_name__
|
|
306
306
|
__project_url__ = "https://github.com/GameMaker2k/PyCatFile"
|
|
307
|
-
__version_info__ = (0, 15,
|
|
308
|
-
__version_date_info__ = (2024, 12,
|
|
307
|
+
__version_info__ = (0, 15, 14, "RC 1", 1)
|
|
308
|
+
__version_date_info__ = (2024, 12, 21, "RC 1", 1)
|
|
309
309
|
__version_date__ = str(__version_date_info__[0]) + "." + str(
|
|
310
310
|
__version_date_info__[1]).zfill(2) + "." + str(__version_date_info__[2]).zfill(2)
|
|
311
311
|
__revision__ = __version_info__[3]
|
|
312
|
-
__revision_id__ = "$Id:
|
|
312
|
+
__revision_id__ = "$Id: 5ac437d67d0b485df434560f6f73d2823777d4c1 $"
|
|
313
313
|
if(__version_info__[4] is not None):
|
|
314
314
|
__version_date_plusrc__ = __version_date__ + \
|
|
315
315
|
"-" + str(__version_date_info__[4])
|
|
@@ -591,6 +591,8 @@ def ListDir(dirpath, followlink=False, duplicates=False, include_regex=None, exc
|
|
|
591
591
|
Returns:
|
|
592
592
|
list: A list of files and directories matching the criteria.
|
|
593
593
|
"""
|
|
594
|
+
if os.stat not in os.supports_follow_symlinks and followlink:
|
|
595
|
+
followlink = False
|
|
594
596
|
if isinstance(dirpath, (list, tuple)):
|
|
595
597
|
dirpath = list(filter(None, dirpath))
|
|
596
598
|
elif isinstance(dirpath, basestring):
|
|
@@ -656,6 +658,8 @@ def ListDirAdvanced(dirpath, followlink=False, duplicates=False, include_regex=N
|
|
|
656
658
|
Returns:
|
|
657
659
|
list: A list of files and directories matching the criteria.
|
|
658
660
|
"""
|
|
661
|
+
if os.stat not in os.supports_follow_symlinks and followlink:
|
|
662
|
+
followlink = False
|
|
659
663
|
if isinstance(dirpath, (list, tuple)):
|
|
660
664
|
dirpath = list(filter(None, dirpath))
|
|
661
665
|
elif isinstance(dirpath, basestring):
|
|
@@ -729,7 +733,7 @@ def GetTotalSize(file_list):
|
|
|
729
733
|
return total_size
|
|
730
734
|
|
|
731
735
|
|
|
732
|
-
def
|
|
736
|
+
def create_alias_function_alt(prefix, base_name, suffix, target_function):
|
|
733
737
|
# Define a new function that wraps the target function
|
|
734
738
|
def alias_function(*args, **kwargs):
|
|
735
739
|
return target_function(*args, **kwargs)
|
|
@@ -739,7 +743,7 @@ def create_alias_function(prefix, base_name, suffix, target_function):
|
|
|
739
743
|
globals()[function_name] = alias_function
|
|
740
744
|
|
|
741
745
|
|
|
742
|
-
def
|
|
746
|
+
def create_alias_function(prefix, base_name, suffix, target_function):
|
|
743
747
|
# Create the function name by combining the prefix, base name, and the suffix
|
|
744
748
|
# Use the format method for string formatting, compatible with Python 2 and 3
|
|
745
749
|
function_name = "{}{}{}".format(prefix, base_name, suffix)
|
|
@@ -1516,16 +1520,21 @@ def ValidateFileChecksum(infile, checksumtype="crc32", inchecksum="0", formatspe
|
|
|
1516
1520
|
|
|
1517
1521
|
|
|
1518
1522
|
def ReadTillNullByteOld(fp, delimiter=__file_format_dict__['format_delimiter']):
|
|
1519
|
-
if
|
|
1523
|
+
if not hasattr(fp, "read"):
|
|
1520
1524
|
return False
|
|
1521
|
-
|
|
1522
|
-
curfullbyte = b""
|
|
1525
|
+
curfullbyte = bytearray()
|
|
1523
1526
|
nullbyte = delimiter.encode("UTF-8")
|
|
1524
|
-
|
|
1527
|
+
dellen = len(nullbyte)
|
|
1528
|
+
while True:
|
|
1525
1529
|
curbyte = fp.read(1)
|
|
1526
|
-
if
|
|
1530
|
+
if not curbyte: # End of file or no more data
|
|
1531
|
+
break
|
|
1532
|
+
curfullbyte.extend(curbyte)
|
|
1533
|
+
# Check if the end of the buffer matches our delimiter
|
|
1534
|
+
if len(curfullbyte) >= dellen and curfullbyte[-dellen:] == nullbyte:
|
|
1535
|
+
# Remove the delimiter from the returned bytes
|
|
1536
|
+
curfullbyte = curfullbyte[:-dellen]
|
|
1527
1537
|
break
|
|
1528
|
-
curfullbyte = curfullbyte + curbyte
|
|
1529
1538
|
return curfullbyte.decode('UTF-8')
|
|
1530
1539
|
|
|
1531
1540
|
|
|
@@ -1581,25 +1590,31 @@ def ReadUntilNullByteAlt(fp, delimiter=__file_format_dict__['format_delimiter'],
|
|
|
1581
1590
|
|
|
1582
1591
|
|
|
1583
1592
|
def ReadTillNullByte(fp, delimiter=__file_format_dict__['format_delimiter'], max_read=1024000):
|
|
1584
|
-
if
|
|
1593
|
+
if not hasattr(fp, "read"):
|
|
1585
1594
|
return False
|
|
1586
1595
|
curfullbyte = bytearray()
|
|
1587
1596
|
nullbyte = delimiter.encode("UTF-8")
|
|
1597
|
+
dellen = len(nullbyte)
|
|
1588
1598
|
total_read = 0 # Track the total number of bytes read
|
|
1589
1599
|
while True:
|
|
1590
1600
|
curbyte = fp.read(1)
|
|
1591
|
-
if curbyte
|
|
1601
|
+
if not curbyte: # End of file or no more data
|
|
1592
1602
|
break
|
|
1593
1603
|
curfullbyte.extend(curbyte)
|
|
1594
1604
|
total_read += 1
|
|
1605
|
+
# Check if the end of the buffer matches the delimiter
|
|
1606
|
+
if len(curfullbyte) >= dellen and curfullbyte[-dellen:] == nullbyte:
|
|
1607
|
+
# Remove the delimiter from the returned bytes
|
|
1608
|
+
curfullbyte = curfullbyte[:-dellen]
|
|
1609
|
+
break
|
|
1610
|
+
# Check if we have exceeded the max read limit
|
|
1595
1611
|
if total_read >= max_read:
|
|
1596
|
-
raise MemoryError(
|
|
1597
|
-
"Maximum read limit reached without finding the delimiter.")
|
|
1612
|
+
raise MemoryError("Maximum read limit reached without finding the delimiter.")
|
|
1598
1613
|
# Decode the full byte array to string once out of the loop
|
|
1599
1614
|
try:
|
|
1600
1615
|
return curfullbyte.decode('UTF-8')
|
|
1601
1616
|
except UnicodeDecodeError:
|
|
1602
|
-
# Handle potential partial UTF-8 characters
|
|
1617
|
+
# Handle potential partial UTF-8 characters at the end
|
|
1603
1618
|
for i in range(1, 4):
|
|
1604
1619
|
try:
|
|
1605
1620
|
return curfullbyte[:-i].decode('UTF-8')
|
|
@@ -2453,17 +2468,17 @@ def MakeEmptyFilePointer(fp, checksumtype="crc32", formatspecs=__file_format_dic
|
|
|
2453
2468
|
return fp
|
|
2454
2469
|
|
|
2455
2470
|
|
|
2456
|
-
def MakeEmptyFile(outfile, compression="auto", compressionlevel=None, checksumtype="crc32", formatspecs=__file_format_dict__, returnfp=False):
|
|
2471
|
+
def MakeEmptyFile(outfile, compression="auto", compresswholefile=True, compressionlevel=None, checksumtype="crc32", formatspecs=__file_format_dict__, returnfp=False):
|
|
2457
2472
|
formatspecs = FormatSpecsListToDict(formatspecs)
|
|
2458
|
-
if(outfile != "-" and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
2473
|
+
if(outfile != "-" and outfile is not None and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
2459
2474
|
if(os.path.exists(outfile)):
|
|
2460
2475
|
try:
|
|
2461
2476
|
os.unlink(outfile)
|
|
2462
2477
|
except OSError:
|
|
2463
2478
|
pass
|
|
2464
|
-
if(outfile == "-"):
|
|
2479
|
+
if(outfile == "-" or outfile is None):
|
|
2465
2480
|
verbose = False
|
|
2466
|
-
|
|
2481
|
+
catfp = BytesIO()
|
|
2467
2482
|
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
2468
2483
|
catfp = outfile
|
|
2469
2484
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", str(outfile))):
|
|
@@ -2475,7 +2490,7 @@ def MakeEmptyFile(outfile, compression="auto", compressionlevel=None, checksumty
|
|
|
2475
2490
|
compresswholefile = True
|
|
2476
2491
|
catfp = CompressOpenFile(outfile, True, compressionlevel)
|
|
2477
2492
|
catfp = AppendFileHeader(catfp, 0, checksumtype, formatspecs)
|
|
2478
|
-
if(outfile == "-" or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
2493
|
+
if(outfile == "-" or outfile is None or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
2479
2494
|
catfp = CompressArchiveFile(
|
|
2480
2495
|
catfp, compression, compressionlevel, formatspecs)
|
|
2481
2496
|
try:
|
|
@@ -2494,6 +2509,11 @@ def MakeEmptyFile(outfile, compression="auto", compressionlevel=None, checksumty
|
|
|
2494
2509
|
shutil.copyfileobj(catfp, sys.stdout.buffer)
|
|
2495
2510
|
else:
|
|
2496
2511
|
shutil.copyfileobj(catfp, sys.stdout)
|
|
2512
|
+
elif(outfile is None):
|
|
2513
|
+
catfp.seek(0, 0)
|
|
2514
|
+
outvar = catfp.read()
|
|
2515
|
+
catfp.close()
|
|
2516
|
+
return outvar
|
|
2497
2517
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", str(outfile))):
|
|
2498
2518
|
catfp = CompressArchiveFile(
|
|
2499
2519
|
catfp, compression, compressionlevel, formatspecs)
|
|
@@ -2595,6 +2615,8 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
|
|
|
2595
2615
|
infilelist = list(filter(None, infiles))
|
|
2596
2616
|
elif(isinstance(infiles, (basestring, ))):
|
|
2597
2617
|
infilelist = list(filter(None, [infiles]))
|
|
2618
|
+
if os.stat not in os.supports_follow_symlinks and followlink:
|
|
2619
|
+
followlink = False
|
|
2598
2620
|
if(advancedlist):
|
|
2599
2621
|
GetDirList = ListDirAdvanced(infilelist, followlink, False)
|
|
2600
2622
|
else:
|
|
@@ -2694,9 +2716,13 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
|
|
|
2694
2716
|
getfdev = GetDevMajorMinor(fdev)
|
|
2695
2717
|
fdev_minor = getfdev[0]
|
|
2696
2718
|
fdev_major = getfdev[1]
|
|
2697
|
-
|
|
2719
|
+
# Types that should be considered zero-length in the archive context:
|
|
2720
|
+
zero_length_types = {1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 13}
|
|
2721
|
+
# Types that have actual data to read:
|
|
2722
|
+
data_types = {0, 7, 12}
|
|
2723
|
+
if ftype in zero_length_types:
|
|
2698
2724
|
fsize = format(int("0"), 'x').lower()
|
|
2699
|
-
elif
|
|
2725
|
+
elif ftype in data_types:
|
|
2700
2726
|
fsize = format(int(fstatinfo.st_size), 'x').lower()
|
|
2701
2727
|
else:
|
|
2702
2728
|
fsize = format(int(fstatinfo.st_size)).lower()
|
|
@@ -2746,7 +2772,7 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
|
|
|
2746
2772
|
fcsize = format(int(0), 'x').lower()
|
|
2747
2773
|
fcontents = BytesIO()
|
|
2748
2774
|
chunk_size = 1024
|
|
2749
|
-
if
|
|
2775
|
+
if ftype in data_types:
|
|
2750
2776
|
with open(fname, "rb") as fpc:
|
|
2751
2777
|
shutil.copyfileobj(fpc, fcontents)
|
|
2752
2778
|
if(not compresswholefile):
|
|
@@ -2838,7 +2864,7 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
|
|
|
2838
2864
|
fcontents.seek(0, 0)
|
|
2839
2865
|
ftypehex = format(ftype, 'x').lower()
|
|
2840
2866
|
catoutlist = [ftypehex, fname, flinkname, fsize, fatime, fmtime, fctime, fbtime, fmode, fwinattributes, fcompression,
|
|
2841
|
-
fcsize, fuid, funame, fgid, fgname, fcurfid, fcurinode, flinkcount, fdev, fdev_minor, fdev_major, "+
|
|
2867
|
+
fcsize, fuid, funame, fgid, fgname, fcurfid, fcurinode, flinkcount, fdev, fdev_minor, fdev_major, "+"+str(len(formatspecs['format_delimiter']))]
|
|
2842
2868
|
fp = AppendFileHeaderWithContent(
|
|
2843
2869
|
fp, catoutlist, extradata, fcontents.read(), checksumtype, formatspecs)
|
|
2844
2870
|
if(numfiles > 0):
|
|
@@ -2919,15 +2945,15 @@ def AppendInFileWithContent(infile, fp, dirlistfromtxt=False, filevalues=[], ext
|
|
|
2919
2945
|
|
|
2920
2946
|
def AppendFilesWithContentToOutFile(infiles, outfile, dirlistfromtxt=False, compression="auto", compresswholefile=True, compressionlevel=None, filevalues=[], extradata=[], followlink=False, checksumtype="crc32", formatspecs=__file_format_dict__, verbose=False, returnfp=False):
|
|
2921
2947
|
formatspecs = FormatSpecsListToDict(formatspecs)
|
|
2922
|
-
if(outfile != "-" and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
2948
|
+
if(outfile != "-" and outfile is not None and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
2923
2949
|
if(os.path.exists(outfile)):
|
|
2924
2950
|
try:
|
|
2925
2951
|
os.unlink(outfile)
|
|
2926
2952
|
except OSError:
|
|
2927
2953
|
pass
|
|
2928
|
-
if(outfile == "-"):
|
|
2954
|
+
if(outfile == "-" or outfile is None):
|
|
2929
2955
|
verbose = False
|
|
2930
|
-
|
|
2956
|
+
catfp = BytesIO()
|
|
2931
2957
|
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
2932
2958
|
catfp = outfile
|
|
2933
2959
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", str(outfile))):
|
|
@@ -2940,7 +2966,7 @@ def AppendFilesWithContentToOutFile(infiles, outfile, dirlistfromtxt=False, comp
|
|
|
2940
2966
|
catfp = CompressOpenFile(outfile, compresswholefile, compressionlevel)
|
|
2941
2967
|
catfp = AppendFilesWithContent(infiles, catfp, dirlistfromtxt, filevalues, extradata, compression,
|
|
2942
2968
|
compresswholefile, compressionlevel, followlink, checksumtype, formatspecs, verbose)
|
|
2943
|
-
if(outfile == "-" or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
2969
|
+
if(outfile == "-" or outfile is None or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
2944
2970
|
catfp = CompressArchiveFile(
|
|
2945
2971
|
catfp, compression, compressionlevel, formatspecs)
|
|
2946
2972
|
try:
|
|
@@ -2959,6 +2985,11 @@ def AppendFilesWithContentToOutFile(infiles, outfile, dirlistfromtxt=False, comp
|
|
|
2959
2985
|
shutil.copyfileobj(catfp, sys.stdout.buffer)
|
|
2960
2986
|
else:
|
|
2961
2987
|
shutil.copyfileobj(catfp, sys.stdout)
|
|
2988
|
+
elif(outfile is None):
|
|
2989
|
+
catfp.seek(0, 0)
|
|
2990
|
+
outvar = catfp.read()
|
|
2991
|
+
catfp.close()
|
|
2992
|
+
return outvar
|
|
2962
2993
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", str(outfile))):
|
|
2963
2994
|
catfp = CompressArchiveFile(
|
|
2964
2995
|
catfp, compression, compressionlevel, formatspecs)
|
|
@@ -2974,15 +3005,15 @@ def AppendFilesWithContentToOutFile(infiles, outfile, dirlistfromtxt=False, comp
|
|
|
2974
3005
|
|
|
2975
3006
|
def AppendListsWithContentToOutFile(inlist, outfile, dirlistfromtxt=False, compression="auto", compresswholefile=True, compressionlevel=None, filevalues=[], extradata=[], followlink=False, checksumtype="crc32", formatspecs=__file_format_dict__, verbose=False, returnfp=False):
|
|
2976
3007
|
formatspecs = FormatSpecsListToDict(formatspecs)
|
|
2977
|
-
if(outfile != "-" and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
3008
|
+
if(outfile != "-" and outfile is not None and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
2978
3009
|
if(os.path.exists(outfile)):
|
|
2979
3010
|
try:
|
|
2980
3011
|
os.unlink(outfile)
|
|
2981
3012
|
except OSError:
|
|
2982
3013
|
pass
|
|
2983
|
-
if(outfile == "-"):
|
|
3014
|
+
if(outfile == "-" or outfile is None):
|
|
2984
3015
|
verbose = False
|
|
2985
|
-
|
|
3016
|
+
catfp = BytesIO()
|
|
2986
3017
|
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
2987
3018
|
catfp = outfile
|
|
2988
3019
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", str(outfile))):
|
|
@@ -2995,7 +3026,7 @@ def AppendListsWithContentToOutFile(inlist, outfile, dirlistfromtxt=False, compr
|
|
|
2995
3026
|
catfp = CompressOpenFile(outfile, compresswholefile, compressionlevel)
|
|
2996
3027
|
catfp = AppendListsWithContent(inlist, catfp, dirlistfromtxt, filevalues, extradata, compression,
|
|
2997
3028
|
compresswholefile, compressionlevel, followlink, checksumtype, formatspecs, verbose)
|
|
2998
|
-
if(outfile == "-" or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
3029
|
+
if(outfile == "-" or outfile is None or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
2999
3030
|
catfp = CompressArchiveFile(
|
|
3000
3031
|
catfp, compression, compressionlevel, formatspecs)
|
|
3001
3032
|
try:
|
|
@@ -3014,6 +3045,11 @@ def AppendListsWithContentToOutFile(inlist, outfile, dirlistfromtxt=False, compr
|
|
|
3014
3045
|
shutil.copyfileobj(catfp, sys.stdout.buffer)
|
|
3015
3046
|
else:
|
|
3016
3047
|
shutil.copyfileobj(catfp, sys.stdout)
|
|
3048
|
+
elif(outfile is None):
|
|
3049
|
+
catfp.seek(0, 0)
|
|
3050
|
+
outvar = catfp.read()
|
|
3051
|
+
catfp.close()
|
|
3052
|
+
return outvar
|
|
3017
3053
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", str(outfile))):
|
|
3018
3054
|
catfp = CompressArchiveFile(
|
|
3019
3055
|
catfp, compression, compressionlevel, formatspecs)
|
|
@@ -3714,7 +3750,7 @@ def PackArchiveFile(infiles, outfile, dirlistfromtxt=False, compression="auto",
|
|
|
3714
3750
|
formatspecs = FormatSpecsListToDict(formatspecs)
|
|
3715
3751
|
advancedlist = formatspecs['use_advanced_list']
|
|
3716
3752
|
altinode = formatspecs['use_alt_inode']
|
|
3717
|
-
if(outfile != "-" and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
3753
|
+
if(outfile != "-" and outfile is not None and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
3718
3754
|
outfile = RemoveWindowsPath(outfile)
|
|
3719
3755
|
checksumtype = checksumtype.lower()
|
|
3720
3756
|
if(not CheckSumSupport(checksumtype, hashlib_guaranteed)):
|
|
@@ -3728,13 +3764,13 @@ def PackArchiveFile(infiles, outfile, dirlistfromtxt=False, compression="auto",
|
|
|
3728
3764
|
if(verbose):
|
|
3729
3765
|
logging.basicConfig(format="%(message)s",
|
|
3730
3766
|
stream=sys.stdout, level=logging.DEBUG)
|
|
3731
|
-
if(outfile != "-" and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
3767
|
+
if(outfile != "-" and outfile is not None and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
3732
3768
|
if(os.path.exists(outfile)):
|
|
3733
3769
|
try:
|
|
3734
3770
|
os.unlink(outfile)
|
|
3735
3771
|
except OSError:
|
|
3736
3772
|
pass
|
|
3737
|
-
if(outfile == "-"):
|
|
3773
|
+
if(outfile == "-" or outfile is None):
|
|
3738
3774
|
verbose = False
|
|
3739
3775
|
catfp = BytesIO()
|
|
3740
3776
|
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
@@ -3766,6 +3802,8 @@ def PackArchiveFile(infiles, outfile, dirlistfromtxt=False, compression="auto",
|
|
|
3766
3802
|
infilelist = list(filter(None, infiles))
|
|
3767
3803
|
elif(isinstance(infiles, (basestring, ))):
|
|
3768
3804
|
infilelist = list(filter(None, [infiles]))
|
|
3805
|
+
if os.stat not in os.supports_follow_symlinks and followlink:
|
|
3806
|
+
followlink = False
|
|
3769
3807
|
if(advancedlist):
|
|
3770
3808
|
GetDirList = ListDirAdvanced(infilelist, followlink, False)
|
|
3771
3809
|
else:
|
|
@@ -3803,8 +3841,8 @@ def PackArchiveFile(infiles, outfile, dirlistfromtxt=False, compression="auto",
|
|
|
3803
3841
|
ftype = 0
|
|
3804
3842
|
if(hasattr(os.path, "isjunction") and os.path.isjunction(fname)):
|
|
3805
3843
|
ftype = 13
|
|
3806
|
-
elif(fstatinfo.st_blocks * 512 < fstatinfo.st_size):
|
|
3807
|
-
|
|
3844
|
+
#elif(fstatinfo.st_blocks * 512 < fstatinfo.st_size):
|
|
3845
|
+
# ftype = 12
|
|
3808
3846
|
elif(stat.S_ISREG(fpremode)):
|
|
3809
3847
|
ftype = 0
|
|
3810
3848
|
elif(stat.S_ISLNK(fpremode)):
|
|
@@ -3864,9 +3902,13 @@ def PackArchiveFile(infiles, outfile, dirlistfromtxt=False, compression="auto",
|
|
|
3864
3902
|
getfdev = GetDevMajorMinor(fdev)
|
|
3865
3903
|
fdev_minor = getfdev[0]
|
|
3866
3904
|
fdev_major = getfdev[1]
|
|
3867
|
-
|
|
3905
|
+
# Types that should be considered zero-length in the archive context:
|
|
3906
|
+
zero_length_types = {1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 13}
|
|
3907
|
+
# Types that have actual data to read:
|
|
3908
|
+
data_types = {0, 7, 12}
|
|
3909
|
+
if ftype in zero_length_types:
|
|
3868
3910
|
fsize = format(int("0"), 'x').lower()
|
|
3869
|
-
elif
|
|
3911
|
+
elif ftype in data_types:
|
|
3870
3912
|
fsize = format(int(fstatinfo.st_size), 'x').lower()
|
|
3871
3913
|
else:
|
|
3872
3914
|
fsize = format(int(fstatinfo.st_size)).lower()
|
|
@@ -3915,7 +3957,7 @@ def PackArchiveFile(infiles, outfile, dirlistfromtxt=False, compression="auto",
|
|
|
3915
3957
|
fcompression = ""
|
|
3916
3958
|
fcsize = format(int(0), 'x').lower()
|
|
3917
3959
|
fcontents = BytesIO()
|
|
3918
|
-
if
|
|
3960
|
+
if ftype in data_types:
|
|
3919
3961
|
with open(fname, "rb") as fpc:
|
|
3920
3962
|
shutil.copyfileobj(fpc, fcontents)
|
|
3921
3963
|
if(not compresswholefile):
|
|
@@ -4007,14 +4049,14 @@ def PackArchiveFile(infiles, outfile, dirlistfromtxt=False, compression="auto",
|
|
|
4007
4049
|
fcontents.seek(0, 0)
|
|
4008
4050
|
ftypehex = format(ftype, 'x').lower()
|
|
4009
4051
|
catoutlist = [ftypehex, fname, flinkname, fsize, fatime, fmtime, fctime, fbtime, fmode, fwinattributes, fcompression,
|
|
4010
|
-
fcsize, fuid, funame, fgid, fgname, fcurfid, fcurinode, flinkcount, fdev, fdev_minor, fdev_major, "+
|
|
4052
|
+
fcsize, fuid, funame, fgid, fgname, fcurfid, fcurinode, flinkcount, fdev, fdev_minor, fdev_major, "+"+str(len(formatspecs['format_delimiter']))]
|
|
4011
4053
|
catfp = AppendFileHeaderWithContent(
|
|
4012
4054
|
catfp, catoutlist, extradata, fcontents.read(), checksumtype, formatspecs)
|
|
4013
4055
|
fcontents.close()
|
|
4014
4056
|
if(numfiles > 0):
|
|
4015
4057
|
catfp.write(AppendNullBytes(
|
|
4016
4058
|
[0, 0], formatspecs['format_delimiter']).encode("UTF-8"))
|
|
4017
|
-
if(outfile == "-" or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
4059
|
+
if(outfile == "-" or outfile is None or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
4018
4060
|
catfp = CompressArchiveFile(
|
|
4019
4061
|
catfp, compression, compressionlevel, formatspecs)
|
|
4020
4062
|
try:
|
|
@@ -4033,6 +4075,11 @@ def PackArchiveFile(infiles, outfile, dirlistfromtxt=False, compression="auto",
|
|
|
4033
4075
|
shutil.copyfileobj(catfp, sys.stdout.buffer)
|
|
4034
4076
|
else:
|
|
4035
4077
|
shutil.copyfileobj(catfp, sys.stdout)
|
|
4078
|
+
elif(outfile is None):
|
|
4079
|
+
catfp.seek(0, 0)
|
|
4080
|
+
outvar = catfp.read()
|
|
4081
|
+
catfp.close()
|
|
4082
|
+
return outvar
|
|
4036
4083
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", str(outfile))):
|
|
4037
4084
|
catfp = CompressArchiveFile(
|
|
4038
4085
|
catfp, compression, compressionlevel, formatspecs)
|
|
@@ -4066,7 +4113,7 @@ create_alias_function("Pack", __file_format_name__,
|
|
|
4066
4113
|
|
|
4067
4114
|
def PackArchiveFileFromTarFile(infile, outfile, compression="auto", compresswholefile=True, compressionlevel=None, checksumtype="crc32", extradata=[], formatspecs=__file_format_dict__, verbose=False, returnfp=False):
|
|
4068
4115
|
formatspecs = FormatSpecsListToDict(formatspecs)
|
|
4069
|
-
if(outfile != "-" and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
4116
|
+
if(outfile != "-" and outfile is not None and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
4070
4117
|
outfile = RemoveWindowsPath(outfile)
|
|
4071
4118
|
checksumtype = checksumtype.lower()
|
|
4072
4119
|
if(not CheckSumSupport(checksumtype, hashlib_guaranteed)):
|
|
@@ -4080,13 +4127,13 @@ def PackArchiveFileFromTarFile(infile, outfile, compression="auto", compresswhol
|
|
|
4080
4127
|
if(verbose):
|
|
4081
4128
|
logging.basicConfig(format="%(message)s",
|
|
4082
4129
|
stream=sys.stdout, level=logging.DEBUG)
|
|
4083
|
-
if(outfile != "-" and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
4130
|
+
if(outfile != "-" and outfile is not None and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
4084
4131
|
if(os.path.exists(outfile)):
|
|
4085
4132
|
try:
|
|
4086
4133
|
os.unlink(outfile)
|
|
4087
4134
|
except OSError:
|
|
4088
4135
|
pass
|
|
4089
|
-
if(outfile == "-"):
|
|
4136
|
+
if(outfile == "-" or outfile is None):
|
|
4090
4137
|
verbose = False
|
|
4091
4138
|
catfp = BytesIO()
|
|
4092
4139
|
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
@@ -4194,9 +4241,13 @@ def PackArchiveFileFromTarFile(infile, outfile, compression="auto", compresswhol
|
|
|
4194
4241
|
fdev = format(int(MakeDevAlt(member.devmajor, member.devminor)), 'x').lower()
|
|
4195
4242
|
fdev_minor = format(int(member.devminor), 'x').lower()
|
|
4196
4243
|
fdev_major = format(int(member.devmajor), 'x').lower()
|
|
4197
|
-
|
|
4244
|
+
# Types that should be considered zero-length in the archive context:
|
|
4245
|
+
zero_length_types = {1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 13}
|
|
4246
|
+
# Types that have actual data to read:
|
|
4247
|
+
data_types = {0, 7, 12}
|
|
4248
|
+
if ftype in zero_length_types:
|
|
4198
4249
|
fsize = format(int("0"), 'x').lower()
|
|
4199
|
-
elif
|
|
4250
|
+
elif ftype in data_types:
|
|
4200
4251
|
fsize = format(int(member.size), 'x').lower()
|
|
4201
4252
|
else:
|
|
4202
4253
|
fsize = format(int(member.size), 'x').lower()
|
|
@@ -4216,7 +4267,7 @@ def PackArchiveFileFromTarFile(infile, outfile, compression="auto", compresswhol
|
|
|
4216
4267
|
fcompression = ""
|
|
4217
4268
|
fcsize = format(int(0), 'x').lower()
|
|
4218
4269
|
fcontents = BytesIO()
|
|
4219
|
-
if
|
|
4270
|
+
if ftype in data_types:
|
|
4220
4271
|
with tarfp.extractfile(member) as fpc:
|
|
4221
4272
|
shutil.copyfileobj(fpc, fcontents)
|
|
4222
4273
|
if(not compresswholefile):
|
|
@@ -4264,14 +4315,14 @@ def PackArchiveFileFromTarFile(infile, outfile, compression="auto", compresswhol
|
|
|
4264
4315
|
fcontents.seek(0, 0)
|
|
4265
4316
|
ftypehex = format(ftype, 'x').lower()
|
|
4266
4317
|
catoutlist = [ftypehex, fname, flinkname, fsize, fatime, fmtime, fctime, fbtime, fmode, fwinattributes, fcompression,
|
|
4267
|
-
fcsize, fuid, funame, fgid, fgname, fcurfid, fcurinode, flinkcount, fdev, fdev_minor, fdev_major, "+
|
|
4318
|
+
fcsize, fuid, funame, fgid, fgname, fcurfid, fcurinode, flinkcount, fdev, fdev_minor, fdev_major, "+"+str(len(formatspecs['format_delimiter']))]
|
|
4268
4319
|
catfp = AppendFileHeaderWithContent(
|
|
4269
4320
|
catfp, catoutlist, extradata, fcontents.read(), checksumtype, formatspecs)
|
|
4270
4321
|
fcontents.close()
|
|
4271
4322
|
if(numfiles > 0):
|
|
4272
4323
|
catfp.write(AppendNullBytes(
|
|
4273
4324
|
[0, 0], formatspecs['format_delimiter']).encode("UTF-8"))
|
|
4274
|
-
if(outfile == "-" or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
4325
|
+
if(outfile == "-" or outfile is None or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
4275
4326
|
catfp = CompressArchiveFile(
|
|
4276
4327
|
catfp, compression, compressionlevel, formatspecs)
|
|
4277
4328
|
try:
|
|
@@ -4290,6 +4341,11 @@ def PackArchiveFileFromTarFile(infile, outfile, compression="auto", compresswhol
|
|
|
4290
4341
|
shutil.copyfileobj(catfp, sys.stdout.buffer)
|
|
4291
4342
|
else:
|
|
4292
4343
|
shutil.copyfileobj(catfp, sys.stdout)
|
|
4344
|
+
elif(outfile is None):
|
|
4345
|
+
catfp.seek(0, 0)
|
|
4346
|
+
outvar = catfp.read()
|
|
4347
|
+
catfp.close()
|
|
4348
|
+
return outvar
|
|
4293
4349
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", str(outfile))):
|
|
4294
4350
|
catfp = CompressArchiveFile(
|
|
4295
4351
|
catfp, compression, compressionlevel, formatspecs)
|
|
@@ -4309,7 +4365,7 @@ create_alias_function("Pack", __file_format_name__,
|
|
|
4309
4365
|
|
|
4310
4366
|
def PackArchiveFileFromZipFile(infile, outfile, compression="auto", compresswholefile=True, compressionlevel=None, checksumtype="crc32", extradata=[], formatspecs=__file_format_dict__, verbose=False, returnfp=False):
|
|
4311
4367
|
formatspecs = FormatSpecsListToDict(formatspecs)
|
|
4312
|
-
if(outfile != "-" and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
4368
|
+
if(outfile != "-" and outfile is not None and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
4313
4369
|
outfile = RemoveWindowsPath(outfile)
|
|
4314
4370
|
checksumtype = checksumtype.lower()
|
|
4315
4371
|
if(not CheckSumSupport(checksumtype, hashlib_guaranteed)):
|
|
@@ -4323,13 +4379,13 @@ def PackArchiveFileFromZipFile(infile, outfile, compression="auto", compresswhol
|
|
|
4323
4379
|
if(verbose):
|
|
4324
4380
|
logging.basicConfig(format="%(message)s",
|
|
4325
4381
|
stream=sys.stdout, level=logging.DEBUG)
|
|
4326
|
-
if(outfile != "-" and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
4382
|
+
if(outfile != "-" and outfile is not None and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
4327
4383
|
if(os.path.exists(outfile)):
|
|
4328
4384
|
try:
|
|
4329
4385
|
os.unlink(outfile)
|
|
4330
4386
|
except OSError:
|
|
4331
4387
|
pass
|
|
4332
|
-
if(outfile == "-"):
|
|
4388
|
+
if(outfile == "-" or outfile is None):
|
|
4333
4389
|
verbose = False
|
|
4334
4390
|
catfp = BytesIO()
|
|
4335
4391
|
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
@@ -4531,14 +4587,14 @@ def PackArchiveFileFromZipFile(infile, outfile, compression="auto", compresswhol
|
|
|
4531
4587
|
fcontents.seek(0, 0)
|
|
4532
4588
|
ftypehex = format(ftype, 'x').lower()
|
|
4533
4589
|
catoutlist = [ftypehex, fname, flinkname, fsize, fatime, fmtime, fctime, fbtime, fmode, fwinattributes, fcompression,
|
|
4534
|
-
fcsize, fuid, funame, fgid, fgname, fcurfid, fcurinode, flinkcount, fdev, fdev_minor, fdev_major, "+
|
|
4590
|
+
fcsize, fuid, funame, fgid, fgname, fcurfid, fcurinode, flinkcount, fdev, fdev_minor, fdev_major, "+"+str(len(formatspecs['format_delimiter']))]
|
|
4535
4591
|
catfp = AppendFileHeaderWithContent(
|
|
4536
4592
|
catfp, catoutlist, extradata, fcontents.read(), checksumtype, formatspecs)
|
|
4537
4593
|
fcontents.close()
|
|
4538
4594
|
if(numfiles > 0):
|
|
4539
4595
|
catfp.write(AppendNullBytes(
|
|
4540
4596
|
[0, 0], formatspecs['format_delimiter']).encode("UTF-8"))
|
|
4541
|
-
if(outfile == "-" or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
4597
|
+
if(outfile == "-" or outfile is None or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
4542
4598
|
catfp = CompressArchiveFile(
|
|
4543
4599
|
catfp, compression, compressionlevel, formatspecs)
|
|
4544
4600
|
try:
|
|
@@ -4557,6 +4613,11 @@ def PackArchiveFileFromZipFile(infile, outfile, compression="auto", compresswhol
|
|
|
4557
4613
|
shutil.copyfileobj(catfp, sys.stdout.buffer)
|
|
4558
4614
|
else:
|
|
4559
4615
|
shutil.copyfileobj(catfp, sys.stdout)
|
|
4616
|
+
elif(outfile is None):
|
|
4617
|
+
catfp.seek(0, 0)
|
|
4618
|
+
outvar = catfp.read()
|
|
4619
|
+
catfp.close()
|
|
4620
|
+
return outvar
|
|
4560
4621
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", str(outfile))):
|
|
4561
4622
|
catfp = CompressArchiveFile(
|
|
4562
4623
|
catfp, compression, compressionlevel, formatspecs)
|
|
@@ -4580,7 +4641,7 @@ if(not rarfile_support):
|
|
|
4580
4641
|
if(rarfile_support):
|
|
4581
4642
|
def PackArchiveFileFromRarFile(infile, outfile, compression="auto", compresswholefile=True, compressionlevel=None, checksumtype="crc32", extradata=[], formatspecs=__file_format_dict__, verbose=False, returnfp=False):
|
|
4582
4643
|
formatspecs = FormatSpecsListToDict(formatspecs)
|
|
4583
|
-
if(outfile != "-" and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
4644
|
+
if(outfile != "-" and outfile is not None and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
4584
4645
|
outfile = RemoveWindowsPath(outfile)
|
|
4585
4646
|
checksumtype = checksumtype.lower()
|
|
4586
4647
|
if(not CheckSumSupport(checksumtype, hashlib_guaranteed)):
|
|
@@ -4594,13 +4655,13 @@ if(rarfile_support):
|
|
|
4594
4655
|
if(verbose):
|
|
4595
4656
|
logging.basicConfig(format="%(message)s",
|
|
4596
4657
|
stream=sys.stdout, level=logging.DEBUG)
|
|
4597
|
-
if(outfile != "-" and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
4658
|
+
if(outfile != "-" and outfile is not None and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
4598
4659
|
if(os.path.exists(outfile)):
|
|
4599
4660
|
try:
|
|
4600
4661
|
os.unlink(outfile)
|
|
4601
4662
|
except OSError:
|
|
4602
4663
|
pass
|
|
4603
|
-
if(outfile == "-"):
|
|
4664
|
+
if(outfile == "-" or outfile is None):
|
|
4604
4665
|
verbose = False
|
|
4605
4666
|
catfp = BytesIO()
|
|
4606
4667
|
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
@@ -4829,14 +4890,14 @@ if(rarfile_support):
|
|
|
4829
4890
|
fcontents.seek(0, 0)
|
|
4830
4891
|
ftypehex = format(ftype, 'x').lower()
|
|
4831
4892
|
catoutlist = [ftypehex, fname, flinkname, fsize, fatime, fmtime, fctime, fbtime, fmode, fwinattributes, fcompression,
|
|
4832
|
-
fcsize, fuid, funame, fgid, fgname, fcurfid, fcurinode, flinkcount, fdev, fdev_minor, fdev_major, "+
|
|
4893
|
+
fcsize, fuid, funame, fgid, fgname, fcurfid, fcurinode, flinkcount, fdev, fdev_minor, fdev_major, "+"+str(len(formatspecs['format_delimiter']))]
|
|
4833
4894
|
catfp = AppendFileHeaderWithContent(
|
|
4834
4895
|
catfp, catoutlist, extradata, fcontents.read(), checksumtype, formatspecs)
|
|
4835
4896
|
fcontents.close()
|
|
4836
4897
|
if(numfiles > 0):
|
|
4837
4898
|
catfp.write(AppendNullBytes(
|
|
4838
4899
|
[0, 0], formatspecs['format_delimiter']).encode("UTF-8"))
|
|
4839
|
-
if(outfile == "-" or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
4900
|
+
if(outfile == "-" or outfile is None or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
4840
4901
|
catfp = CompressArchiveFile(
|
|
4841
4902
|
catfp, compression, compressionlevel, formatspecs)
|
|
4842
4903
|
try:
|
|
@@ -4855,6 +4916,11 @@ if(rarfile_support):
|
|
|
4855
4916
|
shutil.copyfileobj(catfp, sys.stdout.buffer)
|
|
4856
4917
|
else:
|
|
4857
4918
|
shutil.copyfileobj(catfp, sys.stdout)
|
|
4919
|
+
elif(outfile is None):
|
|
4920
|
+
catfp.seek(0, 0)
|
|
4921
|
+
outvar = catfp.read()
|
|
4922
|
+
catfp.close()
|
|
4923
|
+
return outvar
|
|
4858
4924
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", str(outfile))):
|
|
4859
4925
|
catfp = CompressArchiveFile(
|
|
4860
4926
|
catfp, compression, compressionlevel, formatspecs)
|
|
@@ -4877,7 +4943,7 @@ if(not py7zr_support):
|
|
|
4877
4943
|
if(py7zr_support):
|
|
4878
4944
|
def PackArchiveFileFromSevenZipFile(infile, outfile, compression="auto", compresswholefile=True, compressionlevel=None, checksumtype="crc32", extradata=[], formatspecs=__file_format_dict__, verbose=False, returnfp=False):
|
|
4879
4945
|
formatspecs = FormatSpecsListToDict(formatspecs)
|
|
4880
|
-
if(outfile != "-" and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
4946
|
+
if(outfile != "-" and outfile is not None and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
4881
4947
|
outfile = RemoveWindowsPath(outfile)
|
|
4882
4948
|
checksumtype = checksumtype.lower()
|
|
4883
4949
|
if(not CheckSumSupport(checksumtype, hashlib_guaranteed)):
|
|
@@ -4891,13 +4957,13 @@ if(py7zr_support):
|
|
|
4891
4957
|
if(verbose):
|
|
4892
4958
|
logging.basicConfig(format="%(message)s",
|
|
4893
4959
|
stream=sys.stdout, level=logging.DEBUG)
|
|
4894
|
-
if(outfile != "-" and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
4960
|
+
if(outfile != "-" and outfile is not None and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
4895
4961
|
if(os.path.exists(outfile)):
|
|
4896
4962
|
try:
|
|
4897
4963
|
os.unlink(outfile)
|
|
4898
4964
|
except OSError:
|
|
4899
4965
|
pass
|
|
4900
|
-
if(outfile == "-"):
|
|
4966
|
+
if(outfile == "-" or outfile is None):
|
|
4901
4967
|
verbose = False
|
|
4902
4968
|
catfp = BytesIO()
|
|
4903
4969
|
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
@@ -5059,14 +5125,14 @@ if(py7zr_support):
|
|
|
5059
5125
|
fcontents.seek(0, 0)
|
|
5060
5126
|
ftypehex = format(ftype, 'x').lower()
|
|
5061
5127
|
catoutlist = [ftypehex, fname, flinkname, fsize, fatime, fmtime, fctime, fbtime, fmode, fwinattributes, fcompression,
|
|
5062
|
-
fcsize, fuid, funame, fgid, fgname, fcurfid, fcurinode, flinkcount, fdev, fdev_minor, fdev_major, "+
|
|
5128
|
+
fcsize, fuid, funame, fgid, fgname, fcurfid, fcurinode, flinkcount, fdev, fdev_minor, fdev_major, "+"+str(len(formatspecs['format_delimiter']))]
|
|
5063
5129
|
catfp = AppendFileHeaderWithContent(
|
|
5064
5130
|
catfp, catoutlist, extradata, fcontents.read(), checksumtype, formatspecs)
|
|
5065
5131
|
fcontents.close()
|
|
5066
5132
|
if(numfiles > 0):
|
|
5067
5133
|
catfp.write(AppendNullBytes(
|
|
5068
5134
|
[0, 0], formatspecs['format_delimiter']).encode("UTF-8"))
|
|
5069
|
-
if(outfile == "-" or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
5135
|
+
if(outfile == "-" or outfile is None or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
5070
5136
|
catfp = CompressArchiveFile(
|
|
5071
5137
|
catfp, compression, compressionlevel, formatspecs)
|
|
5072
5138
|
try:
|
|
@@ -5085,6 +5151,11 @@ if(py7zr_support):
|
|
|
5085
5151
|
shutil.copyfileobj(catfp, sys.stdout.buffer)
|
|
5086
5152
|
else:
|
|
5087
5153
|
shutil.copyfileobj(catfp, sys.stdout)
|
|
5154
|
+
elif(outfile is None):
|
|
5155
|
+
catfp.seek(0, 0)
|
|
5156
|
+
outvar = catfp.read()
|
|
5157
|
+
catfp.close()
|
|
5158
|
+
return outvar
|
|
5088
5159
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", str(outfile))):
|
|
5089
5160
|
catfp = CompressArchiveFile(
|
|
5090
5161
|
catfp, compression, compressionlevel, formatspecs)
|
|
@@ -5157,6 +5228,14 @@ def ArchiveFileSeekToFileNum(infile, seekto=0, listonly=False, contentasfile=Tru
|
|
|
5157
5228
|
if(not catfp):
|
|
5158
5229
|
return False
|
|
5159
5230
|
catfp.seek(0, 0)
|
|
5231
|
+
elif(isinstance(infile, bytes)):
|
|
5232
|
+
catfp = BytesIO()
|
|
5233
|
+
catfp.write(infile)
|
|
5234
|
+
catfp.seek(0, 0)
|
|
5235
|
+
catfp = UncompressArchiveFile(catfp, formatspecs)
|
|
5236
|
+
if(not catfp):
|
|
5237
|
+
return False
|
|
5238
|
+
catfp.seek(0, 0)
|
|
5160
5239
|
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", str(infile))):
|
|
5161
5240
|
catfp = download_file_from_internet_file(infile)
|
|
5162
5241
|
catfp.seek(0, 0)
|
|
@@ -5416,6 +5495,14 @@ def ArchiveFileSeekToFileName(infile, seekfile=None, listonly=False, contentasfi
|
|
|
5416
5495
|
if(not catfp):
|
|
5417
5496
|
return False
|
|
5418
5497
|
catfp.seek(0, 0)
|
|
5498
|
+
elif(isinstance(infile, bytes)):
|
|
5499
|
+
catfp = BytesIO()
|
|
5500
|
+
catfp.write(infile)
|
|
5501
|
+
catfp.seek(0, 0)
|
|
5502
|
+
catfp = UncompressArchiveFile(catfp, formatspecs)
|
|
5503
|
+
if(not catfp):
|
|
5504
|
+
return False
|
|
5505
|
+
catfp.seek(0, 0)
|
|
5419
5506
|
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", str(infile))):
|
|
5420
5507
|
catfp = download_file_from_internet_file(infile)
|
|
5421
5508
|
catfp = UncompressArchiveFile(catfp, formatspecs)
|
|
@@ -5688,6 +5775,14 @@ def ArchiveFileValidate(infile, formatspecs=__file_format_dict__, verbose=False,
|
|
|
5688
5775
|
if(not catfp):
|
|
5689
5776
|
return False
|
|
5690
5777
|
catfp.seek(0, 0)
|
|
5778
|
+
elif(isinstance(infile, bytes)):
|
|
5779
|
+
catfp = BytesIO()
|
|
5780
|
+
catfp.write(infile)
|
|
5781
|
+
catfp.seek(0, 0)
|
|
5782
|
+
catfp = UncompressArchiveFile(catfp, formatspecs)
|
|
5783
|
+
if(not catfp):
|
|
5784
|
+
return False
|
|
5785
|
+
catfp.seek(0, 0)
|
|
5691
5786
|
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", str(infile))):
|
|
5692
5787
|
catfp = download_file_from_internet_file(infile)
|
|
5693
5788
|
catfp = UncompressArchiveFile(catfp, formatspecs)
|
|
@@ -5967,6 +6062,14 @@ def ArchiveFileToArray(infile, seekstart=0, seekend=0, listonly=False, contentas
|
|
|
5967
6062
|
if(not catfp):
|
|
5968
6063
|
return False
|
|
5969
6064
|
catfp.seek(0, 0)
|
|
6065
|
+
elif(isinstance(infile, bytes)):
|
|
6066
|
+
catfp = BytesIO()
|
|
6067
|
+
catfp.write(infile)
|
|
6068
|
+
catfp.seek(0, 0)
|
|
6069
|
+
catfp = UncompressArchiveFile(catfp, formatspecs)
|
|
6070
|
+
if(not catfp):
|
|
6071
|
+
return False
|
|
6072
|
+
catfp.seek(0, 0)
|
|
5970
6073
|
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", str(infile))):
|
|
5971
6074
|
catfp = download_file_from_internet_file(infile)
|
|
5972
6075
|
catfp = UncompressArchiveFile(catfp, formatspecs)
|
|
@@ -6387,6 +6490,8 @@ def ListDirToArrayAlt(infiles, dirlistfromtxt=False, followlink=False, listonly=
|
|
|
6387
6490
|
infilelist = list(filter(None, infiles))
|
|
6388
6491
|
elif(isinstance(infiles, (basestring, ))):
|
|
6389
6492
|
infilelist = list(filter(None, [infiles]))
|
|
6493
|
+
if os.stat not in os.supports_follow_symlinks and followlink:
|
|
6494
|
+
followlink = False
|
|
6390
6495
|
if(advancedlist):
|
|
6391
6496
|
GetDirList = ListDirAdvanced(infilelist, followlink, False)
|
|
6392
6497
|
else:
|
|
@@ -6442,8 +6547,8 @@ def ListDirToArrayAlt(infiles, dirlistfromtxt=False, followlink=False, listonly=
|
|
|
6442
6547
|
ftype = 0
|
|
6443
6548
|
if(hasattr(os.path, "isjunction") and os.path.isjunction(fname)):
|
|
6444
6549
|
ftype = 13
|
|
6445
|
-
elif(fstatinfo.st_blocks * 512 < fstatinfo.st_size):
|
|
6446
|
-
|
|
6550
|
+
#elif(fstatinfo.st_blocks * 512 < fstatinfo.st_size):
|
|
6551
|
+
# ftype = 12
|
|
6447
6552
|
elif(stat.S_ISREG(fpremode)):
|
|
6448
6553
|
ftype = 0
|
|
6449
6554
|
elif(stat.S_ISLNK(fpremode)):
|
|
@@ -6504,9 +6609,15 @@ def ListDirToArrayAlt(infiles, dirlistfromtxt=False, followlink=False, listonly=
|
|
|
6504
6609
|
getfdev = GetDevMajorMinor(fdev)
|
|
6505
6610
|
fdev_minor = getfdev[0]
|
|
6506
6611
|
fdev_major = getfdev[1]
|
|
6507
|
-
|
|
6612
|
+
# Types that should be considered zero-length in the archive context:
|
|
6613
|
+
zero_length_types = {1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 13}
|
|
6614
|
+
# Types that have actual data to read:
|
|
6615
|
+
data_types = {0, 7, 12}
|
|
6616
|
+
if ftype in zero_length_types:
|
|
6508
6617
|
fsize = "0"
|
|
6509
|
-
|
|
6618
|
+
elif ftype in data_types:
|
|
6619
|
+
fsize = fstatinfo.st_size
|
|
6620
|
+
else:
|
|
6510
6621
|
fsize = fstatinfo.st_size
|
|
6511
6622
|
fatime = fstatinfo.st_atime
|
|
6512
6623
|
fmtime = fstatinfo.st_mtime
|
|
@@ -6547,7 +6658,7 @@ def ListDirToArrayAlt(infiles, dirlistfromtxt=False, followlink=False, listonly=
|
|
|
6547
6658
|
fcompression = ""
|
|
6548
6659
|
fcsize = 0
|
|
6549
6660
|
fcontents = BytesIO()
|
|
6550
|
-
if
|
|
6661
|
+
if ftype in data_types:
|
|
6551
6662
|
with open(fname, "rb") as fpc:
|
|
6552
6663
|
shutil.copyfileobj(fpc, fcontents)
|
|
6553
6664
|
if(followlink and (ftype == 1 or ftype == 2)):
|
|
@@ -6567,7 +6678,7 @@ def ListDirToArrayAlt(infiles, dirlistfromtxt=False, followlink=False, listonly=
|
|
|
6567
6678
|
extrasizelen = len(extrasizestr)
|
|
6568
6679
|
extrasizelenhex = format(extrasizelen, 'x').lower()
|
|
6569
6680
|
catoutlist = [ftypehex, fname, flinkname, format(int(fsize), 'x').lower(), format(int(fatime), 'x').lower(), format(int(fmtime), 'x').lower(), format(int(fctime), 'x').lower(), format(int(fbtime), 'x').lower(), format(int(fmode), 'x').lower(), format(int(fwinattributes), 'x').lower(), fcompression, format(int(fcsize), 'x').lower(), format(int(fuid), 'x').lower(
|
|
6570
|
-
), funame, format(int(fgid), 'x').lower(), fgname, format(int(fcurfid), 'x').lower(), format(int(fcurinode), 'x').lower(), format(int(flinkcount), 'x').lower(), format(int(fdev), 'x').lower(), format(int(fdev_minor), 'x').lower(), format(int(fdev_major), 'x').lower(), "+
|
|
6681
|
+
), funame, format(int(fgid), 'x').lower(), fgname, format(int(fcurfid), 'x').lower(), format(int(fcurinode), 'x').lower(), format(int(flinkcount), 'x').lower(), format(int(fdev), 'x').lower(), format(int(fdev_minor), 'x').lower(), format(int(fdev_major), 'x').lower(), "+"+str(len(formatspecs['format_delimiter'])), extrasizelenhex, format(catfextrafields, 'x').lower()]
|
|
6571
6682
|
catoutlen = len(catoutlist) + len(extradata) + 3
|
|
6572
6683
|
catoutlenhex = format(catoutlen, 'x').lower()
|
|
6573
6684
|
catoutlist.insert(0, catoutlenhex)
|
|
@@ -6622,7 +6733,7 @@ def ListDirToArrayAlt(infiles, dirlistfromtxt=False, followlink=False, listonly=
|
|
|
6622
6733
|
if(not contentasfile):
|
|
6623
6734
|
fcontents = fcontents.read()
|
|
6624
6735
|
catlist['ffilelist'].append({'fid': fileidnum, 'fidalt': fileidnum, 'fheadersize': int(catheaersize, 16), 'fhstart': catfhstart, 'fhend': catfhend, 'ftype': ftype, '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,
|
|
6625
|
-
'fdev': fdev, 'fminor': fdev_minor, 'fmajor': fdev_major, 'fseeknextfile': "+
|
|
6736
|
+
'fdev': fdev, 'fminor': fdev_minor, 'fmajor': fdev_major, 'fseeknextfile': "+"+str(len(formatspecs['format_delimiter'])), 'fheaderchecksumtype': checksumtype, 'fcontentchecksumtype': checksumtype, 'fnumfields': catfnumfields + 2, 'frawheader': catheaderdata, 'fextrafields': catfextrafields, 'fextrafieldsize': extrasizelen, 'fextralist': extrafieldslist, 'fheaderchecksum': int(catfileheadercshex, 16), 'fcontentchecksum': int(catfilecontentcshex, 16), 'fhascontents': pyhascontents, 'fcontentstart': catfcontentstart, 'fcontentend': catfcontentend, 'fcontentasfile': contentasfile, 'fcontents': fcontents})
|
|
6626
6737
|
fileidnum = fileidnum + 1
|
|
6627
6738
|
return catlist
|
|
6628
6739
|
|
|
@@ -6742,9 +6853,13 @@ def TarFileToArrayAlt(infile, listonly=False, contentasfile=True, checksumtype="
|
|
|
6742
6853
|
fdev = MakeDevAlt(member.devmajor, member.devminor)
|
|
6743
6854
|
fdev_minor = member.devminor
|
|
6744
6855
|
fdev_major = member.devmajor
|
|
6745
|
-
|
|
6856
|
+
# Types that should be considered zero-length in the archive context:
|
|
6857
|
+
zero_length_types = {1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 13}
|
|
6858
|
+
# Types that have actual data to read:
|
|
6859
|
+
data_types = {0, 7, 12}
|
|
6860
|
+
if ftype in zero_length_types:
|
|
6746
6861
|
fsize = "0"
|
|
6747
|
-
elif
|
|
6862
|
+
elif ftype in data_types:
|
|
6748
6863
|
fsize = member.size
|
|
6749
6864
|
else:
|
|
6750
6865
|
fsize = member.size
|
|
@@ -6764,7 +6879,7 @@ def TarFileToArrayAlt(infile, listonly=False, contentasfile=True, checksumtype="
|
|
|
6764
6879
|
fcompression = ""
|
|
6765
6880
|
fcsize = 0
|
|
6766
6881
|
fcontents = BytesIO()
|
|
6767
|
-
if
|
|
6882
|
+
if ftype in data_types:
|
|
6768
6883
|
with tarfp.extractfile(member) as fpc:
|
|
6769
6884
|
shutil.copyfileobj(fpc, fcontents)
|
|
6770
6885
|
fcontents.seek(0, 0)
|
|
@@ -6780,7 +6895,7 @@ def TarFileToArrayAlt(infile, listonly=False, contentasfile=True, checksumtype="
|
|
|
6780
6895
|
extrasizelen = len(extrasizestr)
|
|
6781
6896
|
extrasizelenhex = format(extrasizelen, 'x').lower()
|
|
6782
6897
|
catoutlist = [ftypehex, fname, flinkname, format(int(fsize), 'x').lower(), format(int(fatime), 'x').lower(), format(int(fmtime), 'x').lower(), format(int(fctime), 'x').lower(), format(int(fbtime), 'x').lower(), format(int(fmode), 'x').lower(), format(int(fwinattributes), 'x').lower(), fcompression, format(int(fcsize), 'x').lower(), format(int(fuid), 'x').lower(
|
|
6783
|
-
), funame, format(int(fgid), 'x').lower(), fgname, format(int(fcurfid), 'x').lower(), format(int(fcurinode), 'x').lower(), format(int(flinkcount), 'x').lower(), format(int(fdev), 'x').lower(), format(int(fdev_minor), 'x').lower(), format(int(fdev_major), 'x').lower(), "+
|
|
6898
|
+
), funame, format(int(fgid), 'x').lower(), fgname, format(int(fcurfid), 'x').lower(), format(int(fcurinode), 'x').lower(), format(int(flinkcount), 'x').lower(), format(int(fdev), 'x').lower(), format(int(fdev_minor), 'x').lower(), format(int(fdev_major), 'x').lower(), "+"+str(len(formatspecs['format_delimiter'])), extrasizelenhex, format(catfextrafields, 'x').lower()]
|
|
6784
6899
|
catoutlen = len(catoutlist) + len(extradata) + 3
|
|
6785
6900
|
catoutlenhex = format(catoutlen, 'x').lower()
|
|
6786
6901
|
catoutlist.insert(0, catoutlenhex)
|
|
@@ -6835,7 +6950,7 @@ def TarFileToArrayAlt(infile, listonly=False, contentasfile=True, checksumtype="
|
|
|
6835
6950
|
if(not contentasfile):
|
|
6836
6951
|
fcontents = fcontents.read()
|
|
6837
6952
|
catlist['ffilelist'].append({'fid': fileidnum, 'fidalt': fileidnum, 'fheadersize': int(catheaersize, 16), 'fhstart': catfhstart, 'fhend': catfhend, 'ftype': ftype, '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,
|
|
6838
|
-
'fdev': fdev, 'fminor': fdev_minor, 'fmajor': fdev_major, 'fseeknextfile': "+
|
|
6953
|
+
'fdev': fdev, 'fminor': fdev_minor, 'fmajor': fdev_major, 'fseeknextfile': "+"+str(len(formatspecs['format_delimiter'])), 'fheaderchecksumtype': checksumtype, 'fcontentchecksumtype': checksumtype, 'fnumfields': catfnumfields + 2, 'frawheader': catheaderdata, 'fextrafields': catfextrafields, 'fextrafieldsize': extrasizelen, 'fextralist': extrafieldslist, 'fheaderchecksum': int(catfileheadercshex, 16), 'fcontentchecksum': int(catfilecontentcshex, 16), 'fhascontents': pyhascontents, 'fcontentstart': catfcontentstart, 'fcontentend': catfcontentend, 'fcontentasfile': contentasfile, 'fcontents': fcontents})
|
|
6839
6954
|
fileidnum = fileidnum + 1
|
|
6840
6955
|
return catlist
|
|
6841
6956
|
|
|
@@ -7015,7 +7130,7 @@ def ZipFileToArrayAlt(infile, listonly=False, contentasfile=True, checksumtype="
|
|
|
7015
7130
|
extrasizelen = len(extrasizestr)
|
|
7016
7131
|
extrasizelenhex = format(extrasizelen, 'x').lower()
|
|
7017
7132
|
catoutlist = [ftypehex, fname, flinkname, format(int(fsize), 'x').lower(), format(int(fatime), 'x').lower(), format(int(fmtime), 'x').lower(), format(int(fctime), 'x').lower(), format(int(fbtime), 'x').lower(), format(int(fmode), 'x').lower(), format(int(fwinattributes), 'x').lower(), fcompression, format(int(fcsize), 'x').lower(), format(int(fuid), 'x').lower(
|
|
7018
|
-
), funame, format(int(fgid), 'x').lower(), fgname, format(int(fcurfid), 'x').lower(), format(int(fcurinode), 'x').lower(), format(int(flinkcount), 'x').lower(), format(int(fdev), 'x').lower(), format(int(fdev_minor), 'x').lower(), format(int(fdev_major), 'x').lower(), "+
|
|
7133
|
+
), funame, format(int(fgid), 'x').lower(), fgname, format(int(fcurfid), 'x').lower(), format(int(fcurinode), 'x').lower(), format(int(flinkcount), 'x').lower(), format(int(fdev), 'x').lower(), format(int(fdev_minor), 'x').lower(), format(int(fdev_major), 'x').lower(), "+"+str(len(formatspecs['format_delimiter'])), extrasizelenhex, format(catfextrafields, 'x').lower()]
|
|
7019
7134
|
catoutlen = len(catoutlist) + len(extradata) + 3
|
|
7020
7135
|
catoutlenhex = format(catoutlen, 'x').lower()
|
|
7021
7136
|
catoutlist.insert(0, catoutlenhex)
|
|
@@ -7070,7 +7185,7 @@ def ZipFileToArrayAlt(infile, listonly=False, contentasfile=True, checksumtype="
|
|
|
7070
7185
|
if(not contentasfile):
|
|
7071
7186
|
fcontents = fcontents.read()
|
|
7072
7187
|
catlist['ffilelist'].append({'fid': fileidnum, 'fidalt': fileidnum, 'fheadersize': int(catheaersize, 16), 'fhstart': catfhstart, 'fhend': catfhend, 'ftype': ftype, '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,
|
|
7073
|
-
'fdev': fdev, 'fminor': fdev_minor, 'fmajor': fdev_major, 'fseeknextfile': "+
|
|
7188
|
+
'fdev': fdev, 'fminor': fdev_minor, 'fmajor': fdev_major, 'fseeknextfile': "+"+str(len(formatspecs['format_delimiter'])), 'fheaderchecksumtype': checksumtype, 'fcontentchecksumtype': checksumtype, 'fnumfields': catfnumfields + 2, 'frawheader': catheaderdata, 'fextrafields': catfextrafields, 'fextrafieldsize': extrasizelen, 'fextralist': extrafieldslist, 'fheaderchecksum': int(catfileheadercshex, 16), 'fcontentchecksum': int(catfilecontentcshex, 16), 'fhascontents': pyhascontents, 'fcontentstart': catfcontentstart, 'fcontentend': catfcontentend, 'fcontentasfile': contentasfile, 'fcontents': fcontents})
|
|
7074
7189
|
fileidnum = fileidnum + 1
|
|
7075
7190
|
return catlist
|
|
7076
7191
|
|
|
@@ -7263,7 +7378,7 @@ if(rarfile_support):
|
|
|
7263
7378
|
extrasizelen = len(extrasizestr)
|
|
7264
7379
|
extrasizelenhex = format(extrasizelen, 'x').lower()
|
|
7265
7380
|
catoutlist = [ftypehex, fname, flinkname, format(int(fsize), 'x').lower(), format(int(fatime), 'x').lower(), format(int(fmtime), 'x').lower(), format(int(fctime), 'x').lower(), format(int(fbtime), 'x').lower(), format(int(fmode), 'x').lower(), format(int(fwinattributes), 'x').lower(), fcompression, format(int(fcsize), 'x').lower(), format(int(fuid), 'x').lower(
|
|
7266
|
-
), funame, format(int(fgid), 'x').lower(), fgname, format(int(fcurfid), 'x').lower(), format(int(fcurinode), 'x').lower(), format(int(flinkcount), 'x').lower(), format(int(fdev), 'x').lower(), format(int(fdev_minor), 'x').lower(), format(int(fdev_major), 'x').lower(), "+
|
|
7381
|
+
), funame, format(int(fgid), 'x').lower(), fgname, format(int(fcurfid), 'x').lower(), format(int(fcurinode), 'x').lower(), format(int(flinkcount), 'x').lower(), format(int(fdev), 'x').lower(), format(int(fdev_minor), 'x').lower(), format(int(fdev_major), 'x').lower(), "+"+str(len(formatspecs['format_delimiter'])), extrasizelenhex, format(catfextrafields, 'x').lower()]
|
|
7267
7382
|
catoutlen = len(catoutlist) + len(extradata) + 3
|
|
7268
7383
|
catoutlenhex = format(catoutlen, 'x').lower()
|
|
7269
7384
|
catoutlist.insert(0, catoutlenhex)
|
|
@@ -7318,7 +7433,7 @@ if(rarfile_support):
|
|
|
7318
7433
|
if(not contentasfile):
|
|
7319
7434
|
fcontents = fcontents.read()
|
|
7320
7435
|
catlist['ffilelist'].append({'fid': fileidnum, 'fidalt': fileidnum, 'fheadersize': int(catheaersize, 16), 'fhstart': catfhstart, 'fhend': catfhend, 'ftype': ftype, '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,
|
|
7321
|
-
'fdev': fdev, 'fminor': fdev_minor, 'fmajor': fdev_major, 'fseeknextfile': "+
|
|
7436
|
+
'fdev': fdev, 'fminor': fdev_minor, 'fmajor': fdev_major, 'fseeknextfile': "+"+str(len(formatspecs['format_delimiter'])), 'fheaderchecksumtype': checksumtype, 'fcontentchecksumtype': checksumtype, 'fnumfields': catfnumfields + 2, 'frawheader': catheaderdata, 'fextrafields': catfextrafields, 'fextrafieldsize': extrasizelen, 'fextralist': extrafieldslist, 'fheaderchecksum': int(catfileheadercshex, 16), 'fcontentchecksum': int(catfilecontentcshex, 16), 'fhascontents': pyhascontents, 'fcontentstart': catfcontentstart, 'fcontentend': catfcontentend, 'fcontentasfile': contentasfile, 'fcontents': fcontents})
|
|
7322
7437
|
fileidnum = fileidnum + 1
|
|
7323
7438
|
return catlist
|
|
7324
7439
|
|
|
@@ -7455,7 +7570,7 @@ if(py7zr_support):
|
|
|
7455
7570
|
extrasizelen = len(extrasizestr)
|
|
7456
7571
|
extrasizelenhex = format(extrasizelen, 'x').lower()
|
|
7457
7572
|
catoutlist = [ftypehex, fname, flinkname, format(int(fsize), 'x').lower(), format(int(fatime), 'x').lower(), format(int(fmtime), 'x').lower(), format(int(fctime), 'x').lower(), format(int(fbtime), 'x').lower(), format(int(fmode), 'x').lower(), format(int(fwinattributes), 'x').lower(), fcompression, format(int(fcsize), 'x').lower(), format(int(fuid), 'x').lower(
|
|
7458
|
-
), funame, format(int(fgid), 'x').lower(), fgname, format(int(fcurfid), 'x').lower(), format(int(fcurinode), 'x').lower(), format(int(flinkcount), 'x').lower(), format(int(fdev), 'x').lower(), format(int(fdev_minor), 'x').lower(), format(int(fdev_major), 'x').lower(), "+
|
|
7573
|
+
), funame, format(int(fgid), 'x').lower(), fgname, format(int(fcurfid), 'x').lower(), format(int(fcurinode), 'x').lower(), format(int(flinkcount), 'x').lower(), format(int(fdev), 'x').lower(), format(int(fdev_minor), 'x').lower(), format(int(fdev_major), 'x').lower(), "+"+str(len(formatspecs['format_delimiter'])), extrasizelenhex, format(catfextrafields, 'x').lower()]
|
|
7459
7574
|
catoutlen = len(catoutlist) + len(extradata) + 3
|
|
7460
7575
|
catoutlenhex = format(catoutlen, 'x').lower()
|
|
7461
7576
|
catoutlist.insert(0, catoutlenhex)
|
|
@@ -7510,7 +7625,7 @@ if(py7zr_support):
|
|
|
7510
7625
|
if(not contentasfile):
|
|
7511
7626
|
fcontents = fcontents.read()
|
|
7512
7627
|
catlist['ffilelist'].append({'fid': fileidnum, 'fidalt': fileidnum, 'fheadersize': int(catheaersize, 16), 'fhstart': catfhstart, 'fhend': catfhend, 'ftype': ftype, '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,
|
|
7513
|
-
'fdev': fdev, 'fminor': fdev_minor, 'fmajor': fdev_major, 'fseeknextfile': "+
|
|
7628
|
+
'fdev': fdev, 'fminor': fdev_minor, 'fmajor': fdev_major, 'fseeknextfile': "+"+str(len(formatspecs['format_delimiter'])), 'fheaderchecksumtype': checksumtype, 'fcontentchecksumtype': checksumtype, 'fnumfields': catfnumfields + 2, 'frawheader': catheaderdata, 'fextrafields': catfextrafields, 'fextrafieldsize': extrasizelen, 'fextralist': extrafieldslist, 'fheaderchecksum': int(catfileheadercshex, 16), 'fcontentchecksum': int(catfilecontentcshex, 16), 'fhascontents': pyhascontents, 'fcontentstart': catfcontentstart, 'fcontentend': catfcontentend, 'fcontentasfile': contentasfile, 'fcontents': fcontents})
|
|
7514
7629
|
fileidnum = fileidnum + 1
|
|
7515
7630
|
return catlist
|
|
7516
7631
|
|
|
@@ -7619,11 +7734,11 @@ def RePackArchiveFile(infile, outfile, compression="auto", compresswholefile=Tru
|
|
|
7619
7734
|
if(isinstance(infile, dict)):
|
|
7620
7735
|
listcatfiles = infile
|
|
7621
7736
|
else:
|
|
7622
|
-
if(infile != "-" and not hasattr(infile, "read") and not hasattr(infile, "write")):
|
|
7737
|
+
if(infile != "-" and not isinstance(infile, bytes) and not hasattr(infile, "read") and not hasattr(infile, "write")):
|
|
7623
7738
|
infile = RemoveWindowsPath(infile)
|
|
7624
7739
|
listcatfiles = ArchiveFileToArray(
|
|
7625
7740
|
infile, seekstart, seekend, False, True, skipchecksum, formatspecs, returnfp)
|
|
7626
|
-
if(outfile != "-" and not hasattr(infile, "read") and not hasattr(outfile, "write")):
|
|
7741
|
+
if(outfile != "-" and not isinstance(infile, bytes) and not hasattr(infile, "read") and not hasattr(outfile, "write")):
|
|
7627
7742
|
outfile = RemoveWindowsPath(outfile)
|
|
7628
7743
|
checksumtype = checksumtype.lower()
|
|
7629
7744
|
if(not CheckSumSupport(checksumtype, hashlib_guaranteed)):
|
|
@@ -7637,7 +7752,7 @@ def RePackArchiveFile(infile, outfile, compression="auto", compresswholefile=Tru
|
|
|
7637
7752
|
if(verbose):
|
|
7638
7753
|
logging.basicConfig(format="%(message)s",
|
|
7639
7754
|
stream=sys.stdout, level=logging.DEBUG)
|
|
7640
|
-
if(outfile != "-" and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
7755
|
+
if(outfile != "-" and outfile is not None and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
|
|
7641
7756
|
if(os.path.exists(outfile)):
|
|
7642
7757
|
try:
|
|
7643
7758
|
os.unlink(outfile)
|
|
@@ -7645,7 +7760,7 @@ def RePackArchiveFile(infile, outfile, compression="auto", compresswholefile=Tru
|
|
|
7645
7760
|
pass
|
|
7646
7761
|
if(not listcatfiles):
|
|
7647
7762
|
return False
|
|
7648
|
-
if(outfile == "-"):
|
|
7763
|
+
if(outfile == "-" or outfile is None):
|
|
7649
7764
|
verbose = False
|
|
7650
7765
|
catfp = BytesIO()
|
|
7651
7766
|
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
@@ -7840,7 +7955,7 @@ def RePackArchiveFile(infile, outfile, compression="auto", compresswholefile=Tru
|
|
|
7840
7955
|
if(lcfx > 0):
|
|
7841
7956
|
catfp.write(AppendNullBytes(
|
|
7842
7957
|
[0, 0], formatspecs['format_delimiter']).encode("UTF-8"))
|
|
7843
|
-
if(outfile == "-" or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
7958
|
+
if(outfile == "-" or outfile is None or hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
7844
7959
|
catfp = CompressArchiveFile(
|
|
7845
7960
|
catfp, compression, compressionlevel, formatspecs)
|
|
7846
7961
|
try:
|
|
@@ -7859,6 +7974,11 @@ def RePackArchiveFile(infile, outfile, compression="auto", compresswholefile=Tru
|
|
|
7859
7974
|
shutil.copyfileobj(catfp, sys.stdout.buffer)
|
|
7860
7975
|
else:
|
|
7861
7976
|
shutil.copyfileobj(catfp, sys.stdout)
|
|
7977
|
+
elif(outfile is None):
|
|
7978
|
+
catfp.seek(0, 0)
|
|
7979
|
+
outvar = catfp.read()
|
|
7980
|
+
catfp.close()
|
|
7981
|
+
return outvar
|
|
7862
7982
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", str(outfile))):
|
|
7863
7983
|
catfp = CompressArchiveFile(
|
|
7864
7984
|
catfp, compression, compressionlevel, formatspecs)
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
Copyright 2016-2024 Game Maker 2k - http://intdb.sourceforge.net/
|
|
14
14
|
Copyright 2016-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
|
|
15
15
|
|
|
16
|
-
$FileInfo: setup.py - Last Update: 12/
|
|
16
|
+
$FileInfo: setup.py - Last Update: 12/21/2024 Ver. 0.15.14 RC 1 - Author: cooldude2k $
|
|
17
17
|
'''
|
|
18
18
|
|
|
19
19
|
import os
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|