Skip to content

Commit 988f660

Browse files
authored
Add files via upload
1 parent 6846650 commit 988f660

1 file changed

Lines changed: 55 additions & 48 deletions

File tree

pycatfile.py

Lines changed: 55 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2785,6 +2785,7 @@ def ReadFileDataWithContent(fp, filestart=0, listonly=False, uncompress=True, sk
27852785
break
27862786
flist.append(HeaderOut)
27872787
countnum = countnum + 1
2788+
outlist.update({'fp': fp})
27882789
return flist
27892790

27902791

@@ -3294,6 +3295,33 @@ def ReadInMultipleFilesWithContentToArray(infile, fmttype="auto", filestart=0, s
32943295
return ReadInMultipleFileWithContentToArray(infile, fmttype, filestart, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, formatspecs, seektoend)
32953296

32963297

3298+
def ReadInStackedFileWithContentToArray(infile, fmttype="auto", filestart=0, seekstart=0, seekend=0, listonly=False, contentasfile=True, uncompress=True, skipchecksum=False, formatspecs=__file_format_multi_dict__, seektoend=False):
3299+
outretval = []
3300+
outstartfile = filestart
3301+
while True:
3302+
outarray = ReadInFileWithContentToArray(infile, fmttype, filestart, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, formatspecs, seektoend)
3303+
if outarray is False: # stop when function signals False
3304+
break
3305+
infile = outarray['fp']
3306+
print(infile.tell())
3307+
outretval.append(outarray)
3308+
return outretval
3309+
3310+
3311+
def ReadInMultipleStackedFileWithContentToArray(infile, fmttype="auto", filestart=0, seekstart=0, seekend=0, listonly=False, contentasfile=True, uncompress=True, skipchecksum=False, formatspecs=__file_format_multi_dict__, seektoend=False):
3312+
if(isinstance(infile, (list, tuple, ))):
3313+
pass
3314+
else:
3315+
infile = [infile]
3316+
outretval = {}
3317+
for curfname in infile:
3318+
curretfile[curfname] = ReadInStackedFileWithContentToArray(curfname, fmttype, filestart, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, formatspecs, seektoend)
3319+
return outretval
3320+
3321+
def ReadInMultipleStackedFilesWithContentToArray(infile, fmttype="auto", filestart=0, seekstart=0, seekend=0, listonly=False, contentasfile=True, uncompress=True, skipchecksum=False, formatspecs=__file_format_multi_dict__, seektoend=False):
3322+
return ReadInMultipleStackedFileWithContentToArray(infile, fmttype, filestart, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, formatspecs, seektoend)
3323+
3324+
32973325
def ReadInFileWithContentToList(infile, fmttype="auto", filestart=0, seekstart=0, seekend=0, listonly=False, contentasfile=True, uncompress=True, skipchecksum=False, formatspecs=__file_format_multi_dict__, seektoend=False):
32983326
if(IsNestedDict(formatspecs) and fmttype!="auto" and fmttype in formatspecs):
32993327
formatspecs = formatspecs[fmttype]
@@ -4044,12 +4072,6 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
40444072
fcsize, fuid, funame, fgid, fgname, fcurfid, fcurinode, flinkcount, fdev, fdev_minor, fdev_major, "+"+str(len(formatspecs['format_delimiter']))]
40454073
AppendFileHeaderWithContent(
40464074
fp, tmpoutlist, extradata, jsondata, fcontents.read(), [checksumtype[1], checksumtype[2], checksumtype[3]], formatspecs)
4047-
if(numfiles > 0):
4048-
try:
4049-
fp.write(AppendNullBytes(
4050-
["0", "0"], formatspecs['format_delimiter']))
4051-
except OSError:
4052-
return False
40534075
fp.seek(0, 0)
40544076
return fp
40554077

@@ -4113,12 +4135,6 @@ def AppendListsWithContent(inlist, fp, dirlistfromtxt=False, filevalues=[], extr
41134135
fcontents.seek(0, 0)
41144136
AppendFileHeaderWithContent(
41154137
fp, tmpoutlist, extradata, jsondata, fcontents.read(), [checksumtype[1], checksumtype[2], checksumtype[3]], formatspecs)
4116-
if(numfiles > 0):
4117-
try:
4118-
fp.write(AppendNullBytes(
4119-
["0", "0"], formatspecs['format_delimiter']))
4120-
except OSError:
4121-
return False
41224138
return fp
41234139

41244140

@@ -5511,12 +5527,6 @@ def PackCatFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", compress
55115527
AppendFileHeaderWithContent(
55125528
fp, tmpoutlist, extradata, jsondata, fcontents.read(), [checksumtype[1], checksumtype[2], checksumtype[3]], formatspecs)
55135529
fcontents.close()
5514-
if(numfiles > 0):
5515-
try:
5516-
fp.write(AppendNullBytes(
5517-
["0", "0"], formatspecs['format_delimiter']))
5518-
except OSError:
5519-
return False
55205530
if(outfile == "-" or outfile is None or hasattr(outfile, "read") or hasattr(outfile, "write")):
55215531
fp = CompressOpenFileAlt(
55225532
fp, compression, compressionlevel, compressionuselist, formatspecs)
@@ -5812,12 +5822,6 @@ def PackCatFileFromTarFile(infile, outfile, fmttype="auto", compression="auto",
58125822
AppendFileHeaderWithContent(
58135823
fp, tmpoutlist, extradata, jsondata, fcontents.read(), [checksumtype[1], checksumtype[2], checksumtype[3]], formatspecs)
58145824
fcontents.close()
5815-
if(numfiles > 0):
5816-
try:
5817-
fp.write(AppendNullBytes(
5818-
["0", "0"], formatspecs['format_delimiter']))
5819-
except OSError:
5820-
return False
58215825
if(outfile == "-" or outfile is None or hasattr(outfile, "read") or hasattr(outfile, "write")):
58225826
fp = CompressOpenFileAlt(
58235827
fp, compression, compressionlevel, compressionuselist, formatspecs)
@@ -6106,12 +6110,6 @@ def PackCatFileFromZipFile(infile, outfile, fmttype="auto", compression="auto",
61066110
AppendFileHeaderWithContent(
61076111
fp, tmpoutlist, extradata, jsondata, fcontents.read(), [checksumtype[1], checksumtype[2], checksumtype[3]], formatspecs)
61086112
fcontents.close()
6109-
if(numfiles > 0):
6110-
try:
6111-
fp.write(AppendNullBytes(
6112-
["0", "0"], formatspecs['format_delimiter']))
6113-
except OSError:
6114-
return False
61156113
if(outfile == "-" or outfile is None or hasattr(outfile, "read") or hasattr(outfile, "write")):
61166114
fp = CompressOpenFileAlt(
61176115
fp, compression, compressionlevel, compressionuselist, formatspecs)
@@ -6426,12 +6424,6 @@ def PackCatFileFromRarFile(infile, outfile, fmttype="auto", compression="auto",
64266424
AppendFileHeaderWithContent(
64276425
fp, tmpoutlist, extradata, jsondata, fcontents.read(), [checksumtype[1], checksumtype[2], checksumtype[3]], formatspecs)
64286426
fcontents.close()
6429-
if(numfiles > 0):
6430-
try:
6431-
fp.write(AppendNullBytes(
6432-
["0", "0"], formatspecs['format_delimiter']))
6433-
except OSError:
6434-
return False
64356427
if(outfile == "-" or outfile is None or hasattr(outfile, "read") or hasattr(outfile, "write")):
64366428
fp = CompressOpenFileAlt(
64376429
fp, compression, compressionlevel, compressionuselist, formatspecs)
@@ -6680,12 +6672,6 @@ def PackCatFileFromSevenZipFile(infile, outfile, fmttype="auto", compression="au
66806672
AppendFileHeaderWithContent(
66816673
fp, tmpoutlist, extradata, jsondata, fcontents.read(), [checksumtype[1], checksumtype[2], checksumtype[3]], formatspecs)
66826674
fcontents.close()
6683-
if(numfiles > 0):
6684-
try:
6685-
fp.write(AppendNullBytes(
6686-
["0", "0"], formatspecs['format_delimiter']))
6687-
except OSError:
6688-
return False
66896675
if(outfile == "-" or outfile is None or hasattr(outfile, "read") or hasattr(outfile, "write")):
66906676
fp = CompressOpenFileAlt(
66916677
fp, compression, compressionlevel, compressionuselist, formatspecs)
@@ -7569,6 +7555,33 @@ def MultipleCatFilesToArray(infile, fmttype="auto", filestart=0, seekstart=0, se
75697555
return MultipleCatFileToArray(infile, fmttype, filestart, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, formatspecs, seektoend, returnfp)
75707556

75717557

7558+
def StackedCatFileToArray(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):
7559+
outretval = []
7560+
outstartfile = filestart
7561+
while True:
7562+
outarray = CatFileToArray(infile, fmttype, outstartfile, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, formatspecs, seektoend, True)
7563+
if outarray is False: # stop when function signals False
7564+
break
7565+
infile = outarray['fp']
7566+
print(infile.tell())
7567+
outretval.append(outarray)
7568+
return outretval
7569+
7570+
7571+
def MultipleStackedCatFileToArray(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):
7572+
if(isinstance(infile, (list, tuple, ))):
7573+
pass
7574+
else:
7575+
infile = [infile]
7576+
outretval = {}
7577+
for curfname in infile:
7578+
curretfile[curfname] = StackedCatFileToArray(curfname, fmttype, filestart, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, formatspecs, seektoend, returnfp)
7579+
return outretval
7580+
7581+
def MultipleStackedCatFilesToArray(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):
7582+
return MultipleStackedCatFileToArray(infile, fmttype, filestart, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, formatspecs, seektoend, returnfp)
7583+
7584+
75727585
def CatFileStringToArray(instr, filestart=0, seekstart=0, seekend=0, listonly=False, contentasfile=True, skipchecksum=False, formatspecs=__file_format_multi_dict__, seektoend=False, returnfp=False):
75737586
checkcompressfile = CheckCompressionSubType(infile, formatspecs, filestart, True)
75747587
if(IsNestedDict(formatspecs) and checkcompressfile in formatspecs):
@@ -7961,12 +7974,6 @@ def RePackCatFile(infile, outfile, fmttype="auto", compression="auto", compressw
79617974
fcontents.close()
79627975
lcfi = lcfi + 1
79637976
reallcfi = reallcfi + 1
7964-
if(lcfx > 0):
7965-
try:
7966-
fp.write(AppendNullBytes(
7967-
["0", "0"], formatspecs['format_delimiter']))
7968-
except OSError:
7969-
return False
79707977
if(outfile == "-" or outfile is None or hasattr(outfile, "read") or hasattr(outfile, "write")):
79717978
fp = CompressOpenFileAlt(
79727979
fp, compression, compressionlevel, compressionuselist, formatspecs)

0 commit comments

Comments
 (0)