Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iterative decompression #66

Merged
merged 2 commits into from
Jul 8, 2017

Conversation

unsightlygod
Copy link
Contributor

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

@uroni uroni merged commit 64d92e1 into richgel999:master Jul 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants