Hi all,
I'd like to unzip some multiple zip files ( xxx.zip.001, xxx.zip.002, etc) that I've created using 7zip splitted in small file sizes.
I am using the following code:
for kind, path in walkDir "C:\\tmp\\testzip":
if "zip.001" in path:
echo path
var z: ZipArchive
if not z.open(path):
echo "Opening zip failed"
quit(1)
# extracts all files from archive z to the destination directory.
z.extractAll("C:\\tmp\\testzip")
and it doesn't work, the same code works for a single zip file.
Is there a specific way for opening multi-part zip files?
Regards Fabien
Thank you, it works once files merged. I tested it under dos first > copy /b xxx.zip.001 + xxx.zip.002 + xxx.zip.003 + xxx.zip.004 xxx.zip
then test the merge in nim, perhaps not the shortest way, but it works:
var files: seq[string]
for kind, path in walkDir "C:\\tmp\\testzip":
if "zip." in path:
files.add(path)
for file in files.sorted(system.cmp[string]):
const size = 8192
var
i = open(file)
o = open("C:\\tmp\\test.zip", fmAppend)
buf: array[size, char]
while i.readBuffer(buf.addr, size) > 0:
discard o.writeBuffer(buf.addr, size)
i.close()
o.close()
var z: ZipArchive
if not z.open("C:\\tmp\\test.zip"):
echo "Opening zip failed"
quit(1)
# extracts all files from archive z to the destination directory.
z.extractAll("C:\\tmp\\testzip")
I will handle large files and I first tried using mem files as showed in Rosetta io code example:https://www.rosettacode.org/wiki/File_input/output#Nim but the merged file produced was not the good size and not readable by zip program, strange but didn't try to figure out why