Git Product home page Git Product logo

zippyzap's Introduction

ZippyZap Logo

CI Version GitHub License Platform PayPal Twitch

ZippyZap is a ZIP compression file I/O library for macOS, iOS/iPadOS, and tvOS.

It probably goes without saying that ZIP is the most popular compression format in the world. Supported natively by many operating systems, ZIP is completely open, easy to create and consume, and serves as the basis for many other file formats.

ZippyZap is a fork of ZipZap, originally by Glen Low. ZipZap had the goal of being the most comprehensive open source ZIP library for Apple's platforms, adhering to the ZIP standard as closely as possible, and also having a very extensive test suite.

Glen's current working circumstances have made it such that he has unable been able to continue working on ZipZap for the last few years. Since I believe that this is by far the best ZIP library available on the platform, I've forked ZipZap into ZippyZap with the goal of continuing to use and refine it for my own upcoming projects.

Features

  • Easy-to-use interface: The public API offers just two classes! You can browse through zip files using familiar NSArray collections and properties. And you can zip, unzip and re-zip ZIP files through familiar NSData, NSStream and ImageIO classes.
  • Efficient implementation: ZIP file reading and writing has been optimised to reduce virtual memory pressure and disk file thrashing. Depending on how your archive is organised, updating a single entry can be faster than writing the same data to a separate file.
  • File format compatibility: Since ZippyZap closely follows the zip file format specification, it works with most Mac, Linux and Windows ZIP tools.

System Requirements

  • Build: Xcode 7 and later.
  • Linking:
    • ApplicationServices.framework (macOS only)
    • ImageIO.framework (iOS only)
    • Foundation.framework
    • libz.dylib
  • System: macOS 10.10 (Yosemite) or iOS 7.0 and later.

Install

CocoaPods

Include the following line in your

pod 'ZippyZap' 

Compile your own copy:

  1. Download the ZippyZap repo to your hard drive and decompress it.
  2. Within the ZippyZap directory, open the ZippyZap.xcodeproj project in Xcode.
  3. In the Xcode project, select either the ZippyZap (iOS Framework), ZippyZap (iOS Static Library), ZippyZap (macOS Framework) or ZippyZap (macOS Static Library) scheme from the drop down.
  4. From the selected scheme, you can build a copy of the framework that you can them embed in your own project.
  5. The built libraries and test cases are located in a subdirectory of ~/Library/Developer/Xcode/DerivedData.

Integrate as a project in your Xcode workspace:

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

Usage

Header includes:

#import <ZippyZap/ZippyZap.h>

Read an existing ZIP file:

NSURL *archiveURL = [NSURL fileURLWithPath:@"/tmp/archive.zip"];

// Open the ZIP archive
ZZArchive* archive = [ZZArchive archiveWithURL:archiveURL error:nil];
	
// Load the first entry from within the archive
ZZArchiveEntry* firstArchiveEntry = archive.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]);

Write a new ZIP file:

// Create a new archive object instance, setting a key to create if missing
ZZArchive* newArchive = [[ZZArchive alloc] initWithURL:newURL 
						options:@{ZZOpenOptionsCreateIfMissingKey : @YES} 
						error:nil];

// Create a new entry and populate it with data
id dataBlock = ^(NSError** error) {
			return [@"hello, world" dataUsingEncoding:NSUTF8StringEncoding];
		};
ZZArchiveEntry *newEntry = [ZZArchiveEntry archiveEntryWithFileName:@"first.text" 
							compress:YES 
							dataBlock:dataBlock];

// Add the entry to the archive
[newArchive updateEntries:@[newEntry] error:nil];

Update an existing ZIP file:

// Create a new instance of an archive
NSURL *zipURL = [NSURL fileURLWithPath:@"/tmp/old.zip"];
ZZArchive *archive = [ZZArchive archiveWithURL:zipURL error:nil];

// Create a new entry, and populate it with data
id dataBlock = ^(NSError** error) {
			return [@"bye, world" dataUsingEncoding:NSUTF8StringEncoding];
		};
ZZArchiveEntry *entry = [ZZArchiveEntry archiveEntryWithFileName:@"second.text"
							compress:YES
							dataBlock:dataBlock];

// Append it to the existing entries of the archive
[archive updateEntries:[archive.entries arrayByAddingObject:entry] error:nil];

License

ZippyZap is licensed under the BSD license. Please see the LICENSE file.

zippyzap's People

Contributors

barrettj avatar billinghamj avatar boyvanamstel avatar danielgindi avatar dwarven avatar fritzgerald avatar goetzf avatar l4u avatar laiso avatar mikeabdullah avatar mz2 avatar pixelglow avatar ricobeck avatar rileytestut avatar timoliver avatar yaakov-h 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.