Open mantielero opened 8 months ago
The aforementioned solution would only solve the problem for storing entire folders.
The point of addFile
is also being able to manually add individual files into an archive.
Otherwise, the currently exposed addDir
would suffice, or even the standard createZipArchive
would be enough, which is already a thin wrapper for addDir
I also run into this problem, and I'm going to have to resort to using nim-lang/zip, even though I would much prefer to use this lib :( Hopefully Guzba can get back to this issue sometime in the future. Would be awesome.
Actually, I just tried this approach again, and it did work this time :man_shrugging:
proc zip *(list :seq[Path]; trg :Path; rel :Path= Path".") :void=
## @descr Zips the {@arg list} of files into the {@arg trg} file
var entries: Table[string, string]
withDir rel:
for file in list:
entries[file.relativePath(rel).string] = file.readFile
trg.writeFile(createZipArchive(entries))
Adding it here for future reference if somebody lands into this issue :writing_hand:
I am trying to store files so that they keep the desire structure within the zipfile.
I see that there is addDir with signature:
proc addDir(archive: ZipArchive, base, relative: string)
. I think it would be a good idea to expose it.Something similar for
addFile
would be appreciated.nim-lang/zip
has it.