Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
KazukiPrzyborowski authored Mar 12, 2024
1 parent 59b8289 commit 8caae3d
Showing 1 changed file with 41 additions and 42 deletions.
83 changes: 41 additions & 42 deletions pycatfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2656,8 +2656,7 @@ def ArchiveFileSeekToFileName(infile, seekfile=None, skipchecksum=False, formats

create_alias_function("", __file_format_name__, "SeekToFileName", ArchiveFileSeekToFileName);

def ArchiveFileToArray(infile, seekstart=0, seekend=0, listonly=False, skipchecksum=False, formatspecs=__file_format_list__, returnfp=False):
usenewstyle = True;
def ArchiveFileToArray(infile, seekstart=0, seekend=0, listonly=False, skipchecksum=False, formatspecs=__file_format_list__, usenewstyle=True, returnfp=False):
if(hasattr(infile, "read") or hasattr(infile, "write")):
catfp = infile;
catfp.seek(0, 0);
Expand Down Expand Up @@ -2915,34 +2914,34 @@ def ArchiveFileToArray(infile, seekstart=0, seekend=0, listonly=False, skipcheck

create_alias_function("", __file_format_name__, "ToArray", ArchiveFileToArray);

def ArchiveFileStringToArray(catstr, seekstart=0, seekend=0, listonly=False, skipchecksum=False, formatspecs=__file_format_list__, returnfp=False):
def ArchiveFileStringToArray(catstr, seekstart=0, seekend=0, listonly=False, skipchecksum=False, formatspecs=__file_format_list__, usenewstyle=True, returnfp=False):
catfp = BytesIO(catstr);
listcatfiles = ArchiveFileToArray(catfp, seekstart, seekend, listonly, skipchecksum, formatspecs, returnfp);
listcatfiles = ArchiveFileToArray(catfp, seekstart, seekend, listonly, skipchecksum, formatspecs, usenewstyle, returnfp);
return listcatfiles;

create_alias_function("", __file_format_name__, "StringToArray", ArchiveFileStringToArray);

def TarFileToArray(infile, seekstart=0, seekend=0, listonly=False, skipchecksum=False, formatspecs=__file_format_list__, returnfp=False):
def TarFileToArray(infile, seekstart=0, seekend=0, listonly=False, skipchecksum=False, formatspecs=__file_format_list__, usenewstyle=True, returnfp=False):
catfp = BytesIO();
catfp = PackArchiveFileFromTarFile(infile, catfp, "auto", None, "crc32", [], formatspecs, False, True);
listcatfiles = ArchiveFileToArray(catfp, seekstart, seekend, listonly, skipchecksum, formatspecs, returnfp);
listcatfiles = ArchiveFileToArray(catfp, seekstart, seekend, listonly, skipchecksum, formatspecs, usenewstyle, returnfp);
return listcatfiles;

def ZipFileToArray(infile, seekstart=0, seekend=0, listonly=False, skipchecksum=False, formatspecs=__file_format_list__, returnfp=False):
def ZipFileToArray(infile, seekstart=0, seekend=0, listonly=False, skipchecksum=False, formatspecs=__file_format_list__, usenewstyle=True, returnfp=False):
catfp = BytesIO();
catfp = PackArchiveFileFromZipFile(infile, catfp, "auto", None, "crc32", [], formatspecs, False, True);
listcatfiles = ArchiveFileToArray(catfp, seekstart, seekend, listonly, skipchecksum, formatspecs, returnfp);
listcatfiles = ArchiveFileToArray(catfp, seekstart, seekend, listonly, skipchecksum, formatspecs, usenewstyle, returnfp);
return listcatfiles;

if(not rarfile_support):
def RarFileToArray(infile, seekstart=0, seekend=0, listonly=False, skipchecksum=False, formatspecs=__file_format_list__, returnfp=False):
return False;

if(rarfile_support):
def RarFileToArray(infile, seekstart=0, seekend=0, listonly=False, skipchecksum=False, formatspecs=__file_format_list__, returnfp=False):
def RarFileToArray(infile, seekstart=0, seekend=0, listonly=False, skipchecksum=False, formatspecs=__file_format_list__, usenewstyle=True, returnfp=False):
catfp = BytesIO();
catfp = PackArchiveFileFromRarFile(infile, catfp, "auto", None, "crc32", [], formatspecs, False, True);
listcatfiles = ArchiveFileToArray(catfp, seekstart, seekend, listonly, skipchecksum, formatspecs, returnfp);
listcatfiles = ArchiveFileToArray(catfp, seekstart, seekend, listonly, skipchecksum, formatspecs, usenewstyle, returnfp);
return listcatfiles;

def ListDirToArrayAlt(infiles, dirlistfromtxt=False, followlink=False, listonly=False, checksumtype="crc32", extradata=[], formatspecs=__file_format_list__, verbose=False):
Expand Down Expand Up @@ -3933,19 +3932,19 @@ def RarFileToArrayAlt(infiles, listonly=False, checksumtype="crc32", extradata=[
fileidnum = fileidnum + 1;
return catlist;

def ListDirToArray(infiles, dirlistfromtxt=False, compression="auto", compressionlevel=None, followlink=False, seekstart=0, seekend=0, listonly=False, skipchecksum=False, checksumtype="crc32", extradata=[], formatspecs=__file_format_list__, verbose=False, returnfp=False):
def ListDirToArray(infiles, dirlistfromtxt=False, compression="auto", compressionlevel=None, followlink=False, seekstart=0, seekend=0, listonly=False, skipchecksum=False, checksumtype="crc32", extradata=[], formatspecs=__file_format_list__, verbose=False, usenewstyle=True, returnfp=False):
outarray = BytesIO();
packcat = PackArchiveFile(infiles, outarray, dirlistfromtxt, compression, compressionlevel, followlink, checksumtype, extradata, formatspecs, verbose, True);
listcatfiles = ArchiveFileToArray(outarray, seekstart, seekend, listonly, skipchecksum, formatspecs, returnfp);
listcatfiles = ArchiveFileToArray(outarray, seekstart, seekend, listonly, skipchecksum, formatspecs, usenewstyle, returnfp);
return listcatfiles;

def ArchiveFileToArrayIndex(infile, seekstart=0, seekend=0, listonly=False, skipchecksum=False, formatspecs=__file_format_list__, returnfp=False):
def ArchiveFileToArrayIndex(infile, seekstart=0, seekend=0, listonly=False, skipchecksum=False, formatspecs=__file_format_list__, usenewstyle=True, returnfp=False):
if(isinstance(infile, dict)):
listcatfiles = infile;
else:
if(infile!="-" and not hasattr(infile, "read") and not hasattr(infile, "write")):
infile = RemoveWindowsPath(infile);
listcatfiles = ArchiveFileToArray(infile, seekstart, seekend, listonly, skipchecksum, formatspecs, returnfp);
listcatfiles = ArchiveFileToArray(infile, seekstart, seekend, listonly, skipchecksum, formatspecs, usenewstyle, returnfp);
if(not listcatfiles):
return False;
catarray = {'list': listcatfiles, 'filetoid': {}, 'idtofile': {}, 'filetypes': {'directories': {'filetoid': {}, 'idtofile': {}}, 'files': {'filetoid': {}, 'idtofile': {}}, 'links': {'filetoid': {}, 'idtofile': {}}, 'symlinks': {'filetoid': {}, 'idtofile': {}}, 'hardlinks': {'filetoid': {}, 'idtofile': {}}, 'character': {'filetoid': {}, 'idtofile': {}}, 'block': {'filetoid': {}, 'idtofile': {}}, 'fifo': {'filetoid': {}, 'idtofile': {}}, 'devices': {'filetoid': {}, 'idtofile': {}}}};
Expand Down Expand Up @@ -4233,57 +4232,57 @@ def RarFileToArrayIndexAlt(infiles, seekstart=0, seekend=0, listonly=False, chec
lcfi = lcfi + 1;
return catarray;

def ArchiveFileStringToArrayIndex(catstr, seekstart=0, seekend=0, listonly=False, skipchecksum=False, formatspecs=__file_format_list__, returnfp=False):
def ArchiveFileStringToArrayIndex(catstr, seekstart=0, seekend=0, listonly=False, skipchecksum=False, formatspecs=__file_format_list__, usenewstyle=True, returnfp=False):
catfp = BytesIO(catstr);
listcatfiles = ArchiveFileToArrayIndex(catfp, seekstart, seekend, listonly, skipchecksum, formatspecs, returnfp);
listcatfiles = ArchiveFileToArrayIndex(catfp, seekstart, seekend, listonly, skipchecksum, formatspecs, usenewstyle, returnfp);
return listcatfiles;

create_alias_function("", __file_format_name__, "StringToArrayIndex", ArchiveFileStringToArrayIndex);

def TarFileToArrayIndex(infile, seekstart=0, seekend=0, listonly=False, skipchecksum=False, formatspecs=__file_format_list__, returnfp=False):
def TarFileToArrayIndex(infile, seekstart=0, seekend=0, listonly=False, skipchecksum=False, formatspecs=__file_format_list__, usenewstyle=True, returnfp=False):
catfp = BytesIO();
catfp = PackArchiveFileFromTarFile(infile, catfp, "auto", None, "crc32", [], formatspecs, False, True);
listcatfiles = ArchiveFileToArrayIndex(catfp, seekstart, seekend, listonly, skipchecksum, formatspecs, returnfp);
listcatfiles = ArchiveFileToArrayIndex(catfp, seekstart, seekend, listonly, skipchecksum, formatspecs, usenewstyle, returnfp);
return listcatfiles;

def ZipFileToArrayIndex(infile, seekstart=0, seekend=0, listonly=False, skipchecksum=False, formatspecs=__file_format_list__, returnfp=False):
def ZipFileToArrayIndex(infile, seekstart=0, seekend=0, listonly=False, skipchecksum=False, formatspecs=__file_format_list__, usenewstyle=True, returnfp=False):
catfp = BytesIO();
catfp = PackArchiveFileFromZipFile(infile, catfp, "auto", None, "crc32", [], formatspecs, False, True);
listcatfiles = ArchiveFileToArrayIndex(catfp, seekstart, seekend, listonly, skipchecksum, formatspecs, returnfp);
listcatfiles = ArchiveFileToArrayIndex(catfp, seekstart, seekend, listonly, skipchecksum, formatspecs, usenewstyle, returnfp);
return listcatfiles;

if(not rarfile_support):
def RarFileToArrayIndex(infile, seekstart=0, seekend=0, listonly=False, skipchecksum=False, formatspecs=__file_format_list__, returnfp=False):
return False;

if(rarfile_support):
def RarFileToArrayIndex(infile, seekstart=0, seekend=0, listonly=False, skipchecksum=False, formatspecs=__file_format_list__, returnfp=False):
def RarFileToArrayIndex(infile, seekstart=0, seekend=0, listonly=False, skipchecksum=False, formatspecs=__file_format_list__, usenewstyle=True, returnfp=False):
catfp = BytesIO();
catfp = PackArchiveFileFromRarFile(infile, catfp, "auto", None, "crc32", [], formatspecs, False, True);
listcatfiles = ArchiveFileToArrayIndex(catfp, seekstart, seekend, listonly, skipchecksum, formatspecs, returnfp);
listcatfiles = ArchiveFileToArrayIndex(catfp, seekstart, seekend, listonly, skipchecksum, formatspecs, usenewstyle, returnfp);
return listcatfiles;

def ListDirToArrayIndex(infiles, dirlistfromtxt=False, compression="auto", compressionlevel=None, followlink=False, seekstart=0, seekend=0, listonly=False, skipchecksum=False, checksumtype="crc32", formatspecs=__file_format_list__, verbose=False, returnfp=False):
def ListDirToArrayIndex(infiles, dirlistfromtxt=False, compression="auto", compressionlevel=None, followlink=False, seekstart=0, seekend=0, listonly=False, skipchecksum=False, checksumtype="crc32", formatspecs=__file_format_list__, verbose=False, usenewstyle=True, returnfp=False):
outarray = BytesIO();
packcat = PackArchiveFile(infiles, outarray, dirlistfromtxt, compression, compressionlevel, followlink, checksumtype, formatspecs, verbose, True);
listcatfiles = ArchiveFileToArrayIndex(outarray, seekstart, seekend, listonly, skipchecksum, formatspecs, returnfp)
listcatfiles = ArchiveFileToArrayIndex(outarray, seekstart, seekend, listonly, skipchecksum, formatspecs, usenewstyle, returnfp)
return listcatfiles;

def RePackArchiveFile(infile, outfile, compression="auto", compressionlevel=None, followlink=False, seekstart=0, seekend=0, checksumtype="crc32", skipchecksum=False, extradata=[], formatspecs=__file_format_list__, verbose=False, returnfp=False):
def RePackArchiveFile(infile, outfile, compression="auto", compressionlevel=None, followlink=False, seekstart=0, seekend=0, checksumtype="crc32", skipchecksum=False, extradata=[], formatspecs=__file_format_list__, verbose=False, usenewstyle=True, returnfp=False):
compressionlist = ['auto', 'gzip', 'bzip2', 'zstd', 'lz4', 'lzo', 'lzop', 'lzma', 'xz'];
outextlist = ['gz', 'cgz', 'bz2', 'cbz', 'zst', 'czst', 'lz4', 'lzop', 'clz4', 'lzo', 'clzo', 'lzma', 'xz', 'cxz'];
outextlistwd = ['.gz', '.cgz', '.bz2', '.cbz', '.zst', '.czst', '.lz4', 'lzop', '.clz4', '.lzo', '.clzo', '.lzma', '.xz', '.cxz'];
if(isinstance(infile, dict)):
prelistcatfiles = ArchiveFileToArrayIndex(infile, seekstart, seekend, False, skipchecksum, formatspecs, returnfp);
prelistcatfiles = ArchiveFileToArrayIndex(infile, seekstart, seekend, False, skipchecksum, formatspecs, usenewstyle, returnfp);
listcatfiles = prelistcatfiles['list'];
else:
if(infile!="-" and not hasattr(infile, "read") and not hasattr(infile, "write")):
infile = RemoveWindowsPath(infile);
if(followlink):
prelistcatfiles = ArchiveFileToArrayIndex(infile, seekstart, seekend, False, skipchecksum, formatspecs, returnfp);
prelistcatfiles = ArchiveFileToArrayIndex(infile, seekstart, seekend, False, skipchecksum, formatspecs, usenewstyle, returnfp);
listcatfiles = prelistcatfiles['list'];
else:
listcatfiles = ArchiveFileToArray(infile, seekstart, seekend, False, skipchecksum, formatspecs, returnfp);
listcatfiles = ArchiveFileToArray(infile, seekstart, seekend, False, skipchecksum, formatspecs, usenewstyle, returnfp);
if(outfile!="-" and not hasattr(infile, "read") and not hasattr(outfile, "write")):
outfile = RemoveWindowsPath(outfile);
checksumtype = checksumtype.lower();
Expand Down Expand Up @@ -4583,20 +4582,20 @@ def PackArchiveFileFromListDir(infiles, outfile, dirlistfromtxt=False, compressi

create_alias_function("Pack", __file_format_name__, "FromListDir", PackArchiveFileFromListDir);

def ArchiveFileArrayBase64Encode(infile, followlink=False, seekstart=0, seekend=0, skipchecksum=False, formatspecs=__file_format_list__, verbose=False, returnfp=False):
def ArchiveFileArrayBase64Encode(infile, followlink=False, seekstart=0, seekend=0, skipchecksum=False, formatspecs=__file_format_list__, verbose=False, usenewstyle=True, returnfp=False):
if(verbose):
logging.basicConfig(format="%(message)s", stream=sys.stdout, level=logging.DEBUG);
if(isinstance(infile, dict)):
prelistcatfiles = ArchiveFileToArrayIndex(infile, seekstart, seekend, False, skipchecksum, formatspecs, returnfp);
prelistcatfiles = ArchiveFileToArrayIndex(infile, seekstart, seekend, False, skipchecksum, formatspecs, usenewstyle, returnfp);
listcatfiles = prelistcatfiles['list'];
else:
if(infile!="-" and not hasattr(infile, "read") and not hasattr(infile, "write")):
infile = RemoveWindowsPath(infile);
if(followlink):
prelistcatfiles = ArchiveFileToArrayIndex(infile, seekstart, seekend, False, skipchecksum, formatspecs, returnfp);
prelistcatfiles = ArchiveFileToArrayIndex(infile, seekstart, seekend, False, skipchecksum, formatspecs, usenewstyle=True, returnfp);
listcatfiles = prelistcatfiles['list'];
else:
listcatfiles = ArchiveFileToArray(infile, seekstart, seekend, False, skipchecksum, formatspecs, returnfp);
listcatfiles = ArchiveFileToArray(infile, seekstart, seekend, False, skipchecksum, formatspecs, usenewstyle, returnfp);
if(not listcatfiles):
return False;
lenlist = len(listcatfiles['ffilelist']);
Expand All @@ -4621,20 +4620,20 @@ def ArchiveFileArrayBase64Encode(infile, followlink=False, seekstart=0, seekend=

create_alias_function("", __file_format_name__, "ArrayBase64Encode", ArchiveFileArrayBase64Encode);

def ArchiveFileArrayBase64Decode(infile, followlink=False, seekstart=0, seekend=0, skipchecksum=False, formatspecs=__file_format_list__, verbose=False, returnfp=False):
def ArchiveFileArrayBase64Decode(infile, followlink=False, seekstart=0, seekend=0, skipchecksum=False, formatspecs=__file_format_list__, verbose=False, usenewstyle=True, returnfp=False):
if(verbose):
logging.basicConfig(format="%(message)s", stream=sys.stdout, level=logging.DEBUG);
if(isinstance(infile, dict)):
prelistcatfiles = ArchiveFileToArrayIndex(infile, seekstart, seekend, False, skipchecksum, formatspecs, returnfp);
prelistcatfiles = ArchiveFileToArrayIndex(infile, seekstart, seekend, False, skipchecksum, formatspecs, usenewstyle, returnfp);
listcatfiles = prelistcatfiles['list'];
else:
if(infile!="-" and not hasattr(infile, "read") and not hasattr(infile, "write")):
infile = RemoveWindowsPath(infile);
if(followlink):
prelistcatfiles = ArchiveFileToArrayIndex(infile, seekstart, seekend, False, skipchecksum, formatspecs, returnfp);
prelistcatfiles = ArchiveFileToArrayIndex(infile, seekstart, seekend, False, skipchecksum, formatspecs, usenewstyle, returnfp);
listcatfiles = prelistcatfiles['list'];
else:
listcatfiles = ArchiveFileToArray(infile, seekstart, seekend, False, skipchecksum, formatspecs, returnfp);
listcatfiles = ArchiveFileToArray(infile, seekstart, seekend, False, skipchecksum, formatspecs, usenewstyle, returnfp);
if(not listcatfiles):
return False;
lenlist = len(listcatfiles['ffilelist']);
Expand All @@ -4659,22 +4658,22 @@ def ArchiveFileArrayBase64Decode(infile, followlink=False, seekstart=0, seekend=

create_alias_function("", __file_format_name__, "ArrayBase64Decode", ArchiveFileArrayBase64Decode);

def UnPackArchiveFile(infile, outdir=None, followlink=False, seekstart=0, seekend=0, skipchecksum=False, formatspecs=__file_format_list__, verbose=False, returnfp=False):
def UnPackArchiveFile(infile, outdir=None, followlink=False, seekstart=0, seekend=0, skipchecksum=False, formatspecs=__file_format_list__, verbose=False, usenewstyle=True, returnfp=False):
if(outdir is not None):
outdir = RemoveWindowsPath(outdir);
if(verbose):
logging.basicConfig(format="%(message)s", stream=sys.stdout, level=logging.DEBUG);
if(isinstance(infile, dict)):
prelistcatfiles = ArchiveFileToArrayIndex(infile, seekstart, seekend, False, skipchecksum, formatspecs, returnfp);
prelistcatfiles = ArchiveFileToArrayIndex(infile, seekstart, seekend, False, skipchecksum, formatspecs, usenewstyle, returnfp);
listcatfiles = prelistcatfiles['list'];
else:
if(infile!="-" and not hasattr(infile, "read") and not hasattr(infile, "write")):
infile = RemoveWindowsPath(infile);
if(followlink):
prelistcatfiles = ArchiveFileToArrayIndex(infile, seekstart, seekend, False, skipchecksum, formatspecs, returnfp);
prelistcatfiles = ArchiveFileToArrayIndex(infile, seekstart, seekend, False, skipchecksum, formatspecs, usenewstyle, returnfp);
listcatfiles = prelistcatfiles['list'];
else:
listcatfiles = ArchiveFileToArray(infile, seekstart, seekend, False, skipchecksum, formatspecs, returnfp);
listcatfiles = ArchiveFileToArray(infile, seekstart, seekend, False, skipchecksum, formatspecs, usenewstyle, returnfp);
if(not listcatfiles):
return False;
lenlist = len(listcatfiles['ffilelist']);
Expand Down Expand Up @@ -4861,14 +4860,14 @@ def UnPackArchiveFileString(catstr, outdir=None, followlink=False, seekstart=0,

create_alias_function("UnPack", __file_format_name__, "String", UnPackArchiveFileString);

def ArchiveFileListFiles(infile, seekstart=0, seekend=0, skipchecksum=False, formatspecs=__file_format_list__, verbose=False, returnfp=False):
def ArchiveFileListFiles(infile, seekstart=0, seekend=0, skipchecksum=False, formatspecs=__file_format_list__, verbose=False, usenewstyle=True, returnfp=False):
logging.basicConfig(format="%(message)s", stream=sys.stdout, level=logging.DEBUG);
if(isinstance(infile, dict)):
listcatfiles = infile;
else:
if(infile!="-" and not hasattr(infile, "read") and not hasattr(infile, "write")):
infile = RemoveWindowsPath(infile);
listcatfiles = ArchiveFileToArray(infile, seekstart, seekend, True, skipchecksum, formatspecs, returnfp);
listcatfiles = ArchiveFileToArray(infile, seekstart, seekend, True, skipchecksum, formatspecs, usenewstyle, returnfp);
if(not listcatfiles):
return False;
lenlist = len(listcatfiles['ffilelist']);
Expand Down

0 comments on commit 8caae3d

Please sign in to comment.