@@ -563,8 +563,8 @@ def resource_dir(package_name, filenames):
563563__use_json_name__ = os .path .join (filecfgpath , "foxfile.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 ('PYFOXFILE_CONFIG_FILE ' in os .environ and os .path .exists (os .environ ['PYFOXFILE_CONFIG_FILE ' ]) and __use_env_file__ ):
567+ scriptconf = os .environ ['PYFOXFILE_CONFIG_FILE ' ]
568568else :
569569 prescriptpath = get_importing_script_path ()
570570 if (prescriptpath is not None ):
@@ -1455,14 +1455,7 @@ def NormalizeRelativePath(inpath):
14551455 inpath = "file:///" + inpath [7 :]
14561456 dparsed = urlparse (inpath )
14571457 inpath = url2pathname (dparsed .path )
1458- inpath = RemoveWindowsPath (inpath )
1459- if os .path .isabs (inpath ):
1460- outpath = inpath
1461- else :
1462- if inpath .startswith ("./" ) or inpath .startswith ("../" ):
1463- outpath = inpath
1464- else :
1465- outpath = "./" + inpath
1458+ outpath = RemoveWindowsPath (inpath )
14661459 return outpath
14671460
14681461def PrependPath (base_dir , child_path ):
@@ -4049,10 +4042,7 @@ def ReadFileHeaderDataWithContent(fp, listonly=False, contentasfile=False, uncom
40494042 HeaderOut = ReadFileHeaderDataBySize (fp , delimiter )
40504043 if (len (HeaderOut ) == 0 ):
40514044 return False
4052- if (re .findall ("^[.|/]" , HeaderOut [5 ])):
4053- fname = HeaderOut [5 ]
4054- else :
4055- fname = "./" + HeaderOut [5 ]
4045+ fname = HeaderOut [5 ]
40564046 fcs = HeaderOut [- 2 ].lower ()
40574047 fccs = HeaderOut [- 1 ].lower ()
40584048 fsize = int (HeaderOut [7 ], 16 )
@@ -4247,10 +4237,7 @@ def ReadFileHeaderDataWithContentToArray(fp, listonly=False, contentasfile=True,
42474237 ftype = int (HeaderOut [2 ], 16 )
42484238 fencoding = HeaderOut [3 ]
42494239 fcencoding = HeaderOut [4 ]
4250- if (re .findall ("^[.|/]" , HeaderOut [5 ])):
4251- fname = HeaderOut [5 ]
4252- else :
4253- fname = "./" + HeaderOut [5 ]
4240+ fname = HeaderOut [5 ]
42544241 fbasedir = os .path .dirname (fname )
42554242 flinkname = HeaderOut [6 ]
42564243 fsize = int (HeaderOut [7 ], 16 )
@@ -4466,10 +4453,7 @@ def ReadFileHeaderDataWithContentToList(fp, listonly=False, contentasfile=False,
44664453 ftype = int (HeaderOut [2 ], 16 )
44674454 fencoding = HeaderOut [3 ]
44684455 fcencoding = HeaderOut [4 ]
4469- if (re .findall ("^[.|/]" , HeaderOut [5 ])):
4470- fname = HeaderOut [5 ]
4471- else :
4472- fname = "./" + HeaderOut [5 ]
4456+ fname = HeaderOut [5 ]
44734457 fbasedir = os .path .dirname (fname )
44744458 flinkname = HeaderOut [6 ]
44754459 fsize = int (HeaderOut [7 ], 16 )
@@ -4926,10 +4910,7 @@ def ReadFileDataWithContentToArray(fp, filestart=0, seekstart=0, seekend=0, list
49264910 if (len (preheaderdata ) == 0 ):
49274911 break
49284912 prefsize = int (preheaderdata [5 ], 16 )
4929- if (re .findall ("^[.|/]" , preheaderdata [5 ])):
4930- prefname = preheaderdata [5 ]
4931- else :
4932- prefname = "./" + preheaderdata [5 ]
4913+ prefname = preheaderdata [5 ]
49334914 prefseeknextfile = preheaderdata [26 ]
49344915 prefjsonlen = int (preheaderdata [28 ], 16 )
49354916 prefjsonsize = int (preheaderdata [29 ], 16 )
@@ -5188,10 +5169,7 @@ def ReadFileDataWithContentToList(fp, filestart=0, seekstart=0, seekend=0, listo
51885169 if (len (preheaderdata ) == 0 ):
51895170 break
51905171 prefsize = int (preheaderdata [5 ], 16 )
5191- if (re .findall ("^[.|/]" , preheaderdata [5 ])):
5192- prefname = preheaderdata [5 ]
5193- else :
5194- prefname = "./" + preheaderdata [5 ]
5172+ prefname = preheaderdata [5 ]
51955173 prefcompression = preheaderdata [14 ]
51965174 prefcsize = int (preheaderdata [15 ], 16 )
51975175 prefseeknextfile = preheaderdata [26 ]
@@ -5850,10 +5828,7 @@ def AppendFilesWithContentToList(infiles, dirlistfromtxt=False, extradata=[], js
58505828 tmpoutlist = []
58515829 for curfname in GetDirList :
58525830 fencoding = "UTF-8"
5853- if (re .findall ("^[.|/]" , curfname )):
5854- fname = curfname
5855- else :
5856- fname = "./" + curfname
5831+ fname = curfname
58575832 if (not os .path .exists (fname )):
58585833 return False
58595834 if (verbose ):
@@ -6210,10 +6185,7 @@ def AppendFilesWithContentFromTarFileToList(infile, extradata=[], jsondata={}, c
62106185 tmpoutlist = []
62116186 for member in sorted (tarfp .getmembers (), key = lambda x : x .name ):
62126187 fencoding = "UTF-8"
6213- if (re .findall ("^[.|/]" , member .name )):
6214- fname = member .name
6215- else :
6216- fname = "./" + member .name
6188+ fname = member .name
62176189 if (verbose ):
62186190 VerbosePrintOut (fname )
62196191 fpremode = member .mode
@@ -6417,10 +6389,7 @@ def AppendFilesWithContentFromZipFileToList(infile, extradata=[], jsondata={}, c
64176389 tmpoutlist = []
64186390 for member in sorted (zipfp .infolist (), key = lambda x : x .filename ):
64196391 fencoding = "UTF-8"
6420- if (re .findall ("^[.|/]" , member .filename )):
6421- fname = member .filename
6422- else :
6423- fname = "./" + member .filename
6392+ fname = member .filename
64246393 zipinfo = zipfp .getinfo (member .filename )
64256394 if (verbose ):
64266395 VerbosePrintOut (fname )
@@ -6671,10 +6640,7 @@ def AppendFilesWithContentFromRarFileToList(infile, extradata=[], jsondata={}, c
66716640 is_unix = False
66726641 is_windows = False
66736642 fencoding = "UTF-8"
6674- if (re .findall ("^[.|/]" , member .filename )):
6675- fname = member .filename
6676- else :
6677- fname = "./" + member .filename
6643+ fname = member .filename
66786644 rarinfo = rarfp .getinfo (member .filename )
66796645 if (verbose ):
66806646 VerbosePrintOut (fname )
@@ -6939,10 +6905,7 @@ def AppendFilesWithContentFromSevenZipFileToList(infile, extradata=[], jsondata=
69396905 tmpoutlist = []
69406906 for member in sorted (szpfp .list (), key = lambda x : x .filename ):
69416907 fencoding = "UTF-8"
6942- if (re .findall ("^[.|/]" , member .filename )):
6943- fname = member .filename
6944- else :
6945- fname = "./" + member .filename
6908+ fname = member .filename
69466909 if (verbose ):
69476910 VerbosePrintOut (fname )
69486911 if (not member .is_directory ):
@@ -7130,10 +7093,7 @@ def AppendListsWithContent(inlist, fp, dirlistfromtxt=False, extradata=[], jsond
71307093 ftype = format (curfname [0 ], 'x' ).lower ()
71317094 fencoding = curfname [1 ]
71327095 fcencoding = curfname [2 ]
7133- if (re .findall ("^[.|/]" , curfname [3 ])):
7134- fname = curfname [3 ]
7135- else :
7136- fname = "./" + curfname [3 ]
7096+ fname = curfname [3 ]
71377097 if (not os .path .exists (fname )):
71387098 return False
71397099 fbasedir = os .path .dirname (fname )
@@ -7931,7 +7891,7 @@ def FoxFileArrayValidate(infile, fmttype="auto", filestart=0, formatspecs=__file
79317891 if (infile != "-" and not isinstance (infile , (bytes , bytearray , memoryview )) # bytes is str on Py2
79327892 and not hasattr (infile , "read" ) and not hasattr (infile , "write" )):
79337893 infile = RemoveWindowsPath (infile )
7934- listarrayfileslist = ArchiveFileToArray (
7894+ listarrayfileslist = FoxFileToArray (
79357895 infile , fmttype , filestart , 0 , 0 ,
79367896 False , True , False , True , formatspecs , saltkey , seektoend , returnfp
79377897 )
@@ -8005,7 +7965,7 @@ def FoxFileValidate(infile, fmttype="auto", filestart=0, formatspecs=__file_form
80057965 if (infile != "-" and not isinstance (infile , (bytes , bytearray , memoryview )) # bytes is str on Py2
80067966 and not hasattr (infile , "read" ) and not hasattr (infile , "write" )):
80077967 infile = RemoveWindowsPath (infile )
8008- listarrayfileslist = ArchiveFileToArray (
7968+ listarrayfileslist = FoxFileToArray (
80097969 infile , fmttype , filestart , 0 , 0 ,
80107970 False , True , False , True , formatspecs , saltkey , seektoend , returnfp
80117971 )
@@ -8068,10 +8028,7 @@ def FoxFileValidate(infile, fmttype="auto", filestart=0, formatspecs=__file_form
80688028 inheaderdata = cur_entry ['frawheader' ]
80698029 if (len (inheaderdata ) == 0 ):
80708030 break
8071- if (re .findall ("^[.|/]" , inheaderdata [5 ])):
8072- outfname = inheaderdata [5 ]
8073- else :
8074- outfname = "./" + inheaderdata [5 ]
8031+ outfname = inheaderdata [5 ]
80758032 outfbasedir = os .path .dirname (outfname )
80768033 outfsize = int (inheaderdata [7 ], 16 )
80778034 outfcompression = inheaderdata [17 ]
@@ -8130,6 +8087,7 @@ def FoxFileValidate(infile, fmttype="auto", filestart=0, formatspecs=__file_form
81308087 pyhascontents = False
81318088 if (outfsize > 0 ):
81328089 outfcontents = cur_entry ['fcontents' ]
8090+ outfcontents .seek (0 , 0 )
81338091 infccs = GetFileChecksum (outfcontents , inheaderdata [- 3 ].lower (), False , formatspecs , saltkey )
81348092 pyhascontents = True
81358093 if (CheckChecksums (outfccs , infccs )):
@@ -8155,6 +8113,7 @@ def FoxFileValidate(infile, fmttype="auto", filestart=0, formatspecs=__file_form
81558113 fp .close ()
81568114 return False
81578115
8116+
81588117def FoxFileValidateFile (infile , fmttype = "auto" , filestart = 0 , formatspecs = __file_format_multi_dict__ , saltkey = None , seektoend = False , verbose = False , returnfp = False ):
81598118 return FoxFileValidate (infile , fmttype , filestart , formatspecs , saltkey , seektoend , verbose , returnfp )
81608119
@@ -8578,10 +8537,7 @@ def RePackFoxFile(infile, outfile, fmttype="auto", compression="auto", compressw
85788537
85798538 # path
85808539 fname_field = cur_entry ['fname' ]
8581- if re .findall (r"^[.|/]" , fname_field ):
8582- fname = fname_field
8583- else :
8584- fname = "./" + fname_field
8540+ fname = fname_field
85858541
85868542 if verbose :
85878543 VerbosePrintOut (fname )
@@ -9682,10 +9638,7 @@ def SevenZipFileListFiles(infile, verbose=False, returnfp=False):
96829638 if (sztestalt ):
96839639 VerbosePrintOut ("Bad file found!" )
96849640 for member in sorted (szpfp .list (), key = lambda x : x .filename ):
9685- if (re .findall ("^[.|/]" , member .filename )):
9686- fname = member .filename
9687- else :
9688- fname = "./" + member .filename
9641+ fname = member .filename
96899642 if (not member .is_directory ):
96909643 fpremode = int (stat .S_IFREG | 0x1b6 )
96919644 elif (member .is_directory ):
@@ -9790,7 +9743,7 @@ def InFileListFiles(infile, fmttype="auto", filestart=0, seekstart=0, seekend=0,
97909743 elif (py7zr_support and checkcompressfile == "7zipfile" and py7zr .is_7zfile (infile )):
97919744 return SevenZipFileListFiles (infile , verbose , returnfp )
97929745 elif (checkcompressfile == formatspecs ['format_magic' ]):
9793- return ArchiveFileListFiles (infile , fmttype , filestart , seekstart , seekend , skipchecksum , formatspecs , saltkey , seektoend , verbose , newstyle , returnfp )
9746+ return FoxFileListFiles (infile , fmttype , filestart , seekstart , seekend , skipchecksum , formatspecs , saltkey , seektoend , verbose , newstyle , returnfp )
97949747 else :
97959748 return False
97969749 return False
0 commit comments