Modified module ziparchives to alternatively open zip files as byte strings.
#90
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The module
ziparchivesfeatures a modifiedZipArchiveReaderobject type. It now contains astring-based alternative to amemfile, and a newZipArchiveReaderModeto determine which field to read from. There are two new utility procs:getDataPtr()andgetDataLen(), which depending on the mode of the input reader, get the casted data pointer or the length.Most of
openZipArchive()was moved into a newopenZipArchiveInternal(), which features all of the internal zip archive reading logic. The procopenZipArchive*()is now a wrapper for initializing a reader inMemfileMode. The procopenZipArchiveBytes*()is a wrapper for opening a zip archive inStringMode, and takes a string of bytes; the returned reader can perform operations on those bytes as a .zip file, performing all operations in-memory.Correspondingly,
extractAll*()had an alternative spun out,extractAllBytes*(), which extracts a byte-string archive to the chosen directory. The common internal logic was given its own procextractAllInternal(), and the directory check was given its own proccheckExtractDestination().There are also two extra files present at a higher level. The
inner_test.ziparchive has three internal .zip files, each containing three internal text files, where the filename is a number and the contents are that number's corresponding whole English word. This is a test artifact fortest_ziparchives_inmem.nim, which can be run from its own directory withnim r test_ziparchives_inmem.nim. This test extracts all the text files flatly to the working directory. There is an alternative that extracts each inner archive to its own directory usingextractAllBytes*(). It should be noted that running this may conflict with any nimble-installed versions of zippy, so it should be isolated.