Zip Archive read/write framework in Cocoa

Source: Internet
Author: User

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:

 
 
  1. #import <stdio .h> 
  2. #import <zip /ZipArchive.h> 
  3.    
  4. ZipArchive *zip = [[ZipArchive alloc] initWithFile:@"…"];  
  5. if (!zip) {  
  6.     NSLog(@"File could not be opened");  
  7. }  
  8.    
  9. FILE *fp = [zip entryNamed:@"README.txt"]; // open stream to file README.txt in archive  
  10. if (!fp) {  
  11.     NSLog(@"Not a file or not available in the archive");  
  12. }  
  13.    
  14. NSArray *allEntries = [zip entries];  
  15. // for example: [@"README", @"COPYING", @"src/", @"src/main.c"]  
  16.    
  17. [zip release];  
  18.    
  19. // Autoreleased version  
  20. ZipArchive *autoreleasedZip = [ZipArchive archiveWithFile:@"…"];  
  21. </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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.