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 Apr 29, 2024
1 parent 2fd246f commit c450aaf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 103 deletions.
70 changes: 20 additions & 50 deletions catfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,35 +118,23 @@
if should_create:
if getargs.convert:
checkcompressfile = pycatfile.CheckCompressionSubType(getargs.input, fnamelist, True);
if(checkcompressfile=="tarfile"):
pycatfile.PackArchiveFileFromTarFile(getargs.input, getargs.output, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
elif(checkcompressfile=="zipfile"):
pycatfile.PackArchiveFileFromZipFile(getargs.input, getargs.output, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
elif(checkcompressfile=="catfile"):
pycatfile.RePackArchiveFile(getargs.input, getargs.output, getargs.compression, getargs.level, False, 0, 0, getargs.checksum, getargs.skipchecksum, [], fnamelist, getargs.verbose, False);
elif(rarfile_support and checkcompressfile=="rarfile"):
pycatfile.PackArchiveFileFromRarFile(getargs.input, getargs.output, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
elif(py7zr_support and checkcompressfile=="7zipfile"):
pycatfile.PackArchiveFileFromSevenZipFile(getargs.input, getargs.output, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
if(checkcompressfile=="catfile"):
tmpout = pycatfile.RePackArchiveFile(getargs.input, getargs.output, getargs.compression, getargs.level, False, 0, 0, getargs.checksum, getargs.skipchecksum, [], fnamelist, getargs.verbose, False);
else:
tmpout = pycatfile.PackArchiveFileFromInFile(getargs.input, getargs.output, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
if(not tmpout):
sys.exit(1);
else:
pycatfile.PackArchiveFile(getargs.input, getargs.output, getargs.text, getargs.compression, getargs.level, False, getargs.checksum, [], fnamelist, getargs.verbose, False);

elif should_repack:
if getargs.convert:
checkcompressfile = pycatfile.CheckCompressionSubType(getargs.input, fnamelist, True);
if(checkcompressfile=="tarfile"):
pycatfile.PackArchiveFileFromTarFile(getargs.input, getargs.output, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
elif(checkcompressfile=="zipfile"):
pycatfile.PackArchiveFileFromZipFile(getargs.input, getargs.output, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
elif(checkcompressfile=="catfile"):
if(checkcompressfile=="catfile"):
pycatfile.RePackArchiveFile(getargs.input, getargs.output, getargs.compression, getargs.level, False, 0, 0, getargs.checksum, getargs.skipchecksum, [], fnamelist, getargs.verbose, False);
elif(rarfile_support and checkcompressfile=="rarfile"):
pycatfile.PackArchiveFileFromRarFile(getargs.input, getargs.output, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
elif(py7zr_support and checkcompressfile=="7zipfile"):
pycatfile.PackArchiveFileFromSevenZipFile(getargs.input, getargs.output, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
else:
pycatfile.PackArchiveFileFromInFile(getargs.input, getargs.output, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
if(not tmpout):
sys.exit(1);
else:
pycatfile.RePackArchiveFile(getargs.input, getargs.output, getargs.compression, getargs.level, False, 0, 0, getargs.checksum, getargs.skipchecksum, [], fnamelist, getargs.verbose, False);
Expand All @@ -155,35 +143,23 @@
if getargs.convert:
checkcompressfile = pycatfile.CheckCompressionSubType(getargs.input, fnamelist, True);
tempout = BytesIO();
if(checkcompressfile=="tarfile"):
pycatfile.PackArchiveFileFromTarFile(getargs.input, tempout, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
elif(checkcompressfile=="zipfile"):
pycatfile.PackArchiveFileFromZipFile(getargs.input, tempout, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
elif(checkcompressfile=="catfile"):
pycatfile.RePackArchiveFile(getargs.input, tempout, getargs.compression, getargs.level, False, 0, 0, getargs.checksum, getargs.skipchecksum, [], fnamelist, getargs.verbose, False);
elif(rarfile_support and checkcompressfile=="rarfile"):
pycatfile.PackArchiveFileFromRarFile(getargs.input, tempout, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
elif(py7zr_support and checkcompressfile=="7zipfile"):
pycatfile.PackArchiveFileFromSevenZipFile(getargs.input, tempout, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
if(checkcompressfile=="catfile"):
tmpout = pycatfile.RePackArchiveFile(getargs.input, tempout, getargs.compression, getargs.level, False, 0, 0, getargs.checksum, getargs.skipchecksum, [], fnamelist, getargs.verbose, False);
else:
tmpout = pycatfile.PackArchiveFileFromInFile(getargs.input, tempout, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
if(not tmpout):
sys.exit(1);
getargs.input = tempout;
pycatfile.UnPackArchiveFile(getargs.input, getargs.output, False, 0, 0, getargs.skipchecksum, fnamelist, getargs.verbose, getargs.preserve, getargs.preserve, False);

elif should_list:
if getargs.convert:
checkcompressfile = pycatfile.CheckCompressionSubType(getargs.input, fnamelist, True);
if(checkcompressfile=="tarfile"):
pycatfile.TarFileListFiles(getargs.input, getargs.verbose, False);
elif(checkcompressfile=="zipfile"):
pycatfile.ZipFileListFiles(getargs.input, getargs.verbose, False);
elif(checkcompressfile=="catfile"):
pycatfile.ArchiveFileListFiles(getargs.input, 0, 0, getargs.skipchecksum, fnamelist, getargs.verbose, False);
elif(rarfile_support and checkcompressfile=="rarfile"):
pycatfile.RarFileListFiles(getargs.input, getargs.verbose, False);
elif(py7zr_support and checkcompressfile=="7zipfile"):
pycatfile.SevenZipFileListFiles(getargs.input, getargs.verbose, False);
if(checkcompressfile=="catfile"):
tmpout = pycatfile.ArchiveFileListFiles(getargs.input, 0, 0, getargs.skipchecksum, fnamelist, getargs.verbose, False);
else:
tmpout = pycatfile.InFileListFiles(getargs.input, getargs.verbose, False);
if(not tmpout):
sys.exit(1);
else:
pycatfile.ArchiveFileListFiles(getargs.input, 0, 0, getargs.skipchecksum, fnamelist, getargs.verbose, False);
Expand All @@ -192,19 +168,13 @@
if getargs.convert:
checkcompressfile = pycatfile.CheckCompressionSubType(getargs.input, fnamelist, True);
tempout = BytesIO();
if(checkcompressfile=="tarfile"):
pycatfile.PackArchiveFileFromTarFile(getargs.input, tempout, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
elif(checkcompressfile=="zipfile"):
pycatfile.PackArchiveFileFromZipFile(getargs.input, tempout, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
elif(checkcompressfile=="catfile"):
pycatfile.RePackArchiveFile(getargs.input, tempout, getargs.compression, getargs.level, False, 0, 0, getargs.checksum, getargs.skipchecksum, [], fnamelist, getargs.verbose, False);
elif(rarfile_support and checkcompressfile=="rarfile"):
pycatfile.PackArchiveFileFromRarFile(getargs.input, tempout, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
elif(py7zr_support and checkcompressfile=="7zipfile"):
pycatfile.PackArchiveFileFromSevenZipFile(getargs.input, tempout, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
if(checkcompressfile=="catfile"):
tmpout = pycatfile.RePackArchiveFile(getargs.input, tempout, getargs.compression, getargs.level, False, 0, 0, getargs.checksum, getargs.skipchecksum, [], fnamelist, getargs.verbose, False);
else:
sys.exit(1);
tmpout = pycatfile.PackArchiveFileFromInFile(getargs.input, tempout, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
getargs.input = tempout;
if(not tmpout):
sys.exit(1);
fvalid = pycatfile.ArchiveFileValidate(getargs.input, fnamelist, getargs.verbose, False);
if(not getargs.verbose):
import sys, logging;
Expand Down
54 changes: 1 addition & 53 deletions pycatfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7245,58 +7245,6 @@ def ArchiveFileStringListFiles(catstr, seekstart=0, seekend=0, skipchecksum=Fals

create_alias_function("", __file_format_name__, "StringListFiles", ArchiveFileListFiles);

def ArchiveFileListFilesAlt(infile, seekstart=0, seekend=0, skipchecksum=False, formatspecs=__file_format_list__, verbose=False, 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);
if(not listcatfiles):
return False;
lenlist = len(listcatfiles['ffilelist']);
fnumfiles = int(listcatfiles['fnumfiles']);
lcfi = 0;
lcfx = int(listcatfiles['fnumfiles']);
if(lenlist>listcatfiles['fnumfiles'] or lenlist<listcatfiles['fnumfiles']):
lcfx = int(lenlist);
else:
lcfx = int(listcatfiles['fnumfiles']);
returnval = {};
while(lcfi<lcfx):
returnval.update({lcfi: listcatfiles['ffilelist'][lcfi]['fname']});
if(not verbose):
VerbosePrintOut(listcatfiles['ffilelist'][lcfi]['fname']);
if(verbose):
permissions = { 'access': { '0': ('---'), '1': ('--x'), '2': ('-w-'), '3': ('-wx'), '4': ('r--'), '5': ('r-x'), '6': ('rw-'), '7': ('rwx') }, 'roles': { 0: 'owner', 1: 'group', 2: 'other' } };
printfname = listcatfiles['ffilelist'][lcfi]['fname'];
if(listcatfiles['ffilelist'][lcfi]['ftype']==1):
printfname = listcatfiles['ffilelist'][lcfi]['fname'] + " link to " + listcatfiles['ffilelist'][lcfi]['flinkname'];
if(listcatfiles['ffilelist'][lcfi]['ftype']==2):
printfname = listcatfiles['ffilelist'][lcfi]['fname'] + " -> " + listcatfiles['ffilelist'][lcfi]['flinkname'];
fuprint = listcatfiles['ffilelist'][lcfi]['funame'];
if(len(fuprint)<=0):
fuprint = listcatfiles['ffilelist'][lcfi]['fuid'];
fgprint = listcatfiles['ffilelist'][lcfi]['fgname'];
if(len(fgprint)<=0):
fgprint = listcatfiles['ffilelist'][lcfi]['fgid'];
VerbosePrintOut(PrintPermissionString(listcatfiles['ffilelist'][lcfi]['fmode'], listcatfiles['ffilelist'][lcfi]['ftype']) + " " + str(str(fuprint) + "/" + str(fgprint) + " " + str(listcatfiles['ffilelist'][lcfi]['fsize']).rjust(15) + " " + datetime.datetime.utcfromtimestamp(listcatfiles['ffilelist'][lcfi]['fmtime']).strftime('%Y-%m-%d %H:%M') + " " + printfname));
lcfi = lcfi + 1;
if(returnfp):
return listcatfiles['catfp'];
else:
return True;

create_alias_function("", __file_format_name__, "ListFilesAlt", ArchiveFileListFilesAlt);

def ArchiveFileStringListFilesAlt(catstr, seekstart=0, seekend=0, skipchecksum=False, formatspecs=__file_format_list__, verbose=False, returnfp=False):
catfp = BytesIO(catstr);
listcatfiles = ArchiveFileListFilesAlt(catstr, seekstart, seekend, skipchecksum, formatspecs, verbose, returnfp);
return listcatfiles;

create_alias_function("", __file_format_name__, "StringListFilesAlt", ArchiveFileListFilesAlt);

def TarFileListFiles(infile, verbose=False, returnfp=False):
logging.basicConfig(format="%(message)s", stream=sys.stdout, level=logging.DEBUG);
if(infile=="-"):
Expand Down Expand Up @@ -7760,7 +7708,7 @@ def InFileListFiles(infile, verbose=False, formatspecs=__file_format_list__, ret
elif(checkcompressfile=="zipfile"):
return ZipFileListFiles(infile, verbose, returnfp);
elif(checkcompressfile=="catfile"):
return ArchiveFileListFilesAlt(infile, 0, 0, False, formatspecs, verbose, returnfp);
return ArchiveFileListFiles(infile, 0, 0, False, formatspecs, verbose, returnfp);
elif(rarfile_support and checkcompressfile=="rarfile"):
return RarFileListFiles(infile, verbose, returnfp);
elif(py7zr_support and checkcompressfile=="7zipfile"):
Expand Down

0 comments on commit c450aaf

Please sign in to comment.