我正在使用Objective Zip庫來解壓iPhone中的文件。目標 - 郵編僅適用於文本文件?
所有工作正常,除了文本文件沒有問題沒有問題沒有壓縮,文件是正確的。但與壓縮PNG文件都損壞。文件的大小都與原始文件相同,但全部損壞。
這是代碼:
-(void)installPackageFromZipFile:(NSString *)zipFile
{
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
ZipFile *unzipFile= [[ZipFile alloc] initWithFileName:zipFile mode:ZipFileModeUnzip];
packageRegisterController *pckReg = [[packageRegisterController alloc] init];
[unzipFile goToFirstFileInZip];
NSArray *infos= [unzipFile listFileInZipInfos];
for (FileInZipInfo *info in infos)
{
NSLog([NSString stringWithFormat:@"File Found in Zip File- %@ Size:%d", info.name, info.length]);
ZipReadStream *read = [unzipFile readCurrentFileInZip];
if (![pckReg detectIfFileExists:[documentsDir stringByAppendingPathComponent:info.name]])
{
NSMutableData *data = [[NSMutableData alloc] initWithLength:info.length];
int bytesRead = [read readDataWithBuffer:data];
[data writeToFile:[documentsDir stringByAppendingPathComponent:info.name] atomically:NO];
[read finishedReading];
[data release];
if ([[NSString stringWithFormat:@"%@",info.name] isEqualToString:@"TEMAMANIFEST.xml"])
{
if([self parseManifest:[documentsDir stringByAppendingPathComponent:info.name]])
if ([pckReg validateManifestId:self.temaToInstall.idManifest])
[self installManifest];
}
}
[unzipFile goToNextFileInZip];
}
[unzipFile close];
[unzipFile release];
}
此功能解壓縮具有良好的尺寸和文本文件中的所有文件都OK,但不是PNG文件。
有人可以幫助我嗎?
您是否嘗試解壓縮另一個盒子上的zip文件,並確保其壓縮正確? –
剔除我在這個問題中的答案: - http://stackoverflow.com/questions/2161327/creating-zip-files-in-objectivec-for-iphone – nlg