@@ -6924,7 +6924,7 @@ def AppendFilesWithContentFromTarFileToList(infile, extradata=[], jsondata={}, c
69246924 fblocks = 0
69256925 fflags = 0
69266926 ftype = 0
6927- if(member.isreg()):
6927+ if(member.isreg() or member.isfile() ):
69286928 ffullmode = member.mode + stat.S_IFREG
69296929 ftype = 0
69306930 elif(member.islnk()):
@@ -7129,9 +7129,13 @@ def AppendFilesWithContentFromZipFileToList(infile, extradata=[], jsondata={}, c
71297129 ftype = 0
71307130 if ((hasattr(member, "is_dir") and member.is_dir()) or member.filename.endswith('/')):
71317131 ftype = 5
7132+ elif ((hasattr(member, "symlink") and member.symlink())):
7133+ ftype = 2
71327134 else:
71337135 ftype = 0
71347136 flinkname = ""
7137+ if(ftype==2):
7138+ flinkname = zipfp.read(member.filename).decode("UTF-8")
71357139 fcurfid = format(int(curfid), 'x').lower()
71367140 fcurinode = format(int(curfid), 'x').lower()
71377141 curfid = curfid + 1
@@ -7157,6 +7161,10 @@ def AppendFilesWithContentFromZipFileToList(infile, extradata=[], jsondata={}, c
71577161 fmode = format(int(stat.S_IFDIR | 0x1ff), 'x').lower()
71587162 fchmode = stat.S_IMODE(int(stat.S_IFDIR | 0x1ff))
71597163 ftypemod = stat.S_IFMT(int(stat.S_IFDIR | 0x1ff))
7164+ elif ((hasattr(member, "symlink") and member.symlink()) or member.filename.endswith('/')):
7165+ fmode = format(int(stat.S_IFREG | 0x1b6), 'x').lower()
7166+ fchmode = stat.S_IMODE(int(stat.S_IFREG | 0x1b6))
7167+ ftypemod = stat.S_IFMT(int(stat.S_IFREG | 0x1b6))
71607168 else:
71617169 fmode = format(int(stat.S_IFREG | 0x1b6), 'x').lower()
71627170 fchmode = stat.S_IMODE(int(stat.S_IFREG | 0x1b6))
@@ -7165,6 +7173,17 @@ def AppendFilesWithContentFromZipFileToList(infile, extradata=[], jsondata={}, c
71657173 fwinattributes = format(int(zipinfo.external_attr & 0xFFFF), 'x').lower()
71667174 fmode = format(int((zipinfo.external_attr >> 16) & 0xFFFF), 'x').lower()
71677175 prefmode = int((zipinfo.external_attr >> 16) & 0xFFFF)
7176+ if(prefmode==0):
7177+ fmode = 0
7178+ prefmode = 0
7179+ else:
7180+ file_type = prefmode & 0xF000
7181+ if(file_type not in (stat.S_IFREG, stat.S_IFDIR, stat.S_IFLNK)):
7182+ fmode = 0
7183+ prefmode = 0
7184+ if((mode & 0x1FF) == 0):
7185+ fmode = 0
7186+ prefmode = 0
71687187 if (prefmode == 0):
71697188 if ((hasattr(member, "is_dir") and member.is_dir()) or member.filename.endswith('/')):
71707189 fmode = format(int(stat.S_IFDIR | 0x1ff), 'x').lower()
@@ -7611,7 +7630,10 @@ def AppendFilesWithContentFromSevenZipFileToList(infile, extradata=[], jsondata=
76117630 fpremode = int(stat.S_IFREG | 0x1b6)
76127631 elif(member.is_directory):
76137632 fpremode = int(stat.S_IFDIR | 0x1ff)
7614- fwinattributes = format(int(0), 'x').lower()
7633+ try:
7634+ fwinattributes = format(int(member.attributes & 0xFFFF), 'x').lower()
7635+ except AttributeError:
7636+ fwinattributes = format(int(0), 'x').lower()
76157637 fcompression = ""
76167638 fcsize = format(int(0), 'x').lower()
76177639 flinkcount = 0
@@ -7647,6 +7669,13 @@ def AppendFilesWithContentFromSevenZipFileToList(infile, extradata=[], jsondata=
76477669 int(stat.S_IMODE(int(stat.S_IFREG | 0x1b6))), 'x').lower()
76487670 ftypemod = format(
76497671 int(stat.S_IFMT(int(stat.S_IFREG | 0x1b6))), 'x').lower()
7672+ try:
7673+ ffullmode = member.posix_mode
7674+ fmode = format(int(ffullmode), 'x').lower()
7675+ fchmode = format(int(stat.S_IMODE(ffullmode)), 'x').lower()
7676+ ftypemod = format(int(stat.S_IFMT(ffullmode)), 'x').lower()
7677+ except AttributeError:
7678+ pass
76507679 try:
76517680 fuid = format(int(os.getuid()), 'x').lower()
76527681 except (KeyError, AttributeError):
@@ -11649,7 +11678,7 @@ def TarFileListFiles(infile, formatspecs=__file_format_multi_dict__, verbose=Fal
1164911678 ffullmode = member.mode
1165011679 flinkcount = 0
1165111680 ftype = 0
11652- if(member.isreg()):
11681+ if(member.isreg() or member.isfile() ):
1165311682 ffullmode = member.mode + stat.S_IFREG
1165411683 ftype = 0
1165511684 elif(member.islnk()):
@@ -11740,35 +11769,59 @@ def ZipFileListFiles(infile, verbose=False, returnfp=False):
1174011769 for member in sorted(zipfp.infolist(), key=lambda x: x.filename):
1174111770 zipinfo = zipfp.getinfo(member.filename)
1174211771 if(zipinfo.create_system == 0 or zipinfo.create_system == 10):
11743- fwinattributes = int(zipinfo.external_attr)
11772+ fwinattributes = int(zipinfo.external_attr & 0xFFFF )
1174411773 if ((hasattr(member, "is_dir") and member.is_dir()) or member.filename.endswith('/')):
1174511774 fmode = int(stat.S_IFDIR | 0x1ff)
11746- fchmode = int(stat.S_IMODE(int(stat.S_IFDIR | 0x1ff)))
11747- ftypemod = int(stat.S_IFMT(int(stat.S_IFDIR | 0x1ff)))
11775+ fchmode = stat.S_IMODE(int(stat.S_IFDIR | 0x1ff))
11776+ ftypemod = stat.S_IFMT(int(stat.S_IFDIR | 0x1ff))
11777+ elif ((hasattr(member, "symlink") and member.symlink()) or member.filename.endswith('/')):
11778+ fmode = int(stat.S_IFREG | 0x1b6)
11779+ fchmode = stat.S_IMODE(int(stat.S_IFREG | 0x1b6))
11780+ ftypemod = stat.S_IFMT(int(stat.S_IFREG | 0x1b6))
1174811781 else:
1174911782 fmode = int(stat.S_IFREG | 0x1b6)
11750- fchmode = int( stat.S_IMODE(fmode ))
11751- ftypemod = int( stat.S_IFMT(fmode ))
11783+ fchmode = stat.S_IMODE(int(stat.S_IFREG | 0x1b6 ))
11784+ ftypemod = stat.S_IFMT(int(stat.S_IFREG | 0x1b6 ))
1175211785 elif(zipinfo.create_system == 3):
11753- fwinattributes = int(0)
11754- try:
11755- fmode = int(zipinfo.external_attr)
11756- fchmode = stat.S_IMODE(fmode)
11757- ftypemod = stat.S_IFMT(fmode)
11758- except OverflowError:
11759- fmode = int(zipinfo.external_attr >> 16)
11760- fchmode = stat.S_IMODE(fmode)
11761- ftypemod = stat.S_IFMT(fmode)
11786+ fwinattributes = int(zipinfo.external_attr & 0xFFFF)
11787+ fmode = int((zipinfo.external_attr >> 16) & 0xFFFF)
11788+ prefmode = int((zipinfo.external_attr >> 16) & 0xFFFF)
11789+ if(prefmode==0):
11790+ fmode = 0
11791+ prefmode = 0
11792+ else:
11793+ file_type = prefmode & 0xF000
11794+ if(file_type not in (stat.S_IFREG, stat.S_IFDIR, stat.S_IFLNK)):
11795+ fmode = 0
11796+ prefmode = 0
11797+ if((mode & 0x1FF) == 0):
11798+ fmode = 0
11799+ prefmode = 0
11800+ if (prefmode == 0):
11801+ if ((hasattr(member, "is_dir") and member.is_dir()) or member.filename.endswith('/')):
11802+ fmode = int(stat.S_IFDIR | 0x1ff)
11803+ prefmode = int(stat.S_IFDIR | 0x1ff)
11804+ fchmode = stat.S_IMODE(prefmode)
11805+ ftypemod = stat.S_IFMT(prefmode)
11806+ else:
11807+ fmode = int(stat.S_IFREG | 0x1b6)
11808+ prefmode = int(stat.S_IFREG | 0x1b6)
11809+ fchmode = stat.S_IMODE(prefmode)
11810+ ftypemod = stat.S_IFMT(prefmode)
11811+ fchmode = stat.S_IMODE(prefmode)
11812+ ftypemod = stat.S_IFMT(prefmode)
1176211813 else:
11763- fwinattributes = int(0 )
11814+ fwinattributes = int(zipinfo.external_attr & 0xFFFF )
1176411815 if ((hasattr(member, "is_dir") and member.is_dir()) or member.filename.endswith('/')):
1176511816 fmode = int(stat.S_IFDIR | 0x1ff)
11766- fchmode = int(stat.S_IMODE(int(stat.S_IFDIR | 0x1ff)))
11767- ftypemod = int(stat.S_IFMT(int(stat.S_IFDIR | 0x1ff)))
11817+ prefmode = int(stat.S_IFDIR | 0x1ff)
11818+ fchmode = stat.S_IMODE(prefmode)
11819+ ftypemod = stat.S_IFMT(prefmode)
1176811820 else:
1176911821 fmode = int(stat.S_IFREG | 0x1b6)
11770- fchmode = int(stat.S_IMODE(fmode))
11771- ftypemod = int(stat.S_IFMT(fmode))
11822+ prefmode = int(stat.S_IFREG | 0x1b6)
11823+ fchmode = stat.S_IMODE(prefmode)
11824+ ftypemod = stat.S_IFMT(prefmode)
1177211825 returnval.update({lcfi: member.filename})
1177311826 if(not verbose):
1177411827 VerbosePrintOut(member.filename)
@@ -11782,10 +11835,17 @@ def ZipFileListFiles(infile, verbose=False, returnfp=False):
1178211835 if ((hasattr(member, "is_dir") and member.is_dir()) or member.filename.endswith('/')):
1178311836 ftype = 5
1178411837 permissionstr = "d" + permissionstr
11838+ elif ((hasattr(member, "symlink") and member.symlink())):
11839+ ftype = 2
11840+ permissionstr = "l" + permissionstr
1178511841 else:
1178611842 ftype = 0
1178711843 permissionstr = "-" + permissionstr
1178811844 printfname = member.filename
11845+ if(ftype==2):
11846+ flinkname = zipfp.read(member.filename).decode("UTF-8")
11847+ if(ftype==2):
11848+ printfname = member.filename + " -> " + flinkname
1178911849 try:
1179011850 fuid = int(os.getuid())
1179111851 except (KeyError, AttributeError):
@@ -12001,6 +12061,13 @@ def SevenZipFileListFiles(infile, verbose=False, returnfp=False):
1200112061 fmode = int(stat.S_IFLNK | 0x1b6)
1200212062 fchmode = int(stat.S_IMODE(int(stat.S_IFLNK | 0x1b6)))
1200312063 ftypemod = int(stat.S_IFMT(int(stat.S_IFLNK | 0x1b6)))
12064+ try:
12065+ ffullmode = member.posix_mode
12066+ fmode = format(int(ffullmode), 'x').lower()
12067+ fchmode = format(int(stat.S_IMODE(ffullmode)), 'x').lower()
12068+ ftypemod = format(int(stat.S_IFMT(ffullmode)), 'x').lower()
12069+ except AttributeError:
12070+ pass
1200412071 returnval.update({lcfi: member.filename})
1200512072 if(not verbose):
1200612073 VerbosePrintOut(member.filename)
0 commit comments