@@ -7470,6 +7470,15 @@ def ListDirToArrayAlt(infiles, dirlistfromtxt=False, followlink=False, listonly=
74707470 fhencoding = "UTF-8"
74717471 tmpcatfile = BytesIO ()
74727472 AppendFileHeader (tmpcatfile , fnumfiles , fhencoding , [], checksumtype [0 ], formatspecs )
7473+ tmpcatfile .seek (0 , 0 )
7474+ catheaderver = str (int (formatspecs ['format_ver' ].replace ("." , "" )))
7475+ catstring = tmpcatfile .read (formatspecs ['format_len' ] + len (catheaderver )).decode ("UTF-8" )
7476+ catdelszie = len (formatspecs ['format_delimiter' ])
7477+ catdel = tmpcatfile .read (catdelszie ).decode ("UTF-8" )
7478+ if (catstring != formatspecs ['format_magic' ]+ catheaderver ):
7479+ return False
7480+ if (catdel != formatspecs ['format_delimiter' ]):
7481+ return False
74737482 if (formatspecs ['new_style' ]):
74747483 catheader = ReadFileHeaderDataBySize (
74757484 tmpcatfile , formatspecs ['format_delimiter' ])
@@ -7499,13 +7508,12 @@ def ListDirToArrayAlt(infiles, dirlistfromtxt=False, followlink=False, listonly=
74997508 return False
75007509 fileheader = tmpcatfile .read ()
75017510 tmpcatfile .close ()
7502- catversion = re .findall ("([\\ d]+)" , fileheader )
7503- catversions = re .search ('(.*?)(\\ d+)' , fileheader ).groups ()
7511+ catversions = re .search ('(.*?)(\\ d+)' , catstring ).groups ()
75047512 catfileheadercshex = GetFileChecksum (
7505- fileheader , checksumtype [0 ], True , formatspecs )
7513+ fileheader , checksumtype [0 ], False , formatspecs )
75067514 fheadtell = len (fileheader )
75077515 catlist = {'fnumfiles' : fnumfiles , 'fformat' : catversions [0 ], 'fcompression' : "" , 'fencoding' : fhencoding , 'fversion' : catversions [1 ], 'fostype' : fostype ,
7508- 'fformatspecs' : formatspecs , 'fchecksumtype' : checksumtype [0 ], 'fheaderchecksum' : catfileheadercshex , 'frawheader' : catheader , 'ffilelist' : []}
7516+ 'fformatspecs' : formatspecs , 'fchecksumtype' : checksumtype [0 ], 'fheaderchecksum' : catfileheadercshex , 'frawheader' : [ catstring ] + catheader , 'ffilelist' : []}
75097517 FullSizeFilesAlt = 0
75107518 for curfname in GetDirList :
75117519 catfhstart = fheadtell
@@ -7644,10 +7652,12 @@ def ListDirToArrayAlt(infiles, dirlistfromtxt=False, followlink=False, listonly=
76447652 if ftype in data_types :
76457653 with open (fname , "rb" ) as fpc :
76467654 shutil .copyfileobj (fpc , fcontents )
7655+ fcsize = fcontents .tell ()
76477656 if (followlink and (ftype == 1 or ftype == 2 )):
76487657 flstatinfo = os .stat (flinkname )
76497658 with open (flinkname , "rb" ) as fpc :
76507659 shutil .copyfileobj (fpc , fcontents )
7660+ fcsize = fcontents .tell ()
76517661 fcontents .seek (0 , 0 )
76527662 ftypehex = format (ftype , 'x' ).lower ()
76537663 extrafields = len (extradata )
@@ -7661,7 +7671,7 @@ def ListDirToArrayAlt(infiles, dirlistfromtxt=False, followlink=False, listonly=
76617671 extrasizelen = len (extrasizestr )
76627672 extrasizelenhex = format (extrasizelen , 'x' ).lower ()
76637673 catoutlist = [ftypehex , fencoding , 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 (
7664- ), 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 ()]
7674+ ), funame , format (int (fgid ), 'x' ).lower (), fgname , format (int (fcurfid ), 'x' ).lower (), fcurinode , 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 ()]
76657675 catoutlen = len (catoutlist ) + len (extradata ) + 3
76667676 catoutlenhex = format (catoutlen , 'x' ).lower ()
76677677 catoutlist .insert (0 , catoutlenhex )
@@ -7795,6 +7805,15 @@ def TarFileToArrayAlt(infile, listonly=False, contentasfile=True, checksumtype=[
77957805 fhencoding = "UTF-8"
77967806 tmpcatfile = BytesIO ()
77977807 AppendFileHeader (tmpcatfile , fnumfiles , fhencoding , [], checksumtype [0 ], formatspecs )
7808+ tmpcatfile .seek (0 , 0 )
7809+ catheaderver = str (int (formatspecs ['format_ver' ].replace ("." , "" )))
7810+ catstring = tmpcatfile .read (formatspecs ['format_len' ] + len (catheaderver )).decode ("UTF-8" )
7811+ catdelszie = len (formatspecs ['format_delimiter' ])
7812+ catdel = tmpcatfile .read (catdelszie ).decode ("UTF-8" )
7813+ if (catstring != formatspecs ['format_magic' ]+ catheaderver ):
7814+ return False
7815+ if (catdel != formatspecs ['format_delimiter' ]):
7816+ return False
77987817 if (formatspecs ['new_style' ]):
77997818 catheader = ReadFileHeaderDataBySize (
78007819 tmpcatfile , formatspecs ['format_delimiter' ])
@@ -7824,13 +7843,12 @@ def TarFileToArrayAlt(infile, listonly=False, contentasfile=True, checksumtype=[
78247843 return False
78257844 fileheader = tmpcatfile .read ()
78267845 tmpcatfile .close ()
7827- catversion = re .findall ("([\\ d]+)" , fileheader )
7828- catversions = re .search ('(.*?)(\\ d+)' , fileheader ).groups ()
7846+ catversions = re .search ('(.*?)(\\ d+)' , catstring ).groups ()
78297847 catfileheadercshex = GetFileChecksum (
7830- fileheader , checksumtype [0 ], True , formatspecs )
7848+ fileheader , checksumtype [0 ], False , formatspecs )
78317849 fheadtell = len (fileheader )
78327850 catlist = {'fnumfiles' : fnumfiles , 'fformat' : catversions [0 ], 'fcompression' : "" , 'fencoding' : fhencoding , 'fversion' : catversions [1 ], 'fostype' : fostype ,
7833- 'fformatspecs' : formatspecs , 'fchecksumtype' : checksumtype [0 ], 'fheaderchecksum' : catfileheadercshex , 'frawheader' : catheader , 'ffilelist' : []}
7851+ 'fformatspecs' : formatspecs , 'fchecksumtype' : checksumtype [0 ], 'fheaderchecksum' : catfileheadercshex , 'frawheader' : [ catstring ] + catheader , 'ffilelist' : []}
78347852 for member in sorted (tarfp .getmembers (), key = lambda x : x .name ):
78357853 catfhstart = fheadtell
78367854 fencoding = "UTF-8"
@@ -7917,6 +7935,7 @@ def TarFileToArrayAlt(infile, listonly=False, contentasfile=True, checksumtype=[
79177935 if ftype in data_types :
79187936 fpc = tarfp .extractfile (member )
79197937 shutil .copyfileobj (fpc , fcontents )
7938+ fcsize = fcontents .tell ()
79207939 fcontents .seek (0 , 0 )
79217940 ftypehex = format (ftype , 'x' ).lower ()
79227941 extrafields = len (extradata )
@@ -8040,6 +8059,15 @@ def ZipFileToArrayAlt(infile, listonly=False, contentasfile=True, checksumtype=[
80408059 fhencoding = "UTF-8"
80418060 tmpcatfile = BytesIO ()
80428061 AppendFileHeader (tmpcatfile , fnumfiles , fhencoding , [], checksumtype [0 ], formatspecs )
8062+ tmpcatfile .seek (0 , 0 )
8063+ catheaderver = str (int (formatspecs ['format_ver' ].replace ("." , "" )))
8064+ catstring = tmpcatfile .read (formatspecs ['format_len' ] + len (catheaderver )).decode ("UTF-8" )
8065+ catdelszie = len (formatspecs ['format_delimiter' ])
8066+ catdel = tmpcatfile .read (catdelszie ).decode ("UTF-8" )
8067+ if (catstring != formatspecs ['format_magic' ]+ catheaderver ):
8068+ return False
8069+ if (catdel != formatspecs ['format_delimiter' ]):
8070+ return False
80438071 if (formatspecs ['new_style' ]):
80448072 catheader = ReadFileHeaderDataBySize (
80458073 tmpcatfile , formatspecs ['format_delimiter' ])
@@ -8069,13 +8097,12 @@ def ZipFileToArrayAlt(infile, listonly=False, contentasfile=True, checksumtype=[
80698097 return False
80708098 fileheader = tmpcatfile .read ()
80718099 tmpcatfile .close ()
8072- catversion = re .findall ("([\\ d]+)" , fileheader )
8073- catversions = re .search ('(.*?)(\\ d+)' , fileheader ).groups ()
8100+ catversions = re .search ('(.*?)(\\ d+)' , catstring ).groups ()
80748101 catfileheadercshex = GetFileChecksum (
8075- fileheader , checksumtype [0 ], True , formatspecs )
8102+ fileheader , checksumtype [0 ], False , formatspecs )
80768103 fheadtell = len (fileheader )
80778104 catlist = {'fnumfiles' : fnumfiles , 'fformat' : catversions [0 ], 'fcompression' : "" , 'fencoding' : fhencoding , 'fversion' : catversions [1 ], 'fostype' : fostype ,
8078- 'fformatspecs' : formatspecs , 'fchecksumtype' : checksumtype [0 ], 'fheaderchecksum' : catfileheadercshex , 'frawheader' : catheader , 'ffilelist' : []}
8105+ 'fformatspecs' : formatspecs , 'fchecksumtype' : checksumtype [0 ], 'fheaderchecksum' : catfileheadercshex , 'frawheader' : [ catstring ] + catheader , 'ffilelist' : []}
80798106 for member in sorted (zipfp .infolist (), key = lambda x : x .filename ):
80808107 catfhstart = fheadtell
80818108 fencoding = "UTF-8"
@@ -8185,6 +8212,7 @@ def ZipFileToArrayAlt(infile, listonly=False, contentasfile=True, checksumtype=[
81858212 fcontents = BytesIO ()
81868213 if (ftype == 0 ):
81878214 fcontents .write (zipfp .read (member .filename ))
8215+ fcsize = fcontents .tell ()
81888216 fcontents .seek (0 , 0 )
81898217 ftypehex = format (ftype , 'x' ).lower ()
81908218 extrafields = len (extradata )
@@ -8285,13 +8313,21 @@ def RarFileToArrayAlt(infile, listonly=False, contentasfile=True, checksumtype=[
82858313 fileheaderver = str (int (catver .replace ("." , "" )))
82868314 fileheader = AppendNullByte (
82878315 formatspecs ['format_magic' ] + fileheaderver , formatspecs ['format_delimiter' ])
8288- catversion = re .findall ("([\\ d]+)" , fileheader )
8289- catversions = re .search ('(.*?)(\\ d+)' , fileheader ).groups ()
8316+ catversions = re .search ('(.*?)(\\ d+)' , catstring ).groups ()
82908317 fnumfileshex = format (int (fnumfiles ), 'x' ).lower ()
82918318 fostype = platform .system ()
82928319 fhencoding = "UTF-8"
82938320 tmpcatfile = BytesIO ()
82948321 AppendFileHeader (tmpcatfile , fnumfiles , fhencoding , [], checksumtype [0 ], formatspecs )
8322+ tmpcatfile .seek (0 , 0 )
8323+ catheaderver = str (int (formatspecs ['format_ver' ].replace ("." , "" )))
8324+ catstring = tmpcatfile .read (formatspecs ['format_len' ] + len (catheaderver )).decode ("UTF-8" )
8325+ catdelszie = len (formatspecs ['format_delimiter' ])
8326+ catdel = tmpcatfile .read (catdelszie ).decode ("UTF-8" )
8327+ if (catstring != formatspecs ['format_magic' ]+ catheaderver ):
8328+ return False
8329+ if (catdel != formatspecs ['format_delimiter' ]):
8330+ return False
82958331 if (formatspecs ['new_style' ]):
82968332 catheader = ReadFileHeaderDataBySize (
82978333 tmpcatfile , formatspecs ['format_delimiter' ])
@@ -8324,10 +8360,10 @@ def RarFileToArrayAlt(infile, listonly=False, contentasfile=True, checksumtype=[
83248360 catversion = re .findall ("([\\ d]+)" , fileheader )
83258361 catversions = re .search ('(.*?)(\\ d+)' , fileheader ).groups ()
83268362 catfileheadercshex = GetFileChecksum (
8327- fileheader , checksumtype [0 ], True , formatspecs )
8363+ fileheader , checksumtype [0 ], False , formatspecs )
83288364 fheadtell = len (fileheader )
83298365 catlist = {'fnumfiles' : fnumfiles , 'fformat' : catversions [0 ], 'fcompression' : "" , 'fencoding' : fhencoding , 'fversion' : catversions [1 ], 'fostype' : fostype ,
8330- 'fformatspecs' : formatspecs , 'fchecksumtype' : checksumtype [0 ], 'fheaderchecksum' : catfileheadercshex , 'frawheader' : catheader , 'ffilelist' : []}
8366+ 'fformatspecs' : formatspecs , 'fchecksumtype' : checksumtype [0 ], 'fheaderchecksum' : catfileheadercshex , 'frawheader' : [ catstring ] + catheader , 'ffilelist' : []}
83318367 for member in sorted (rarfp .infolist (), key = lambda x : x .filename ):
83328368 catfhstart = fheadtell
83338369 fencoding = "UTF-8"
@@ -8464,6 +8500,7 @@ def RarFileToArrayAlt(infile, listonly=False, contentasfile=True, checksumtype=[
84648500 fcontents = BytesIO ()
84658501 if (ftype == 0 ):
84668502 fcontents .write (rarfp .read (member .filename ))
8503+ fcsize = fcontents .tell ()
84678504 fcontents .seek (0 , 0 )
84688505 ftypehex = format (ftype , 'x' ).lower ()
84698506 extrafields = len (extradata )
@@ -8568,6 +8605,15 @@ def SevenZipFileToArrayAlt(infile, listonly=False, contentasfile=True, checksumt
85688605 fhencoding = "UTF-8"
85698606 tmpcatfile = BytesIO ()
85708607 AppendFileHeader (tmpcatfile , fnumfiles , fhencoding , [], checksumtype [0 ], formatspecs )
8608+ tmpcatfile .seek (0 , 0 )
8609+ catheaderver = str (int (formatspecs ['format_ver' ].replace ("." , "" )))
8610+ catstring = tmpcatfile .read (formatspecs ['format_len' ] + len (catheaderver )).decode ("UTF-8" )
8611+ catdelszie = len (formatspecs ['format_delimiter' ])
8612+ catdel = tmpcatfile .read (catdelszie ).decode ("UTF-8" )
8613+ if (catstring != formatspecs ['format_magic' ]+ catheaderver ):
8614+ return False
8615+ if (catdel != formatspecs ['format_delimiter' ]):
8616+ return False
85718617 if (formatspecs ['new_style' ]):
85728618 catheader = ReadFileHeaderDataBySize (
85738619 tmpcatfile , formatspecs ['format_delimiter' ])
@@ -8600,10 +8646,10 @@ def SevenZipFileToArrayAlt(infile, listonly=False, contentasfile=True, checksumt
86008646 catversion = re .findall ("([\\ d]+)" , fileheader )
86018647 catversions = re .search ('(.*?)(\\ d+)' , fileheader ).groups ()
86028648 catfileheadercshex = GetFileChecksum (
8603- fileheader , checksumtype [0 ], True , formatspecs )
8649+ fileheader , checksumtype [0 ], False , formatspecs )
86048650 fheadtell = len (fileheader )
86058651 catlist = {'fnumfiles' : fnumfiles , 'fformat' : catversions [0 ], 'fcompression' : "" , 'fencoding' : fhencoding , 'fversion' : catversions [1 ], 'fostype' : fostype ,
8606- 'fformatspecs' : formatspecs , 'fchecksumtype' : checksumtype [0 ], 'fheaderchecksum' : catfileheadercshex , 'frawheader' : catheader , 'ffilelist' : []}
8652+ 'fformatspecs' : formatspecs , 'fchecksumtype' : checksumtype [0 ], 'fheaderchecksum' : catfileheadercshex , 'frawheader' : [ catstring ] + catheader , 'ffilelist' : []}
86078653 for member in sorted (szpfp .list (), key = lambda x : x .filename ):
86088654 catfhstart = fheadtell
86098655 fencoding = "UTF-8"
@@ -8687,6 +8733,7 @@ def SevenZipFileToArrayAlt(infile, listonly=False, contentasfile=True, checksumt
86878733 fcontents .write (file_content [member .filename ].read ())
86888734 fsize = format (fcontents .tell (), 'x' ).lower ()
86898735 fileop .close ()
8736+ fcsize = fcontents .tell ()
86908737 fcontents .seek (0 , 0 )
86918738 ftypehex = format (ftype , 'x' ).lower ()
86928739 extrafields = len (extradata )
0 commit comments