Giter Site home page Giter Site logo

zipzap's Introduction

Build Status

ZipZap is a zip file I/O library for Mac OS X and iOS.

The zip file is an ideal container for compound Objective-C documents. Zip files are widely used and well understood. You can randomly access their parts. The format compresses decently and has extensive operating system and tool support. So we want to make this format an even easier choice for you. Thus, the library features:

  • Easy-to-use interface: The public API offers just two classes! Yet you can look through zip files using familiar NSArray collections and properties. And you can zip, unzip and rezip zip files through familiar NSData, NSStream and Image I/O classes.
  • Efficient implementation: We've optimized zip file reading and writing to reduce virtual memory pressure and disk file thrashing. Depending on how your compound document is organized, updating a single entry can be faster than writing the same data to a separate file.
  • File format compatibility: Since ZipZap closely follows the zip file format specification, it works with most Mac, Linux and Windows zip tools.

Install

As an independent project:

  • In the Terminal, run git clone https://github.com/pixelglow/ZipZap.git.
  • Within the ZipZap directory, open the ZipZap.xcodeproj Xcode project.
  • In the Xcode project, select either the ZipZap (iOS Framework), ZipZap (iOS Static Library), ZipZap (OS X Framework) or ZipZap (OS X Static Library) scheme from the drop down.
  • You can now build, test (Mac OS X only) or analyze with the selected scheme.
  • The built libraries and test cases are in a subdirectory of ~/Library/Developer/Xcode/DerivedData.

As a project integrated with your own workspace:

  • In the Terminal, run cd workspace then git submodule add https://github.com/pixelglow/ZipZap.git.
  • In your Xcode workspace, choose the File > Add Files to "workspace" menu item, then within the ZipZap directory pick the ZipZap.xcodeproj Xcode project.
  • In any project target that will use ZipZap:
    • In Build Phases > Link Binary With Libraries, add the corresponding libZipZap.a and any other library listed in the Require Link section below.
    • Under Build Settings > Search Paths > Header Search Paths, add ../ZipZap.
  • You can now build, test or analyze those project targets.

Use

Header includes:

#import <ZipZap/ZipZap.h>

Reading an existing zip file:

ZZArchive* oldArchive = [ZZArchive archiveWithURL:[NSURL fileURLWithPath:@"/tmp/old.zip"]
                                            error:nil];
ZZArchiveEntry* firstArchiveEntry = oldArchive.entries[0];
NSLog(@"The first entry's uncompressed size is %lu bytes.", (unsigned long)firstArchiveEntry.uncompressedSize);
NSLog(@"The first entry's data is: %@.", [firstArchiveEntry newDataWithError:nil]);

Writing a new zip file:

ZZArchive* newArchive = [[ZZArchive alloc] initWithURL:[NSURL fileURLWithPath:@"/tmp/new.zip"]
                                               options:@{ZZOpenOptionsCreateIfMissingKey : @YES}
                                                 error:nil];
[newArchive updateEntries:
					 @[
					 [ZZArchiveEntry archiveEntryWithFileName:@"first.text"
													 compress:YES
													dataBlock:^(NSError** error)
														  {
															  return [@"hello, world" dataUsingEncoding:NSUTF8StringEncoding];
														  }]
					 ]
				    error:nil];

Updating an existing zip file:

ZZArchive* oldArchive = [ZZArchive archiveWithURL:[NSURL fileURLWithPath:@"/tmp/old.zip"]
                                            error:nil];
[oldArchive updateEntries:
 [oldArchive.entries arrayByAddingObject:
  [ZZArchiveEntry archiveEntryWithFileName:@"second.text"
								  compress:YES
								 dataBlock:^(NSError** error)
									   {
										   return [@"bye, world" dataUsingEncoding:NSUTF8StringEncoding];
									   }]]
					error:nil];

Advanced uses: Recipes

API references: References

Require

  • Build: Xcode 7 and later.
  • Link: Only system libraries; no third-party libraries needed.
    • ApplicationServices.framework (Mac OS X) or ImageIO.framework (iOS)
    • Foundation.framework
    • libz.dylib
  • Run: Mac OS X 10.9 (Mavericks) or iOS 7.0 and later.

Support

License

ZipZap is licensed with the BSD license.

Donate

zipzap's People

Contributors

pixelglow avatar danielgindi avatar mikeabdullah avatar dwarven avatar yaakov-h avatar laiso avatar barrettj avatar boyvanamstel avatar fritzgerald avatar goetzf avatar billinghamj avatar l4u avatar rileytestut avatar mz2 avatar ricobeck avatar

Watchers

James Cloos avatar Harimoto avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.