Skip to content
pixelglow edited this page Oct 27, 2012 · 31 revisions

Easy-to-use interface

Archive classes

Archive entry classes

The ZZArchiveEntry class is a class cluster that serves as a facade for both existing ( ZZOldArchiveEntry ) and new ( ZZNewArchiveEntry ) entries. You can inspect zip entry fields through the corresponding property.

Streaming support

Mac OS X and iOS developers typically use a combination of NSData, NSInputStream / NSOutputStream and CGDataProviderRef / CGDataConsumerRef classes to move data in and out of disk files. We support all of these methods.

Efficient implementation

Zip file reading

Instead of explicitly reading in portions of the zip file, we make a read-only memory map of the entire content. So when memory goes low, the operating system can just discard parts of the zip file in memory instead of paging it to the swap file (Mac OS X) or running out of usable memory (iOS).

  • Existing deflated entries either use, wrap or just return a ZZInflateInputStream instance that inflates the entry data from the memory map.

  • Existing stored entries either use, wrap or just return the raw entry data from the memory map.

Zip file writing

You can supply new entry content just-in-time while writing out the zip file, instead of all-at-once before writing. This technique uses blocks that are called back while writing to the open zip file handle. In particular, you can use streaming API like NSStream and CGDataConsumer to save even more memory.

  • New deflated entries either use, wrap or just provide a ZZDeflateOutputStream instance to your callback that deflates to the open zip file handle.

  • New stored entries either wrap or just provide a ZZStoreOutputStream instance to your callback that stores to the open zip file handle.

Zip file rewriting

If you are updating an existing zip file, we will skip reading and writing any initial unchanged entries. This idea reduces disk thrashing for document formats that keep large unchanging files toward the zip file start, and small changing files toward the zip file end.

For example, a HTML editor could keep a self-contained website's images at zip file start and its actual HTML at zip file end, and only have to pay for writing out the HTML when that changes.

If the entries at the end are compressed, the zip file write may end up faster than writing the entries as separate files.

File format compatibility

Zipzap closely follows the zip file format specification. In particular, we support reading xxx. However any data descriptors need to be prefaced with the right signature. We currently don't support Zip64 or encrypted zip files (but we could, in the future). Zipzap writes xxx. Zipzap features an extensive unit test suite that tests the library against the command-line zip, unzip and zipinfo tools.

Alternatives

File formats

  • plist

Libraries

  • minizip
Clone this wiki locally