PyCatFile 0.27.0__py3-none-any.whl → 0.27.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,7 +14,7 @@
14
14
  Copyright 2018-2024 Game Maker 2k - http://intdb.sourceforge.net/
15
15
  Copyright 2018-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
16
16
 
17
- $FileInfo: catfile.py - Last Update: 11/14/2025 Ver. 0.27.0 RC 1 - Author: cooldude2k $
17
+ $FileInfo: catfile.py - Last Update: 11/16/2025 Ver. 0.27.4 RC 1 - Author: cooldude2k $
18
18
  '''
19
19
 
20
20
  from __future__ import absolute_import, division, print_function, unicode_literals, generators, with_statement, nested_scopes
@@ -170,11 +170,11 @@ if active_action:
170
170
  tmpout = pycatfile.RePackCatFile(input_file, getargs.output, "auto", getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, False, getargs.filestart, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.insecretkey, getargs.outsecretkey, False, getargs.verbose, False)
171
171
  else:
172
172
  tmpout = pycatfile.PackCatFileFromInFile(
173
- input_file, getargs.output, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.insecretkey, getargs.verbose, False)
173
+ input_file, getargs.output, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.outsecretkey, getargs.verbose, False)
174
174
  if(not tmpout):
175
175
  sys.exit(1)
176
176
  else:
177
- pycatfile.PackCatFile(getargs.input, getargs.output, getargs.text, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, False, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.insecretkey, getargs.verbose, False)
177
+ pycatfile.PackCatFile(getargs.input, getargs.output, getargs.text, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, False, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.outsecretkey, getargs.verbose, False)
178
178
  elif active_action == 'repack':
179
179
  if getargs.convert:
180
180
  checkcompressfile = pycatfile.CheckCompressionSubType(
@@ -183,7 +183,7 @@ if active_action:
183
183
  pycatfile.RePackCatFile(input_file, getargs.output, "auto", getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt,
184
184
  False, getargs.filestart, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.insecretkey, getargs.outsecretkey, False, getargs.verbose, False)
185
185
  else:
186
- pycatfile.PackCatFileFromInFile(input_file, getargs.output, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.insecretkey, getargs.verbose, False)
186
+ pycatfile.PackCatFileFromInFile(input_file, getargs.output, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.outsecretkey, getargs.verbose, False)
187
187
  if(not tmpout):
188
188
  sys.exit(1)
189
189
  else:
@@ -198,7 +198,7 @@ if active_action:
198
198
  tmpout = pycatfile.RePackCatFile(input_file, tempout, "auto", getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, False, getargs.filestart, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.insecretkey, getargs.outsecretkey, False, False)
199
199
  else:
200
200
  tmpout = pycatfile.PackCatFileFromInFile(
201
- input_file, tempout, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.insecretkey, False, False)
201
+ input_file, tempout, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.outsecretkey, False, False)
202
202
  if(not tmpout):
203
203
  sys.exit(1)
204
204
  input_file = tempout
@@ -225,7 +225,7 @@ if active_action:
225
225
  tmpout = pycatfile.RePackCatFile(input_file, tempout, "auto", getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, False, getargs.filestart, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.insecretkey, getargs.outsecretkey, False, False, False)
226
226
  else:
227
227
  tmpout = pycatfile.PackCatFileFromInFile(
228
- input_file, tempout, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.insecretkey, False, False)
228
+ input_file, tempout, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.outsecretkey, False, False)
229
229
  input_file = tempout
230
230
  if(not tmpout):
231
231
  sys.exit(1)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyCatFile
3
- Version: 0.27.0
3
+ Version: 0.27.4
4
4
  Summary: A tar like file format name archivefile.
5
5
  Home-page: https://github.com/GameMaker2k/PyCatFile
6
6
  Download-URL: https://github.com/GameMaker2k/PyCatFile/archive/master.tar.gz
@@ -0,0 +1,8 @@
1
+ pycatfile.py,sha256=pSFe4iTM_ScB-prJla6YEW8S_56xbmGszKrJW92uOls,626450
2
+ pycatfile-0.27.4.data/scripts/catfile.py,sha256=sZnZyplqCbA_sS3CY7834E2vcuJkeCbO_A6HzGhoiLE,15314
3
+ pycatfile-0.27.4.dist-info/licenses/LICENSE,sha256=WM1VWxTUVrQbvEa-LC7cKTaBHXiqSTyYPoJvsZSbd7E,1513
4
+ pycatfile-0.27.4.dist-info/METADATA,sha256=LYvjYQGvj5v3QP4W6ZYZ5OgGwLh_zYlKQPUVW0V5-TY,954
5
+ pycatfile-0.27.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
+ pycatfile-0.27.4.dist-info/top_level.txt,sha256=ZnSwEHU_60RLIvmFhsATaAaEYjErDQgUymWwoXZ724c,10
7
+ pycatfile-0.27.4.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
8
+ pycatfile-0.27.4.dist-info/RECORD,,
pycatfile.py CHANGED
@@ -14,7 +14,7 @@
14
14
  Copyright 2018-2024 Game Maker 2k - http://intdb.sourceforge.net/
15
15
  Copyright 2018-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
16
16
 
17
- $FileInfo: pycatfile.py - Last Update: 11/14/2025 Ver. 0.27.0 RC 1 - Author: cooldude2k $
17
+ $FileInfo: pycatfile.py - Last Update: 11/16/2025 Ver. 0.27.4 RC 1 - Author: cooldude2k $
18
18
  '''
19
19
 
20
20
  from __future__ import absolute_import, division, print_function, unicode_literals, generators, with_statement, nested_scopes
@@ -47,11 +47,9 @@ except ImportError:
47
47
 
48
48
  try:
49
49
  from http.server import BaseHTTPRequestHandler, HTTPServer
50
- from socketserver import TCPServer
51
50
  from urllib.parse import urlparse, parse_qs
52
51
  except ImportError:
53
52
  from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
54
- from SocketServer import TCPServer
55
53
  from urlparse import urlparse, parse_qs
56
54
 
57
55
  try:
@@ -663,12 +661,12 @@ __project__ = __program_name__
663
661
  __program_alt_name__ = __program_name__
664
662
  __project_url__ = "https://github.com/GameMaker2k/PyCatFile"
665
663
  __project_release_url__ = __project_url__+"/releases/latest"
666
- __version_info__ = (0, 27, 0, "RC 1", 1)
667
- __version_date_info__ = (2025, 11, 14, "RC 1", 1)
664
+ __version_info__ = (0, 27, 4, "RC 1", 1)
665
+ __version_date_info__ = (2025, 11, 16, "RC 1", 1)
668
666
  __version_date__ = str(__version_date_info__[0]) + "." + str(
669
667
  __version_date_info__[1]).zfill(2) + "." + str(__version_date_info__[2]).zfill(2)
670
668
  __revision__ = __version_info__[3]
671
- __revision_id__ = "$Id: a0f8681f37b2a5e4682ca33c86dc2fe3ec56a903 $"
669
+ __revision_id__ = "$Id: 9e8b32c35830838aaf65e0655146a3d9269d096a $"
672
670
  if(__version_info__[4] is not None):
673
671
  __version_date_plusrc__ = __version_date__ + \
674
672
  "-" + str(__version_date_info__[4])
@@ -884,16 +882,14 @@ try:
884
882
  try:
885
883
  import compression.lzma as lzma
886
884
  except ImportError:
887
- import lzma
885
+ try:
886
+ import lzma
887
+ except ImportError:
888
+ from backports import lzma
888
889
  compressionsupport.append("lzma")
889
890
  compressionsupport.append("xz")
890
891
  except ImportError:
891
- try:
892
- from backports import lzma
893
- compressionsupport.append("lzma")
894
- compressionsupport.append("xz")
895
- except ImportError:
896
- pass
892
+ pass
897
893
  try:
898
894
  try:
899
895
  import compression.zlib as zlib
@@ -6502,16 +6498,29 @@ def AppendFilesWithContentToList(infiles, dirlistfromtxt=False, extradata=[], js
6502
6498
  advancedlist = __use_advanced_list__
6503
6499
  altinode = __use_alt_inode__
6504
6500
  infilelist = []
6505
- if(infiles == "-"):
6501
+ if(not dirlistfromtxt and not isinstance(infiles, (list, tuple, )) and infiles == "-"):
6506
6502
  for line in PY_STDIN_TEXT:
6507
6503
  infilelist.append(line.strip())
6508
6504
  infilelist = list(filter(None, infilelist))
6509
- elif(infiles != "-" and dirlistfromtxt and os.path.exists(infiles) and (os.path.isfile(infiles) or infiles == os.devnull)):
6510
- if(not os.path.exists(infiles) or not os.path.isfile(infiles)):
6511
- return False
6512
- with UncompressFile(infiles, formatspecs, "r") as finfile:
6513
- for line in finfile:
6514
- infilelist.append(line.strip())
6505
+ if(not dirlistfromtxt and isinstance(infiles, (list, tuple, )) and len(infiles)==1 and infiles[0] == "-"):
6506
+ for line in PY_STDIN_TEXT:
6507
+ infilelist.append(line.strip())
6508
+ infilelist = list(filter(None, infilelist))
6509
+ elif(dirlistfromtxt):
6510
+ if(not isinstance(infiles, (list, tuple, ))):
6511
+ infiles = [infiles]
6512
+ if(isinstance(infiles, (list, tuple, ))):
6513
+ for fileloc in infiles:
6514
+ if(fileloc == "-"):
6515
+ for line in PY_STDIN_TEXT:
6516
+ infilelist.append(line.strip())
6517
+ else:
6518
+ if(not os.path.exists(fileloc) or not os.path.isfile(fileloc)):
6519
+ return False
6520
+ else:
6521
+ with UncompressFile(fileloc, formatspecs, "r") as finfile:
6522
+ for line in finfile:
6523
+ infilelist.append(line.strip())
6515
6524
  infilelist = list(filter(None, infilelist))
6516
6525
  else:
6517
6526
  if(isinstance(infiles, (list, tuple, ))):
@@ -6847,7 +6856,7 @@ def AppendFilesWithContentFromTarFileToList(infile, extradata=[], jsondata={}, c
6847
6856
  inodetofile = {}
6848
6857
  filetoinode = {}
6849
6858
  inodetoforminode = {}
6850
- if(infile == "-"):
6859
+ if(not isinstance(infile, (list, tuple, )) and infile == "-"):
6851
6860
  infile = MkTempFile()
6852
6861
  shutil.copyfileobj(PY_STDIN_BUF, infile, length=__filebuff_size__)
6853
6862
  infile.seek(0, 0)
@@ -6915,7 +6924,7 @@ def AppendFilesWithContentFromTarFileToList(infile, extradata=[], jsondata={}, c
6915
6924
  fblocks = 0
6916
6925
  fflags = 0
6917
6926
  ftype = 0
6918
- if(member.isreg()):
6927
+ if(member.isreg() or member.isfile()):
6919
6928
  ffullmode = member.mode + stat.S_IFREG
6920
6929
  ftype = 0
6921
6930
  elif(member.islnk()):
@@ -7073,7 +7082,7 @@ def AppendFilesWithContentFromZipFileToList(infile, extradata=[], jsondata={}, c
7073
7082
  inodetofile = {}
7074
7083
  filetoinode = {}
7075
7084
  inodetoforminode = {}
7076
- if(infile == "-"):
7085
+ if(not isinstance(infile, (list, tuple, )) and infile == "-"):
7077
7086
  infile = MkTempFile()
7078
7087
  shutil.copyfileobj(PY_STDIN_BUF, infile, length=__filebuff_size__)
7079
7088
  infile.seek(0, 0)
@@ -7120,9 +7129,13 @@ def AppendFilesWithContentFromZipFileToList(infile, extradata=[], jsondata={}, c
7120
7129
  ftype = 0
7121
7130
  if ((hasattr(member, "is_dir") and member.is_dir()) or member.filename.endswith('/')):
7122
7131
  ftype = 5
7132
+ elif ((hasattr(member, "symlink") and member.symlink())):
7133
+ ftype = 2
7123
7134
  else:
7124
7135
  ftype = 0
7125
7136
  flinkname = ""
7137
+ if(ftype==2):
7138
+ flinkname = zipfp.read(member.filename).decode("UTF-8")
7126
7139
  fcurfid = format(int(curfid), 'x').lower()
7127
7140
  fcurinode = format(int(curfid), 'x').lower()
7128
7141
  curfid = curfid + 1
@@ -7148,6 +7161,10 @@ def AppendFilesWithContentFromZipFileToList(infile, extradata=[], jsondata={}, c
7148
7161
  fmode = format(int(stat.S_IFDIR | 0x1ff), 'x').lower()
7149
7162
  fchmode = stat.S_IMODE(int(stat.S_IFDIR | 0x1ff))
7150
7163
  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))
7151
7168
  else:
7152
7169
  fmode = format(int(stat.S_IFREG | 0x1b6), 'x').lower()
7153
7170
  fchmode = stat.S_IMODE(int(stat.S_IFREG | 0x1b6))
@@ -7156,6 +7173,17 @@ def AppendFilesWithContentFromZipFileToList(infile, extradata=[], jsondata={}, c
7156
7173
  fwinattributes = format(int(zipinfo.external_attr & 0xFFFF), 'x').lower()
7157
7174
  fmode = format(int((zipinfo.external_attr >> 16) & 0xFFFF), 'x').lower()
7158
7175
  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
7159
7187
  if (prefmode == 0):
7160
7188
  if ((hasattr(member, "is_dir") and member.is_dir()) or member.filename.endswith('/')):
7161
7189
  fmode = format(int(stat.S_IFDIR | 0x1ff), 'x').lower()
@@ -7602,7 +7630,10 @@ else:
7602
7630
  fpremode = int(stat.S_IFREG | 0x1b6)
7603
7631
  elif(member.is_directory):
7604
7632
  fpremode = int(stat.S_IFDIR | 0x1ff)
7605
- 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()
7606
7637
  fcompression = ""
7607
7638
  fcsize = format(int(0), 'x').lower()
7608
7639
  flinkcount = 0
@@ -7638,6 +7669,13 @@ else:
7638
7669
  int(stat.S_IMODE(int(stat.S_IFREG | 0x1b6))), 'x').lower()
7639
7670
  ftypemod = format(
7640
7671
  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
7641
7679
  try:
7642
7680
  fuid = format(int(os.getuid()), 'x').lower()
7643
7681
  except (KeyError, AttributeError):
@@ -10203,7 +10241,7 @@ def CatFileValidate(infile, fmttype="auto", filestart=0, formatspecs=__file_form
10203
10241
  if(not fp):
10204
10242
  return False
10205
10243
  fp.seek(filestart, 0)
10206
- elif(infile == "-"):
10244
+ elif(not isinstance(infile, (list, tuple, )) and infile == "-"):
10207
10245
  fp = MkTempFile()
10208
10246
  shutil.copyfileobj(PY_STDIN_BUF, fp, length=__filebuff_size__)
10209
10247
  fp.seek(filestart, 0)
@@ -11579,8 +11617,8 @@ def CatFileStringListFiles(instr, filestart=0, seekstart=0, seekend=0, skipcheck
11579
11617
  return listarrayfiles
11580
11618
 
11581
11619
 
11582
- def TarFileListFiles(infile, verbose=False, returnfp=False):
11583
- if(infile == "-"):
11620
+ def TarFileListFiles(infile, formatspecs=__file_format_multi_dict__, verbose=False, returnfp=False):
11621
+ if(not isinstance(infile, (list, tuple, )) and infile == "-"):
11584
11622
  infile = MkTempFile()
11585
11623
  shutil.copyfileobj(PY_STDIN_BUF, infile, length=__filebuff_size__)
11586
11624
  infile.seek(0, 0)
@@ -11640,7 +11678,7 @@ def TarFileListFiles(infile, verbose=False, returnfp=False):
11640
11678
  ffullmode = member.mode
11641
11679
  flinkcount = 0
11642
11680
  ftype = 0
11643
- if(member.isreg()):
11681
+ if(member.isreg() or member.isfile()):
11644
11682
  ffullmode = member.mode + stat.S_IFREG
11645
11683
  ftype = 0
11646
11684
  elif(member.islnk()):
@@ -11695,8 +11733,12 @@ def TarFileListFiles(infile, verbose=False, returnfp=False):
11695
11733
  return True
11696
11734
 
11697
11735
 
11736
+ def TarFileListFile(infile, formatspecs=__file_format_multi_dict__, verbose=False, returnfp=False):
11737
+ return TarFileListFiles(infile, formatspecs, verbose, returnfp)
11738
+
11739
+
11698
11740
  def ZipFileListFiles(infile, verbose=False, returnfp=False):
11699
- if(infile == "-"):
11741
+ if(not isinstance(infile, (list, tuple, )) and infile == "-"):
11700
11742
  infile = MkTempFile()
11701
11743
  shutil.copyfileobj(PY_STDIN_BUF, infile, length=__filebuff_size__)
11702
11744
  infile.seek(0, 0)
@@ -11727,35 +11769,59 @@ def ZipFileListFiles(infile, verbose=False, returnfp=False):
11727
11769
  for member in sorted(zipfp.infolist(), key=lambda x: x.filename):
11728
11770
  zipinfo = zipfp.getinfo(member.filename)
11729
11771
  if(zipinfo.create_system == 0 or zipinfo.create_system == 10):
11730
- fwinattributes = int(zipinfo.external_attr)
11772
+ fwinattributes = int(zipinfo.external_attr & 0xFFFF)
11731
11773
  if ((hasattr(member, "is_dir") and member.is_dir()) or member.filename.endswith('/')):
11732
11774
  fmode = int(stat.S_IFDIR | 0x1ff)
11733
- fchmode = int(stat.S_IMODE(int(stat.S_IFDIR | 0x1ff)))
11734
- 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))
11735
11781
  else:
11736
11782
  fmode = int(stat.S_IFREG | 0x1b6)
11737
- fchmode = int(stat.S_IMODE(fmode))
11738
- 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))
11739
11785
  elif(zipinfo.create_system == 3):
11740
- fwinattributes = int(0)
11741
- try:
11742
- fmode = int(zipinfo.external_attr)
11743
- fchmode = stat.S_IMODE(fmode)
11744
- ftypemod = stat.S_IFMT(fmode)
11745
- except OverflowError:
11746
- fmode = int(zipinfo.external_attr >> 16)
11747
- fchmode = stat.S_IMODE(fmode)
11748
- 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)
11749
11813
  else:
11750
- fwinattributes = int(0)
11814
+ fwinattributes = int(zipinfo.external_attr & 0xFFFF)
11751
11815
  if ((hasattr(member, "is_dir") and member.is_dir()) or member.filename.endswith('/')):
11752
11816
  fmode = int(stat.S_IFDIR | 0x1ff)
11753
- fchmode = int(stat.S_IMODE(int(stat.S_IFDIR | 0x1ff)))
11754
- 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)
11755
11820
  else:
11756
11821
  fmode = int(stat.S_IFREG | 0x1b6)
11757
- fchmode = int(stat.S_IMODE(fmode))
11758
- 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)
11759
11825
  returnval.update({lcfi: member.filename})
11760
11826
  if(not verbose):
11761
11827
  VerbosePrintOut(member.filename)
@@ -11769,10 +11835,17 @@ def ZipFileListFiles(infile, verbose=False, returnfp=False):
11769
11835
  if ((hasattr(member, "is_dir") and member.is_dir()) or member.filename.endswith('/')):
11770
11836
  ftype = 5
11771
11837
  permissionstr = "d" + permissionstr
11838
+ elif ((hasattr(member, "symlink") and member.symlink())):
11839
+ ftype = 2
11840
+ permissionstr = "l" + permissionstr
11772
11841
  else:
11773
11842
  ftype = 0
11774
11843
  permissionstr = "-" + permissionstr
11775
11844
  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
11776
11849
  try:
11777
11850
  fuid = int(os.getuid())
11778
11851
  except (KeyError, AttributeError):
@@ -11815,6 +11888,10 @@ def ZipFileListFiles(infile, verbose=False, returnfp=False):
11815
11888
  return True
11816
11889
 
11817
11890
 
11891
+ def ZipFileListFile(infile, verbose=False, returnfp=False):
11892
+ return ZipFileListFiles(infile, verbose, returnfp)
11893
+
11894
+
11818
11895
  if(not rarfile_support):
11819
11896
  def RarFileListFiles(infile, verbose=False, returnfp=False):
11820
11897
  return False
@@ -11942,6 +12019,11 @@ if(rarfile_support):
11942
12019
  else:
11943
12020
  return True
11944
12021
 
12022
+
12023
+ def RarFileListFile(infile, verbose=False, returnfp=False):
12024
+ return RarFileListFiles(infile, verbose, returnfp)
12025
+
12026
+
11945
12027
  if(not py7zr_support):
11946
12028
  def SevenZipFileListFiles(infile, verbose=False, returnfp=False):
11947
12029
  return False
@@ -11979,6 +12061,13 @@ if(py7zr_support):
11979
12061
  fmode = int(stat.S_IFLNK | 0x1b6)
11980
12062
  fchmode = int(stat.S_IMODE(int(stat.S_IFLNK | 0x1b6)))
11981
12063
  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
11982
12071
  returnval.update({lcfi: member.filename})
11983
12072
  if(not verbose):
11984
12073
  VerbosePrintOut(member.filename)
@@ -12046,12 +12135,16 @@ if(py7zr_support):
12046
12135
  return True
12047
12136
 
12048
12137
 
12138
+ def SevenZipFileListFile(infile, verbose=False, returnfp=False):
12139
+ return SevenZipFileListFiles(infile, verbose, returnfp)
12140
+
12141
+
12049
12142
  def InFileListFiles(infile, verbose=False, formatspecs=__file_format_multi_dict__, seektoend=False, newstyle=False, returnfp=False):
12050
12143
  checkcompressfile = CheckCompressionSubType(infile, formatspecs, filestart, True)
12051
12144
  if(IsNestedDict(formatspecs) and checkcompressfile in formatspecs):
12052
12145
  formatspecs = formatspecs[checkcompressfile]
12053
12146
  if(checkcompressfile == "tarfile" and TarFileCheck(infile)):
12054
- return TarFileListFiles(infile, verbose, returnfp)
12147
+ return TarFileListFiles(infile, formatspecs, verbose, returnfp)
12055
12148
  elif(checkcompressfile == "zipfile" and zipfile.is_zipfile(infile)):
12056
12149
  return ZipFileListFiles(infile, verbose, returnfp)
12057
12150
  elif(rarfile_support and checkcompressfile == "rarfile" and (rarfile.is_rarfile(infile) or rarfile.is_rarfile_sfx(infile))):
@@ -12065,6 +12158,10 @@ def InFileListFiles(infile, verbose=False, formatspecs=__file_format_multi_dict_
12065
12158
  return False
12066
12159
 
12067
12160
 
12161
+ def InFileListFile(infile, verbose=False, formatspecs=__file_format_multi_dict__, seektoend=False, newstyle=False, returnfp=False):
12162
+ return InFileListFiles(infile, verbose, formatspecs, seektoend, newstyle, returnfp)
12163
+
12164
+
12068
12165
  def ListDirListFiles(infiles, dirlistfromtxt=False, compression="auto", compresswholefile=True, compressionlevel=None, followlink=False, seekstart=0, seekend=0, skipchecksum=False, checksumtype=["md5", "md5", "md5"], formatspecs=__file_format_dict__, seektoend=False, verbose=False, returnfp=False):
12069
12166
  outarray = MkTempFile()
12070
12167
  packform = PackCatFile(infiles, outarray, dirlistfromtxt, compression, compresswholefile,
@@ -12073,6 +12170,11 @@ def ListDirListFiles(infiles, dirlistfromtxt=False, compression="auto", compress
12073
12170
  outarray, seekstart, seekend, skipchecksum, formatspecs, seektoend, verbose, returnfp)
12074
12171
  return listarrayfiles
12075
12172
 
12173
+
12174
+ def ListDirListFiles(infiles, dirlistfromtxt=False, compression="auto", compresswholefile=True, compressionlevel=None, followlink=False, seekstart=0, seekend=0, skipchecksum=False, checksumtype=["md5", "md5", "md5"], formatspecs=__file_format_dict__, seektoend=False, verbose=False, returnfp=False):
12175
+ return ListDirListFiles(infiles, dirlistfromtxt, compression, compresswholefile, compressionlevel, followlink, seekstart, seekend, skipchecksum, checksumtype, formatspecs, seektoend, verbose, returnfp)
12176
+
12177
+
12076
12178
  def detect_cwd(ftp, file_dir):
12077
12179
  """
12078
12180
  Test whether cwd into file_dir works. Returns True if it does,
@@ -1,130 +0,0 @@
1
- #!python
2
- # -*- coding: utf-8 -*-
3
- from __future__ import absolute_import, division, print_function, unicode_literals
4
-
5
- import sys, os, io, argparse
6
-
7
- try:
8
- import pycatfile as P # core must provide *_neo functions
9
- except Exception as e:
10
- sys.stderr.write("Failed to import core module 'pycatfile': %s\n" % (e,))
11
- sys.exit(2)
12
-
13
-
14
- def _expand_combined_short_opts(argv):
15
- out = [argv[0]]
16
- i = 1
17
- while i < len(argv):
18
- a = argv[i]
19
- if a.startswith("--") or not (a.startswith("-") and len(a) > 2):
20
- out.append(a); i += 1; continue
21
- for ch in a[1:]:
22
- out.append("-" + ch)
23
- i += 1
24
- return out
25
-
26
-
27
- def main():
28
- argv = _expand_combined_short_opts(sys.argv)
29
-
30
- p = argparse.ArgumentParser(
31
- description="PyNeoFile CLI (uses pycatfile core)")
32
- g = p.add_mutually_exclusive_group(required=True)
33
- g.add_argument("-l", "--list", action="store_true", help="List archive")
34
- g.add_argument("-e", "--extract", action="store_true", help="Extract archive")
35
- g.add_argument("-c", "--create", action="store_true", help="Create archive from path")
36
- g.add_argument("-r", "--repack", action="store_true", help="Repack (recompress) an archive")
37
- g.add_argument("-E", "--empty", action="store_true", help="Create an empty archive")
38
-
39
- p.add_argument("-i", "--input", help="Input file/path", nargs="*")
40
- p.add_argument("-o", "--output", help="Output file/dir (or '-' for stdout)")
41
- p.add_argument("-d", "--verbose", action="store_true", help="Verbose/detailed listing")
42
- p.add_argument("-P", "--compression", default="auto", help="Compression algo (auto, none, zlib, gzip, bz2, lzma)")
43
- p.add_argument("-L", "--level", type=int, default=None, help="Compression level/preset")
44
- p.add_argument("--checksum", default="crc32", help="Checksum type for header/content/json (default: crc32)")
45
-
46
- args = p.parse_args(argv[1:])
47
-
48
- src = None
49
- if args.input:
50
- if isinstance(args.input, list) and len(args.input) == 1:
51
- src = args.input[0]
52
- elif isinstance(args.input, list) and len(args.input) > 1:
53
- src = args.input[0]
54
- else:
55
- src = args.input
56
-
57
- if args.empty:
58
- dst = args.output or "-"
59
- blob_or_true = P.make_empty_file_neo(dst, fmttype="auto", checksumtype=args.checksum, encoding="UTF-8", returnfp=False)
60
- if dst in (None, "-"):
61
- data = blob_or_true if isinstance(blob_or_true, (bytes, bytearray)) else b""
62
- if hasattr(sys.stdout, "buffer"):
63
- sys.stdout.buffer.write(data)
64
- else:
65
- sys.stdout.write(data.decode("latin1"))
66
- return 0
67
-
68
- if args.list:
69
- if not src:
70
- p.error("list requires -i <archive>")
71
- P.archivefilelistfiles_neo(src, advanced=args.verbose, include_dirs=True)
72
- return 0
73
-
74
- if args.extract:
75
- if not src:
76
- p.error("extract requires -i <archive>")
77
- outdir = args.output or "."
78
- ok = P.unpack_neo(src, outdir, skipchecksum=False, uncompress=True)
79
- return 0 if ok else 1
80
-
81
- if args.create:
82
- if not src:
83
- p.error("create requires -i <path>")
84
- if args.verbose:
85
- walkroot = src
86
- if os.path.isdir(walkroot):
87
- print(walkroot)
88
- for root, dirs, files in os.walk(walkroot):
89
- relroot = root if root.startswith("./") else "./" + root.replace("\\", "/")
90
- if root != walkroot:
91
- print(relroot)
92
- for name in sorted(files):
93
- path = os.path.join(root, name).replace("\\", "/")
94
- if not path.startswith("./"):
95
- path = "./" + path
96
- print(path)
97
- else:
98
- path = src if src.startswith("./") else "./" + src
99
- print(path)
100
-
101
- outpath = args.output or "-"
102
- ok = P.pack_neo(src, outpath, checksumtypes=(args.checksum,args.checksum,args.checksum,args.checksum),
103
- encoding="UTF-8", compression=args.compression, compression_level=args.level)
104
- if outpath in (None, "-") and isinstance(ok, (bytes, bytearray)):
105
- if hasattr(sys.stdout, "buffer"):
106
- sys.stdout.buffer.write(ok)
107
- else:
108
- sys.stdout.write(ok.decode("latin1"))
109
- return 0
110
- return 0 if ok else 1
111
-
112
- if args.repack:
113
- if not src:
114
- p.error("repack requires -i <archive>")
115
- outpath = args.output or "-"
116
- ok = P.repack_neo(src, outpath, checksumtypes=(args.checksum,args.checksum,args.checksum,args.checksum),
117
- compression=args.compression, compression_level=args.level)
118
- if outpath in (None, "-") and isinstance(ok, (bytes, bytearray)):
119
- if hasattr(sys.stdout, "buffer"):
120
- sys.stdout.buffer.write(ok)
121
- else:
122
- sys.stdout.write(ok.decode("latin1"))
123
- return 0
124
- return 0 if ok else 1
125
-
126
- return 0
127
-
128
-
129
- if __name__ == "__main__":
130
- sys.exit(main())
@@ -1,136 +0,0 @@
1
- #!python
2
- # -*- coding: utf-8 -*-
3
-
4
- '''
5
- This program is free software; you can redistribute it and/or modify
6
- it under the terms of the Revised BSD License.
7
-
8
- This program is distributed in the hope that it will be useful,
9
- but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- Revised BSD License for more details.
12
-
13
- Copyright 2018-2024 Cool Dude 2k - http://idb.berlios.de/
14
- Copyright 2018-2024 Game Maker 2k - http://intdb.sourceforge.net/
15
- Copyright 2018-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
16
-
17
- $FileInfo: neocatfile.py - Last Update: 8/26/2025 Ver. 0.21.4 RC 1 - Author: cooldude2k $
18
- '''
19
-
20
- from __future__ import absolute_import, division, print_function, unicode_literals, generators, with_statement, nested_scopes
21
- import argparse
22
- import pycatfile
23
-
24
- __project__ = pycatfile.__project__
25
- __program_name__ = pycatfile.__program_name__
26
- __file_format_name__ = pycatfile.__file_format_name__
27
- __file_format_magic__ = pycatfile.__file_format_magic__
28
- __file_format_len__ = pycatfile.__file_format_len__
29
- __file_format_hex__ = pycatfile.__file_format_hex__
30
- __file_format_delimiter__ = pycatfile.__file_format_delimiter__
31
- __file_format_dict__ = pycatfile.__file_format_dict__
32
- __file_format_default__ = pycatfile.__file_format_default__
33
- __use_new_style__ = pycatfile.__use_new_style__
34
- __use_advanced_list__ = pycatfile.__use_advanced_list__
35
- __use_alt_inode__ = pycatfile.__use_alt_inode__
36
- __project_url__ = pycatfile.__project_url__
37
- __version_info__ = pycatfile.__version_info__
38
- __version_date_info__ = pycatfile.__version_date_info__
39
- __version_date__ = pycatfile.__version_date__
40
- __version_date_plusrc__ = pycatfile.__version_date_plusrc__
41
- __version__ = pycatfile.__version__
42
-
43
- # Compatibility layer for Python 2 and 3 input
44
- try:
45
- input = raw_input
46
- except NameError:
47
- pass
48
-
49
- # Determine if rar file support is enabled
50
- rarfile_support = pycatfile.rarfile_support
51
- py7zr_support = pycatfile.py7zr_support
52
-
53
- # Set up the argument parser
54
- argparser = argparse.ArgumentParser(
55
- description="Manipulates concatenated files for various operations like creation, extraction, and validation.")
56
- argparser.add_argument("-V", "--version", action="version", version="{0} {1}".format(
57
- __program_name__, __version__), help="Displays the program's version.")
58
- argparser.add_argument("-i", "--input", nargs="+", required=True,
59
- help="Specifies input file(s) for processing.")
60
- argparser.add_argument(
61
- "-o", "--output", help="Specifies the output file name.")
62
- argparser.add_argument("-d", "--verbose", action="store_true",
63
- help="Enables verbose mode for detailed information.")
64
- argparser.add_argument("-c", "--create", action="store_true",
65
- help="Creates a new concatenated file from input.")
66
- argparser.add_argument("-e", "--extract", action="store_true",
67
- help="Extracts files from a concatenated archive.")
68
- argparser.add_argument("-l", "--list", action="store_true",
69
- help="Lists contents of a specified concatenated file.")
70
- argparser.add_argument("-r", "--repack", action="store_true",
71
- help="Repacks an existing concatenated file.")
72
- argparser.add_argument("-v", "--validate", action="store_true",
73
- help="Validates a concatenated file's integrity.")
74
- argparser.add_argument("--checksum", default="crc32",
75
- help="Specifies the checksum type (default: crc32).")
76
- argparser.add_argument("--compression", default="auto",
77
- help="Specifies the compression method (default: auto).")
78
- argparser.add_argument("--level", help="Specifies the compression level.")
79
- argparser.add_argument("--preserve", action="store_true",
80
- help="Preserves file attributes when extracting.")
81
- argparser.add_argument("--convert", choices=['tar', 'zip', '7zip', 'rar'],
82
- help="Convert from an archive format (tar, zip, 7zip, rar) to a concatenated file.")
83
- args = argparser.parse_args()
84
-
85
- # Determine the primary action based on user input
86
- primary_action = None
87
- if args.create:
88
- primary_action = 'create'
89
- elif args.repack:
90
- primary_action = 'repack'
91
- elif args.extract:
92
- primary_action = 'extract'
93
- elif args.list:
94
- primary_action = 'list'
95
- elif args.validate:
96
- primary_action = 'validate'
97
- input_file = args.input[0]
98
- # Functionality mappings
99
- if primary_action == 'create':
100
- if args.convert == 'tar':
101
- pycatfile.PackCatFileFromTarFile(input_file, args.output, args.compression, args.level, pycatfile.compressionlistalt, [args.checksum, args.checksum, args.checksum, args.checksum], [
102
- ], pycatfile.__file_format_dict__, args.verbose, False)
103
- elif args.convert == 'zip':
104
- pycatfile.PackCatFileFromZipFile(input_file, args.output, args.compression, args.level, pycatfile.compressionlistalt, [args.checksum, args.checksum, args.checksum, args.checksum], [
105
- ], pycatfile.__file_format_dict__, args.verbose, False)
106
- elif py7zr_support and args.convert == '7zip':
107
- pycatfile.PackCatFileFromSevenZipFile(input_file, args.output, args.compression, args.level, pycatfile.compressionlistalt, [args.checksum, args.checksum, args.checksum, args.checksum], [
108
- ], pycatfile.__file_format_dict__, args.verbose, False)
109
- elif rarfile_support and args.convert == 'rar':
110
- pycatfile.PackCatFileFromRarFile(input_file, args.output, args.compression, args.level, pycatfile.compressionlistalt, [args.checksum, args.checksum, args.checksum, args.checksum], [
111
- ], pycatfile.__file_format_dict__, args.verbose, False)
112
- else:
113
- pycatfile.PackCatFile(args.input, args.output, args.verbose, args.compression, args.level, pycatfile.compressionlistalt,
114
- False, [args.checksum, args.checksum, args.checksum, args.checksum], [], {}, pycatfile.__file_format_dict__, args.verbose, False)
115
- elif primary_action == 'repack':
116
- pycatfile.RePackCatFile(
117
- input_file, args.output, args.compression, args.level, pycatfile.compressionlistalt, [args.checksum, args.checksum, args.checksum, args.checksum], False, args.verbose)
118
- elif primary_action == 'extract':
119
- pycatfile.UnPackCatFile(
120
- input_file, args.output, args.verbose, False, args.preserve)
121
- elif primary_action == 'list':
122
- if args.convert == 'tar':
123
- pycatfile.TarFileListFiles(input_file, verbose=args.verbose)
124
- elif args.convert == 'zip':
125
- pycatfile.ZipFileListFiles(input_file, verbose=args.verbose)
126
- elif args.convert == '7zip':
127
- pycatfile.SevenZipFileListFiles(input_file, verbose=args.verbose)
128
- elif rarfile_support and args.convert == 'rar':
129
- pycatfile.RarFileListFiles(input_file, verbose=args.verbose)
130
- else:
131
- pycatfile.CatFileListFiles(input_file, verbose=args.verbose)
132
- elif primary_action == 'validate':
133
- is_valid = pycatfile.CatFileValidate(input_file, verbose=args.verbose)
134
- result_msg = "Validation result for {0}: {1}".format(
135
- input_file, 'Valid' if is_valid else 'Invalid')
136
- print(result_msg)
@@ -1,10 +0,0 @@
1
- pycatfile.py,sha256=EMZPN3xwFiKWSbeC_h4vrH2DtTcGMpvgMIR7EMjiZmU,621068
2
- pycatfile-0.27.0.data/scripts/catfile.py,sha256=Mki2dfWV8IF-2dHoMOpAzlpq7kTz4JNcU0rQ5PdTyAE,15309
3
- pycatfile-0.27.0.data/scripts/catneofile.py,sha256=b0sJBb-o6Rx5TO_dqXnJz3fCf-yPbEul1_6uX2CRS0Q,5128
4
- pycatfile-0.27.0.data/scripts/neocatfile.py,sha256=YefEZZAnFwJ63xy2zDnvvs99BOyrHVhT1cPH4TnzrQs,7149
5
- pycatfile-0.27.0.dist-info/licenses/LICENSE,sha256=WM1VWxTUVrQbvEa-LC7cKTaBHXiqSTyYPoJvsZSbd7E,1513
6
- pycatfile-0.27.0.dist-info/METADATA,sha256=lwgCNef5NzcXfULVzLYltMtDoRLj1hk2Q8_LmJkNqNU,954
7
- pycatfile-0.27.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
- pycatfile-0.27.0.dist-info/top_level.txt,sha256=ZnSwEHU_60RLIvmFhsATaAaEYjErDQgUymWwoXZ724c,10
9
- pycatfile-0.27.0.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
10
- pycatfile-0.27.0.dist-info/RECORD,,