Skip to content

Refactor UnzipFileToMemory and getZipFileContents to use iterator#63

Open
wallclimber21 wants to merge 11 commits into
mattconnolly:masterfrom
wallclimber21:iterate
Open

Refactor UnzipFileToMemory and getZipFileContents to use iterator#63
wallclimber21 wants to merge 11 commits into
mattconnolly:masterfrom
wallclimber21:iterate

Conversation

@wallclimber21
Copy link
Copy Markdown

This patch adds the following iterator function:

-(BOOL)iterateZipFileContentsWithCheckDecompressBlock:(ZipArchiveCheckDecompressBlock)checkDecompressBlock dataAcceptBlock:(ZipArchiveDataAcceptBlock)dataAcceptBlock;

It loops over all entires in a zip file. For each entry, it first calls the CheckDecompressBlock to see if the file should be decompressed, and if so, then call the dataAcceptBlock with the decompressed data.

For some cases, this reduces the peak memory usage by orders of magnitude. (E.g. I have a .zip file with a thousand smaller entries that need to be imported into a sqlite database.)

The patch also refactors UnzipFileToMemory and getZipFileContents to use this iterator.

@mattconnolly
Copy link
Copy Markdown
Owner

Can you rename the method to be "enumerate" instead of "iterate" to be consistent with NSArray, NSFileManager, NSFastEnumeration etc.

@wallclimber21
Copy link
Copy Markdown
Author

Not sure if it will automatically show up here, but there was a crucial bug in the unzip code, that I fixed after renaming the iterate to enumerate. It's already present in my tree.

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