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.
Hi,
Great little library, been using it for some prototyping on an embedded platform recently.
Had a need to extract large files (3-5MB...on an embedded system) from a zip directly to a waiting web server client.
Callback method was a good start but network stack memory usage became an issue.
Therefore I've written an iterative decompression method, allowing a file to be decompressed in variable sized chunks - allowing me to load small chunks at a time into my socket as the TCP buffers empty.
I've based it heavily on the callback method.
A state instance (containing the variables which were on the stack before with the callback extractor) can be created with mz_zip_reader_extract_iter_new or mz_zip_reader_extract_file_iter_new.
Once constructed the compressed file can be read either compressed or decompressed via mz_zip_reader_extract_iter_read.
Finally the state object can be destroyed via mz_zip_reader_extract_iter_free.
I've included a few tests for it in the tests directory. The build passes with the different combinations of flag tested in test.sh.
I've also tested it extensively myself, with gcov and valgrind.
I've tested both zips hosted in memory (my use case....directly from Flash) as well as zips being loaded from files. I've checked it gracefully handles empty files and directories...passed either by index or by name.
Love to see it included,
Keep up the good work!
Phil