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

API to remove multiple entries at once #109

Open
Mark-s99 opened this issue Apr 9, 2019 · 1 comment
Open

API to remove multiple entries at once #109

Mark-s99 opened this issue Apr 9, 2019 · 1 comment

Comments

@Mark-s99
Copy link

Mark-s99 commented Apr 9, 2019

Currently entries can be removed one at a time, each time a temporary archive is created that replaces the original.

Would you consider extending the API to allow removing a list of entries?

For example:

public func remove(_ entries: [Entry], bufferSize: UInt32 = defaultReadChunkSize, 
                                  progress: Progress? = nil) throws

I'm currently looking into adding this myself, but I have not wrapped my head around CentralDirectoryStructure and endOfCentralDirectoryRecord and the various offsets that are involved.

Thank you!

@weichsel
Copy link
Owner

Removing entries from ZIP archives is - in contrast to entry addition - very expensive. So providing a "batch removal" method would certainly make sense.
ZIP Foundation removes an entry by re-writing the whole archive to a temp file, but skipping the entry to remove. The part to skip is from Entry.centraldDirectoryStructure.relativeOffsetToLocalHeader to the end of the data section of the file. Wikipedia has a good introduction + diagram about the structure of archives:
https://en.wikipedia.org/wiki/Zip_(file_format)#Structure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants