ZipArchiveライブラリの使い方
●ダウンロード:
http://code.google.com/p/ziparchive/
●必要ライブラリ
libz.1.2.3.dylib
●圧縮
#import "ZipArchive/ZipArchive.h"
BOOL ret = [zip CreateZipFile2:@"/path/to/taarget.zip"];
// または
BOOL ret = [zip CreateZipFile2:@"/path/to/taarget.zip" Password:@"your password"];
// パスワードが空なら、上のコードと同じ動き
ret = [zip addFileToZip:@"/path/to/taarget.zip" newname:@"photo.jpg"];
if(![zip CloseZipFile2]) {
// エラー処理
}
[zip release];
●解凍
ZipArchive* za = [[ZipArchive alloc] init];
if([za UnzipOpenFile:@"/path/to/taarget.zip"])
// または
if([za UnzipOpenFile:@"/path/to/taarget.zip"] Password:@"password of the zip fil
e"])
// パスワードが空なら、上のコードと同じ動き
{
BOOL ret = [za UnzipFileTo:@"/path/to/dir" overWrite:YES];
if(NO == ret) {
// エラー処理
}
[za UnzipCloseFile];
}
[za release];