CocoaMediumZipArchive read/writeFrameworkIs the content to be introduced in this article.ZipRead/writeFramework:Zip-Framework. ThisFrameworkSupports reading and writing directly in the programZipFiles in the archive, instead of using NSTask to execute the unzip command line.
CocoaRead/write is not providedZipGZIP:/usr/include/zlib. h, but it has limitations.Zip frameworkThis function is well implemented. ThisFrameworkUse Objective-C for writing, so it can be conveniently called in the program. In theory, it can also be used for the iPhone. If anyone is interested, try it ).
Usage:
- #import <stdio .h>
- #import <zip /ZipArchive.h>
-
- ZipArchive *zip = [[ZipArchive alloc] initWithFile:@"…"];
- if (!zip) {
- NSLog(@"File could not be opened");
- }
-
- FILE *fp = [zip entryNamed:@"README.txt"]; // open stream to file README.txt in archive
- if (!fp) {
- NSLog(@"Not a file or not available in the archive");
- }
-
- NSArray *allEntries = [zip entries];
- // for example: [@"README", @"COPYING", @"src/", @"src/main.c"]
-
- [zip release];
-
- // Autoreleased version
- ZipArchive *autoreleasedZip = [ZipArchive archiveWithFile:@"…"];
- </zip></stdio>
In this way, you can obtainZipThe file pointer in the package, which can be read directly. (Currently, only fread operations are supported)
Summary:CocoaMediumZipArchive read/writeFrameworkI hope this article will help you!
Located in: http://code.google.com/p/zip-framework/