Sunday, April 1, 2012

Add files to an existing zip - objective c, ZipArchive

I'm using ZipArchive developed by aish to create zip files. ZipArchive is an Objective-C class to compress or uncompress zip files, which is based on open source code "MiniZip". It worked fine on many of the iPhone apps I developed.

However it does not support opening of an existing zip and adding more files to it. So I did this small tweak to the code to enable this. Just place the following code in the zipArchive.m and also their definitions to the zipArchive.h

-(BOOL) openZipFile2:(NSString*) zipFile
{
_zipFile = zipOpen( (const char*)[zipFile UTF8String], 1 );
if( !_zipFile )
return NO;
return YES;
}

No comments: