iPhone에서 파일의 압축을 풀기 위해 Objective Zip 라이브러리를 사용하고 있습니다.목표 - 우편 텍스트 파일에만 작동합니까?
모두 잘 작동합니다. 문제가없는 텍스트 파일은 문제없이 압축되며 파일이 올바른 것입니다. 그러나 압축 된 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];
}
이 기능은 압축 해제하지만, PNG로하지 :
이
는 코드입니다.누군가 나를 도울 수 있습니까?
다른 상자에서 압축 파일을 압축 해제하고 올바르게 압축했는지 확인 했습니까? –
이 질문에 내 대답을 che다 : - http://stackoverflow.com/questions/2161327/creating-zip-files-in-objectivec-for-iphone – nlg