ファイルを抽出するためにobjectivezipというライブラリを使用しています。
関連するコード:
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
ZipFile *unzipFile= [[ZipFile alloc] initWithFileName:requestFinishedPresentationPath mode:ZipFileModeUnzip];
NSArray *infos= [unzipFile listFileInZipInfos];
for (FileInZipInfo *info in infos) {
NSLog(@"- %@ %@ %d (%d)", info.name, info.date, info.size, info.level);
[unzipFile locateFileInZip:info.name];
// Expand the file in memory
ZipReadStream *read= [unzipFile readCurrentFileInZip];
NSMutableData *data = [[NSMutableData alloc] initWithLength:256];
int bytesRead = [read readDataWithBuffer:data];
[data writeToFile:[documentsDir stringByAppendingPathComponent:info.name] atomically:NO];
NSLog([documentsDir stringByAppendingPathComponent:info.name]);
[read finishedReading];
}
[unzipFile close];
最初のnslogは次を出力します。
- _some-path_/modules/reference-popup/ref-popup.js 2012-08-21 08:49:36 +0000 109 (-1)
2番目のnslogは、次を出力します。
/Users/_USER_/Library/Application Support/iPhone Simulator/5.1/Applications/F2649DB7-7806-4C49-8DF9-BD939B2A9D5A/Documents/_some-path_/modules/slide-popup/slide-popup.css
基本的に、読み取りオブジェクトとデータオブジェクトは相互に通信していないと思います...ブラウザで適切なディレクトリに移動すると、ディレクトリであるはずの2つのファイルが表示されます(これらは最も上位にあります-レベルのディレクトリ)が、ブラウザはそれらが1kbのファイルとして書き出されたと言っています。コード内のバッファに従って、ファイルとその256バイトのファイルを表示してみます。
代わりに何をすべきですか?
zipを展開するには(すべてのファイルを適切にディレクトリに入れます)?