a5de5b6bef
Before, the library resolved symbolic links that are relative into absolute paths, using the current working directory of the process that's doing the unzipping, which to me seems pretty wrong. This was due to using -[NSURL fileURLWithPath:], which transforms relative URLs to absolute URLs automatically. I don't see much of a reason to use NSFileManager here, so I made that use symlink() directly. Alternatively, one could also use -[NSURL URLWithString:]. This keeps relative symlinks relative after unzipping. |
||
---|---|---|
Example | ||
SSZipArchive | ||
SSZipArchive.xcodeproj | ||
Tests | ||
.gitignore | ||
LICENSE | ||
Readme.markdown | ||
SSZipArchive.podspec |
SSZipArchive
SSZipArchive is a simple utility class for zipping and unzipping files. Features:
- Unzipping zip files
- Unzipping password protected zip files
- Creating zip files
- Appending to zip files
- Zipping files
- Zipping NSData with a filename
Adding to your project
- Add the
SSZipArchive
andminizip
folders to your project. - Add the
libz
library to your target
SSZipArchive requires ARC.
Usage
// Unzipping
NSString *zipPath = @"path_to_your_zip_file";
NSString *destinationPath = @"path_to_the_folder_where_you_want_it_unzipped";
[SSZipArchive unzipFileAtPath:zipPath toDestination:destinationPath];
// Zipping
NSString *zippedPath = @"path_where_you_want_the_file_created";
NSArray *inputPaths = [NSArray arrayWithObjects:
[[NSBundle mainBundle] pathForResource:@"photo1" ofType:@"jpg"],
[[NSBundle mainBundle] pathForResource:@"photo2" ofType:@"jpg"]
nil];
[SSZipArchive createZipFileAtPath:zippedPath withFilesAtPaths:inputPaths];
Tests
Simply, open the Xcode 5 or higher project in the Tests directory and press Command-U to run the tests.
License
SSZipArchive is licensed under the MIT license. A slightly modified version of Minizip 1.1 is also included and is licensed under the Zlib license.
Thanks
Thanks aish for creating ZipArchive which SSZipArchive is based on, Johnnie Walker (@randomsequence) for implementing creation support, and John Engelhart (@johnezang) for all his amazing help along the way.