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 7, 2024
1 parent da26c7f commit 767b8a2
Show file tree
Hide file tree
Showing 2 changed files with 749 additions and 4 deletions.
18 changes: 15 additions & 3 deletions catfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
import os, sys, logging, argparse, pycatfile, binascii;
from io import open as open;

rarfile_support = False;
try:
import rarfile;
rarfile_support = True;
except ImportError:
rarfile_support = False;

if(sys.version[0]=="2"):
try:
from io import StringIO, BytesIO;
Expand Down Expand Up @@ -80,12 +87,13 @@
argparser.add_argument("-delimiter", "--delimiter", default=__file_format_list__[4], help="Specify the format to use");
argparser.add_argument("-formatver", "--formatver", default=__file_format_list__[5], help="Specify the format version");
argparser.add_argument("-l", "-t", "--list", action="store_true", help="List files included in the concatenated file.");
argparser.add_argument("-r", "--repack", action="store_true", help="Re-concatenate files, fixing checksum errors if any.");
argparser.add_argument("-repack", "--repack", action="store_true", help="Re-concatenate files, fixing checksum errors if any.");
argparser.add_argument("-o", "--output", default=None, help="Specify the name for the extracted concatenated files or the output concatenated file.");
argparser.add_argument("-compression", "--compression", default="auto", help="Specify the compression method to use for concatenation.");
argparser.add_argument("-level", "--level", default=None, help="Specify the compression level for concatenation.");
argparser.add_argument("-t", "--converttar", action="store_true", help="Convert a tar file to a catfile.");
argparser.add_argument("-z", "--convertzip", action="store_true", help="Convert a zip file to a catfile.");
argparser.add_argument("-t", "-tar", "--converttar", action="store_true", help="Convert a tar file to a catfile.");
argparser.add_argument("-z", "-zip", "--convertzip", action="store_true", help="Convert a zip file to a catfile.");
argparser.add_argument("-rar", "--convertrar", action="store_true", help="Convert a rar file to a catfile.");
argparser.add_argument("-T", "--text", action="store_true", help="Read file locations from a text file.");
getargs = argparser.parse_args();

Expand All @@ -108,6 +116,8 @@
pycatfile.PackArchiveFileFromTarFile(getargs.input, getargs.output, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
elif getargs.convertzip:
pycatfile.PackArchiveFileFromZipFile(getargs.input, getargs.output, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
elif rarfile_support and getargs.convertrar:
pycatfile.PackArchiveFileFromRarFile(getargs.input, getargs.output, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
else:
pycatfile.PackArchiveFile(getargs.input, getargs.output, getargs.text, getargs.compression, getargs.level, False, getargs.checksum, [], fnamelist, getargs.verbose, False);

Expand All @@ -122,5 +132,7 @@
pycatfile.TarFileListFiles(getargs.input, getargs.verbose, False);
elif getargs.convertzip:
pycatfile.ZipFileListFiles(getargs.input, getargs.verbose, False);
elif rarfile_support and getargs.convertrar:
pycatfile.RarFileListFiles(getargs.input, getargs.verbose, False);
else:
pycatfile.ArchiveFileListFiles(getargs.input, 0, 0, False, fnamelist, getargs.verbose, False);
Loading

0 comments on commit 767b8a2

Please sign in to comment.