Skip to content

Commit 3df519b

Browse files
Add files via upload
1 parent a69c421 commit 3df519b

1 file changed

Lines changed: 29 additions & 17 deletions

File tree

pyarchivefile.py

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5932,9 +5932,9 @@ def ReadInMultipleFileWithContentToArray(infile, fmttype="auto", filestart=0, se
59325932
pass
59335933
else:
59345934
infile = [infile]
5935-
outretval = {}
5935+
outretval = []
59365936
for curfname in infile:
5937-
outretval[curfname] = ReadInFileWithContentToArray(curfname, fmttype, filestart, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, formatspecs, seektoend)
5937+
outretval.append(ReadInFileWithContentToArray(curfname, fmttype, filestart, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, formatspecs, seektoend))
59385938
return outretval
59395939

59405940
def ReadInMultipleFilesWithContentToArray(infile, fmttype="auto", filestart=0, seekstart=0, seekend=0, listonly=False, contentasfile=True, uncompress=True, skipchecksum=False, formatspecs=__file_format_multi_dict__, seektoend=False):
@@ -6013,35 +6013,48 @@ def ReadInFileWithContentToList(infile, fmttype="auto", filestart=0, seekstart=0
60136013
outfsize = fp.tell()
60146014
fp.seek(filestart, 0)
60156015
currentfilepos = fp.tell()
6016+
if(not isinstance(infile, FileLikeAdapter)):
6017+
6018+
# For uncompressed: optional mmap
6019+
mm = None
6020+
try:
6021+
base = _extract_base_fp(fp)
6022+
if base is not None:
6023+
mm = mmap.mmap(base.fileno(), 0, access=mmap.ACCESS_READ if "r" in mode else mmap.ACCESS_WRITE)
6024+
except Exception:
6025+
mm = None # fallback to normal file stream
6026+
readfp = FileLikeAdapter(fp, mode="rb", mm=mm)
6027+
else:
6028+
readfp = fp
60166029
ArchiveList = []
60176030
while True:
60186031
if currentfilepos >= outfsize: # stop when function signals False
60196032
break
6020-
oldfppos = fp.tell()
6021-
compresscheck = CheckCompressionType(fp, formatspecs, currentfilepos, False)
6033+
oldfppos = readfp.tell()
6034+
compresscheck = CheckCompressionType(readfp, formatspecs, currentfilepos, False)
60226035
if(IsNestedDict(formatspecs) and compresscheck in formatspecs):
60236036
pass
60246037
else:
6025-
checkcompressfile = CheckCompressionSubType(fp, formatspecs, currentfilepos, False)
6038+
checkcompressfile = CheckCompressionSubType(readfp, formatspecs, currentfilepos, False)
60266039
if(IsNestedDict(formatspecs) and checkcompressfile in formatspecs):
60276040
pass
60286041
else:
60296042
break
6030-
fp.seek(oldfppos, 0)
6043+
readfp.seek(oldfppos, 0)
60316044
if(compresscheck in formatspecs):
60326045
if currentfilepos >= outfsize: # stop when function signals False
60336046
break
6034-
oldfppos = fp.tell()
6035-
compresscheck = CheckCompressionType(fp, formatspecs, currentfilepos, False)
6047+
oldfppos = readfp.tell()
6048+
compresscheck = CheckCompressionType(readfp, formatspecs, currentfilepos, False)
60366049
if(IsNestedDict(formatspecs) and compresscheck in formatspecs):
60376050
informatspecs = formatspecs[compresscheck]
60386051
else:
60396052
break
6040-
fp.seek(oldfppos, 0)
6041-
ArchiveList.append(ReadFileDataWithContentToList(fp, currentfilepos, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, informatspecs, seektoend))
6042-
currentfilepos = fp.tell()
6053+
readfp.seek(oldfppos, 0)
6054+
ArchiveList.append(ReadFileDataWithContentToList(readfp, currentfilepos, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, informatspecs, seektoend))
6055+
currentfilepos = readfp.tell()
60436056
else:
6044-
infp = UncompressFileAlt(fp, formatspecs, currentfilepos)
6057+
infp = UncompressFileAlt(readfp, formatspecs, currentfilepos)
60456058
infp.seek(0, 0)
60466059
currentinfilepos = infp.tell()
60476060
try:
@@ -6064,8 +6077,7 @@ def ReadInFileWithContentToList(infile, fmttype="auto", filestart=0, seekstart=0
60646077
infp.seek(oldinfppos, 0)
60656078
ArchiveList.append(ReadFileDataWithContentToList(infp, currentinfilepos, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, informatspecs, seektoend))
60666079
currentinfilepos = infp.tell()
6067-
infp.close()
6068-
currentfilepos = fp.tell()
6080+
currentfilepos = readfp.tell()
60696081
return ArchiveList
60706082

60716083

@@ -6076,7 +6088,7 @@ def ReadInMultipleFileWithContentToList(infile, fmttype="auto", filestart=0, see
60766088
infile = [infile]
60776089
outretval = {}
60786090
for curfname in infile:
6079-
outretval[curfname] = ReadInFileWithContentToList(curfname, fmttype, filestart, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, formatspecs, seektoend)
6091+
outretval.append(ReadInFileWithContentToList(curfname, fmttype, filestart, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, formatspecs, seektoend))
60806092
return outretval
60816093

60826094
def ReadInMultipleFilesWithContentToList(infile, fmttype="auto", filestart=0, seekstart=0, seekend=0, listonly=False, contentasfile=True, uncompress=True, skipchecksum=False, formatspecs=__file_format_multi_dict__, seektoend=False):
@@ -10500,9 +10512,9 @@ def MultipleArchiveFileToArray(infile, fmttype="auto", filestart=0, seekstart=0,
1050010512
pass
1050110513
else:
1050210514
infile = [infile]
10503-
outretval = {}
10515+
outretval = []
1050410516
for curfname in infile:
10505-
outretval[curfname] = ArchiveFileToArray(curfname, fmttype, filestart, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, formatspecs, seektoend, returnfp)
10517+
outretval.append(ArchiveFileToArray(curfname, fmttype, filestart, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, formatspecs, seektoend, returnfp))
1050610518
return outretval
1050710519

1050810520
def MultipleArchiveFilesToArray(infile, fmttype="auto", filestart=0, seekstart=0, seekend=0, listonly=False, contentasfile=True, uncompress=True, skipchecksum=False, formatspecs=__file_format_multi_dict__, seektoend=False, returnfp=False):

0 commit comments

Comments
 (0)