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 29, 2024
1 parent b569a1a commit da6bae7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pycatfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,10 +1031,12 @@ def AppendFileHeaderWithContent(fp, filevalues=[], extradata=[], filecontent="",
if(len(extradata)>0):
extrasizestr = extrasizestr + AppendNullBytes(extradata, formatspecs[5]);
extrasizelen = format(len(extrasizestr), 'x').lower();
catoutlen = len(filevalues) + len(extradata) + 3;
catoutlen = len(filevalues) + len(extradata) + 5;
catoutlenhex = format(catoutlen, 'x').lower();
catoutlist = filevalues;
catoutlist.insert(0, catoutlenhex);
catoutlist.append(extrasizelen);
catoutlist.append(extrafields);
catfileoutstr = AppendNullBytes(catoutlist, formatspecs[5]);
if(len(extradata)>0):
catfileoutstr = catfileoutstr + AppendNullBytes(extradata, formatspecs[5]);
Expand All @@ -1044,6 +1046,7 @@ def AppendFileHeaderWithContent(fp, filevalues=[], extradata=[], filecontent="",
tmpfileoutstr = catfileoutstr + AppendNullBytes([catfileheadercshex, catfilecontentcshex], formatspecs[5]);
catheaersize = format(int(len(tmpfileoutstr) - 1), 'x').lower();
catfileoutstr = AppendNullByte(catheaersize, formatspecs[5]) + catfileoutstr;
catfileheadercshex = GetFileChecksum(catfileoutstr, checksumtype, True, formatspecs);
catfileoutstr = catfileoutstr + AppendNullBytes([catfileheadercshex, catfilecontentcshex], formatspecs[5]);
catfileoutstrecd = catfileoutstr.encode('UTF-8');
nullstrecd = formatspecs[5].encode('UTF-8');
Expand All @@ -1058,7 +1061,7 @@ def AppendFileHeaderWithContent(fp, filevalues=[], extradata=[], filecontent="",
pass;
return fp;

def AppendFiles(infiles, fp, dirlistfromtxt=False, filevalues=[], extradata=[], followlink=False, checksumtype="crc32", formatspecs=__file_format_list__):
def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], extradata=[], followlink=False, checksumtype="crc32", formatspecs=__file_format_list__):
advancedlist = True;
if(infiles=="-"):
for line in sys.stdin:
Expand Down Expand Up @@ -1230,7 +1233,7 @@ def AppendFiles(infiles, fp, dirlistfromtxt=False, filevalues=[], extradata=[],
fp.seek(0, 0);
return fp;

def AppendFilesToOutFile(infile, outfile, dirlistfromtxt=False, compression="auto", compressionlevel=None, filevalues=[], extradata=[], followlink=False, checksumtype="crc32", formatspecs=__file_format_list__, returnfp=False):
def AppendFilesWithContentToOutFile(infile, outfile, dirlistfromtxt=False, compression="auto", compressionlevel=None, filevalues=[], extradata=[], followlink=False, checksumtype="crc32", formatspecs=__file_format_list__, returnfp=False):
if(outfile!="-" and not hasattr(outfile, "read") and not hasattr(outfile, "write")):
if(os.path.exists(outfile)):
os.unlink(outfile);
Expand All @@ -1245,7 +1248,7 @@ def AppendFilesToOutFile(infile, outfile, dirlistfromtxt=False, compression="aut
fbasename = os.path.splitext(outfile)[0];
fextname = os.path.splitext(outfile)[1];
catfp = CompressOpenFile(outfile, compressionlevel);
catfp = AppendFiles(infile, catfp, dirlistfromtxt, filevalues, extradata, followlink, checksumtype, formatspecs);
catfp = AppendFilesWithContent(infile, catfp, dirlistfromtxt, filevalues, extradata, followlink, checksumtype, formatspecs);
if(outfile=="-" or hasattr(outfile, "read") or hasattr(outfile, "write")):
catfp = CompressArchiveFile(catfp, compression, formatspecs);
try:
Expand Down

0 comments on commit da6bae7

Please sign in to comment.