@@ -563,8 +563,8 @@ def resource_dir(package_name, filenames):
563563__use_json_name__ = os .path .join (filecfgpath , "catfile.json" )
564564if (__use_ini_file__ and __use_json_file__ ):
565565 __use_json_file__ = False
566- if ('PYARCHIVEFILE_CONFIG_FILE ' in os .environ and os .path .exists (os .environ ['PYARCHIVEFILE_CONFIG_FILE ' ]) and __use_env_file__ ):
567- scriptconf = os .environ ['PYARCHIVEFILE_CONFIG_FILE ' ]
566+ if ('PYCATFILE_CONFIG_FILE ' in os .environ and os .path .exists (os .environ ['PYCATFILE_CONFIG_FILE ' ]) and __use_env_file__ ):
567+ scriptconf = os .environ ['PYCATFILE_CONFIG_FILE ' ]
568568else :
569569 prescriptpath = get_importing_script_path ()
570570 if (prescriptpath is not None ):
@@ -1454,14 +1454,7 @@ def NormalizeRelativePath(inpath):
14541454 inpath = "file:///" + inpath [7 :]
14551455 dparsed = urlparse (inpath )
14561456 inpath = url2pathname (dparsed .path )
1457- inpath = RemoveWindowsPath (inpath )
1458- if os .path .isabs (inpath ):
1459- outpath = inpath
1460- else :
1461- if inpath .startswith ("./" ) or inpath .startswith ("../" ):
1462- outpath = inpath
1463- else :
1464- outpath = "./" + inpath
1457+ outpath = RemoveWindowsPath (inpath )
14651458 return outpath
14661459
14671460def PrependPath (base_dir , child_path ):
@@ -4048,10 +4041,7 @@ def ReadFileHeaderDataWithContent(fp, listonly=False, contentasfile=False, uncom
40484041 HeaderOut = ReadFileHeaderDataBySize (fp , delimiter )
40494042 if (len (HeaderOut ) == 0 ):
40504043 return False
4051- if (re .findall ("^[.|/]" , HeaderOut [5 ])):
4052- fname = HeaderOut [5 ]
4053- else :
4054- fname = "./" + HeaderOut [5 ]
4044+ fname = HeaderOut [5 ]
40554045 fcs = HeaderOut [- 2 ].lower ()
40564046 fccs = HeaderOut [- 1 ].lower ()
40574047 fsize = int (HeaderOut [7 ], 16 )
@@ -4246,10 +4236,7 @@ def ReadFileHeaderDataWithContentToArray(fp, listonly=False, contentasfile=True,
42464236 ftype = int (HeaderOut [2 ], 16 )
42474237 fencoding = HeaderOut [3 ]
42484238 fcencoding = HeaderOut [4 ]
4249- if (re .findall ("^[.|/]" , HeaderOut [5 ])):
4250- fname = HeaderOut [5 ]
4251- else :
4252- fname = "./" + HeaderOut [5 ]
4239+ fname = HeaderOut [5 ]
42534240 fbasedir = os .path .dirname (fname )
42544241 flinkname = HeaderOut [6 ]
42554242 fsize = int (HeaderOut [7 ], 16 )
@@ -4465,10 +4452,7 @@ def ReadFileHeaderDataWithContentToList(fp, listonly=False, contentasfile=False,
44654452 ftype = int (HeaderOut [2 ], 16 )
44664453 fencoding = HeaderOut [3 ]
44674454 fcencoding = HeaderOut [4 ]
4468- if (re .findall ("^[.|/]" , HeaderOut [5 ])):
4469- fname = HeaderOut [5 ]
4470- else :
4471- fname = "./" + HeaderOut [5 ]
4455+ fname = HeaderOut [5 ]
44724456 fbasedir = os .path .dirname (fname )
44734457 flinkname = HeaderOut [6 ]
44744458 fsize = int (HeaderOut [7 ], 16 )
@@ -4925,10 +4909,7 @@ def ReadFileDataWithContentToArray(fp, filestart=0, seekstart=0, seekend=0, list
49254909 if (len (preheaderdata ) == 0 ):
49264910 break
49274911 prefsize = int (preheaderdata [5 ], 16 )
4928- if (re .findall ("^[.|/]" , preheaderdata [5 ])):
4929- prefname = preheaderdata [5 ]
4930- else :
4931- prefname = "./" + preheaderdata [5 ]
4912+ prefname = preheaderdata [5 ]
49324913 prefseeknextfile = preheaderdata [26 ]
49334914 prefjsonlen = int (preheaderdata [28 ], 16 )
49344915 prefjsonsize = int (preheaderdata [29 ], 16 )
@@ -5187,10 +5168,7 @@ def ReadFileDataWithContentToList(fp, filestart=0, seekstart=0, seekend=0, listo
51875168 if (len (preheaderdata ) == 0 ):
51885169 break
51895170 prefsize = int (preheaderdata [5 ], 16 )
5190- if (re .findall ("^[.|/]" , preheaderdata [5 ])):
5191- prefname = preheaderdata [5 ]
5192- else :
5193- prefname = "./" + preheaderdata [5 ]
5171+ prefname = preheaderdata [5 ]
51945172 prefcompression = preheaderdata [14 ]
51955173 prefcsize = int (preheaderdata [15 ], 16 )
51965174 prefseeknextfile = preheaderdata [26 ]
@@ -5849,10 +5827,7 @@ def AppendFilesWithContentToList(infiles, dirlistfromtxt=False, extradata=[], js
58495827 tmpoutlist = []
58505828 for curfname in GetDirList :
58515829 fencoding = "UTF-8"
5852- if (re .findall ("^[.|/]" , curfname )):
5853- fname = curfname
5854- else :
5855- fname = "./" + curfname
5830+ fname = curfname
58565831 if (not os .path .exists (fname )):
58575832 return False
58585833 if (verbose ):
@@ -6209,10 +6184,7 @@ def AppendFilesWithContentFromTarFileToList(infile, extradata=[], jsondata={}, c
62096184 tmpoutlist = []
62106185 for member in sorted (tarfp .getmembers (), key = lambda x : x .name ):
62116186 fencoding = "UTF-8"
6212- if (re .findall ("^[.|/]" , member .name )):
6213- fname = member .name
6214- else :
6215- fname = "./" + member .name
6187+ fname = member .name
62166188 if (verbose ):
62176189 VerbosePrintOut (fname )
62186190 fpremode = member .mode
@@ -6416,10 +6388,7 @@ def AppendFilesWithContentFromZipFileToList(infile, extradata=[], jsondata={}, c
64166388 tmpoutlist = []
64176389 for member in sorted (zipfp .infolist (), key = lambda x : x .filename ):
64186390 fencoding = "UTF-8"
6419- if (re .findall ("^[.|/]" , member .filename )):
6420- fname = member .filename
6421- else :
6422- fname = "./" + member .filename
6391+ fname = member .filename
64236392 zipinfo = zipfp .getinfo (member .filename )
64246393 if (verbose ):
64256394 VerbosePrintOut (fname )
@@ -6670,10 +6639,7 @@ def AppendFilesWithContentFromRarFileToList(infile, extradata=[], jsondata={}, c
66706639 is_unix = False
66716640 is_windows = False
66726641 fencoding = "UTF-8"
6673- if (re .findall ("^[.|/]" , member .filename )):
6674- fname = member .filename
6675- else :
6676- fname = "./" + member .filename
6642+ fname = member .filename
66776643 rarinfo = rarfp .getinfo (member .filename )
66786644 if (verbose ):
66796645 VerbosePrintOut (fname )
@@ -6938,10 +6904,7 @@ def AppendFilesWithContentFromSevenZipFileToList(infile, extradata=[], jsondata=
69386904 tmpoutlist = []
69396905 for member in sorted (szpfp .list (), key = lambda x : x .filename ):
69406906 fencoding = "UTF-8"
6941- if (re .findall ("^[.|/]" , member .filename )):
6942- fname = member .filename
6943- else :
6944- fname = "./" + member .filename
6907+ fname = member .filename
69456908 if (verbose ):
69466909 VerbosePrintOut (fname )
69476910 if (not member .is_directory ):
@@ -7129,10 +7092,7 @@ def AppendListsWithContent(inlist, fp, dirlistfromtxt=False, extradata=[], jsond
71297092 ftype = format (curfname [0 ], 'x' ).lower ()
71307093 fencoding = curfname [1 ]
71317094 fcencoding = curfname [2 ]
7132- if (re .findall ("^[.|/]" , curfname [3 ])):
7133- fname = curfname [3 ]
7134- else :
7135- fname = "./" + curfname [3 ]
7095+ fname = curfname [3 ]
71367096 if (not os .path .exists (fname )):
71377097 return False
71387098 fbasedir = os .path .dirname (fname )
@@ -7930,7 +7890,7 @@ def CatFileArrayValidate(infile, fmttype="auto", filestart=0, formatspecs=__file
79307890 if (infile != "-" and not isinstance (infile , (bytes , bytearray , memoryview )) # bytes is str on Py2
79317891 and not hasattr (infile , "read" ) and not hasattr (infile , "write" )):
79327892 infile = RemoveWindowsPath (infile )
7933- listarrayfileslist = ArchiveFileToArray (
7893+ listarrayfileslist = CatFileToArray (
79347894 infile , fmttype , filestart , 0 , 0 ,
79357895 False , True , False , True , formatspecs , saltkey , seektoend , returnfp
79367896 )
@@ -8004,7 +7964,7 @@ def CatFileValidate(infile, fmttype="auto", filestart=0, formatspecs=__file_form
80047964 if (infile != "-" and not isinstance (infile , (bytes , bytearray , memoryview )) # bytes is str on Py2
80057965 and not hasattr (infile , "read" ) and not hasattr (infile , "write" )):
80067966 infile = RemoveWindowsPath (infile )
8007- listarrayfileslist = ArchiveFileToArray (
7967+ listarrayfileslist = CatFileToArray (
80087968 infile , fmttype , filestart , 0 , 0 ,
80097969 False , True , False , True , formatspecs , saltkey , seektoend , returnfp
80107970 )
@@ -8067,10 +8027,7 @@ def CatFileValidate(infile, fmttype="auto", filestart=0, formatspecs=__file_form
80678027 inheaderdata = cur_entry ['frawheader' ]
80688028 if (len (inheaderdata ) == 0 ):
80698029 break
8070- if (re .findall ("^[.|/]" , inheaderdata [5 ])):
8071- outfname = inheaderdata [5 ]
8072- else :
8073- outfname = "./" + inheaderdata [5 ]
8030+ outfname = inheaderdata [5 ]
80748031 outfbasedir = os .path .dirname (outfname )
80758032 outfsize = int (inheaderdata [7 ], 16 )
80768033 outfcompression = inheaderdata [17 ]
@@ -8129,6 +8086,7 @@ def CatFileValidate(infile, fmttype="auto", filestart=0, formatspecs=__file_form
81298086 pyhascontents = False
81308087 if (outfsize > 0 ):
81318088 outfcontents = cur_entry ['fcontents' ]
8089+ outfcontents .seek (0 , 0 )
81328090 infccs = GetFileChecksum (outfcontents , inheaderdata [- 3 ].lower (), False , formatspecs , saltkey )
81338091 pyhascontents = True
81348092 if (CheckChecksums (outfccs , infccs )):
@@ -8154,6 +8112,7 @@ def CatFileValidate(infile, fmttype="auto", filestart=0, formatspecs=__file_form
81548112 fp .close ()
81558113 return False
81568114
8115+
81578116def CatFileValidateFile (infile , fmttype = "auto" , filestart = 0 , formatspecs = __file_format_multi_dict__ , saltkey = None , seektoend = False , verbose = False , returnfp = False ):
81588117 return CatFileValidate (infile , fmttype , filestart , formatspecs , saltkey , seektoend , verbose , returnfp )
81598118
@@ -8577,10 +8536,7 @@ def RePackCatFile(infile, outfile, fmttype="auto", compression="auto", compressw
85778536
85788537 # path
85798538 fname_field = cur_entry ['fname' ]
8580- if re .findall (r"^[.|/]" , fname_field ):
8581- fname = fname_field
8582- else :
8583- fname = "./" + fname_field
8539+ fname = fname_field
85848540
85858541 if verbose :
85868542 VerbosePrintOut (fname )
@@ -9681,10 +9637,7 @@ def SevenZipFileListFiles(infile, verbose=False, returnfp=False):
96819637 if (sztestalt ):
96829638 VerbosePrintOut ("Bad file found!" )
96839639 for member in sorted (szpfp .list (), key = lambda x : x .filename ):
9684- if (re .findall ("^[.|/]" , member .filename )):
9685- fname = member .filename
9686- else :
9687- fname = "./" + member .filename
9640+ fname = member .filename
96889641 if (not member .is_directory ):
96899642 fpremode = int (stat .S_IFREG | 0x1b6 )
96909643 elif (member .is_directory ):
@@ -9789,7 +9742,7 @@ def InFileListFiles(infile, fmttype="auto", filestart=0, seekstart=0, seekend=0,
97899742 elif (py7zr_support and checkcompressfile == "7zipfile" and py7zr .is_7zfile (infile )):
97909743 return SevenZipFileListFiles (infile , verbose , returnfp )
97919744 elif (checkcompressfile == formatspecs ['format_magic' ]):
9792- return ArchiveFileListFiles (infile , fmttype , filestart , seekstart , seekend , skipchecksum , formatspecs , saltkey , seektoend , verbose , newstyle , returnfp )
9745+ return CatFileListFiles (infile , fmttype , filestart , seekstart , seekend , skipchecksum , formatspecs , saltkey , seektoend , verbose , newstyle , returnfp )
97939746 else :
97949747 return False
97959748 return False
0 commit comments