ZIPFoundation
ZIPFoundation copied to clipboard
API to remove multiple entries at once
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!
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