I'm trying to write something to extract the contents from zipfiles (using the zipfiles module), but I keep running into an error.
Error:
Traceback (most recent call last)
epub.nim(98) epub
epub.nim(78) unpackEPUB
zipfiles.nim(160) extractFile
zipfiles.nim(151) extractFile
streams.nim(51) atEnd
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Code that causes the error:
proc unpackEPUB*(filename : string, destination : string): bool =
var archive : TZipArchive
var state : bool = archive.open(filename, fmRead)
if not state:
return false
for i in walkFiles(archive):
archive.extractFile(i, destination & i)
return true
echo(unpackEPUB("test.epub", "/home/adam/"))
Code compiles successfully, but seems to run into a problem when it comes to the file streams. The files are definitely there, as walkFiles() gives them all. Any help would be appreciated.
## The returned stream does not support the `setPosition`, `getPosition`,
## `writeData` or `atEnd` methods.
Immediately after that call atEnd() is used. Maybe that module is half finished and that's why there is an undocumented wrapper for libzzip which presumably offers read access only to zip files?