Objective-Zip에 문제가 있습니다. 내 우편 번호를 확인할 때 예외가 발생합니다. 파일을 확인했는데 압축을 풀 때 아무런 문제가 없었습니다. 더 많은 것은 인 무엇 나는 시스템 디폴트 archiver와 다른을 가진 나의 파일을 지퍼로 잠근 시도한다.Objective-Zip을 열 수 없습니다.
나는 ZipFile *unzipFile= [[ZipFile alloc] initWithFileName:@"textPack.zip" mode:ZipFileModeUnzip];
검증 방법
- (id) initWithFileName:(NSString *)fileName mode:(ZipFileMode)mode {
if (self= [super init]) {
_fileName= [fileName retain];
_mode= mode;
switch (mode) {
case ZipFileModeUnzip:
_unzFile= unzOpen([_fileName cStringUsingEncoding:NSUTF8StringEncoding]);
if (_unzFile == NULL) {
NSString *reason= [NSString stringWithFormat:@"Can't open '%@'", _fileName];
@throw [[[ZipException alloc] initWithReason:reason] autorelease];
}
break;
case ZipFileModeCreate:
_zipFile= zipOpen([_fileName cStringUsingEncoding:NSUTF8StringEncoding], APPEND_STATUS_CREATE);
if (_zipFile == NULL) {
NSString *reason= [NSString stringWithFormat:@"Can't open '%@'", _fileName];
@throw [[[ZipException alloc] initWithReason:reason] autorelease];
}
break;
case ZipFileModeAppend:
_zipFile= zipOpen([_fileName cStringUsingEncoding:NSUTF8StringEncoding], APPEND_STATUS_ADDINZIP);
if (_zipFile == NULL) {
NSString *reason= [NSString stringWithFormat:@"Can't open '%@'", _fileName];
@throw [[[ZipException alloc] initWithReason:reason] autorelease];
}
break;
default: {
NSString *reason= [NSString stringWithFormat:@"Unknown mode %d", _mode];
@throw [[[ZipException alloc] initWithReason:reason] autorelease];
}
}
}
return self;
}
어떤 조언을 사용할 수 있습니까?
왜 unzopen에 대한 NSASCIIStringEncoding하지만 다른 곳에 UTF8을 사용합니까? (이것은 귀하의 문제와 관련이 없으며 단지 일반적인 의견입니다). –
오오 .. 단지 오타 일 뿐이며 테스트 용으로 만 사용되지만 도움이되지 않습니다. – BW4
Google에서 unzOpen을 검색하면 같은 문제가있는 다른 게시물을 찾을 수 있습니다. 하나의 텍스트 파일을 압축해서 시도해보십시오. 그렇지 않다면 아카이브에서 zip 파일 (여러 파일도 포함)을 추출하는 데 사용하기 쉬운 (이전 버전의) 프레임 워크가 있습니다. ZipArchive –