Objective-Zip icon indicating copy to clipboard operation
Objective-Zip copied to clipboard

readCurrentFileInZipWithPassword now taking password

Open SunnyShah407 opened this issue 8 years ago • 1 comments

Hi I am trying to unzip password protected file. But it gives me expections here is my sample code

OZZipFile *unzipFile= [[OZZipFile alloc] initWithFileName:filePath mode:OZZipFileModeUnzip];

[unzipFile goToFirstFileInZip];
BOOL keepReading = YES;

@try {
    while(keepReading){
        OZFileInZipInfo *fInfo = [unzipFile getCurrentFileInZipInfo];
        OZZipReadStream *readStream = [unzipFile readCurrentFileInZipWithPassword:@"password"];
        NSMutableData *data = [[NSMutableData alloc] initWithLength:fInfo.length];

        [readStream readDataWithBuffer:data];
        [readStream finishedReading];

        NSString* unzippedFilename = [self validFilePathForFilename:fInfo.name atPath:path];
        [data writeToFile:unzippedFilename atomically:YES];
        keepReading = [unzipFile goToNextFileInZip];
    }
}
@catch (NSException *exception) {
    NSLog(@"unzip file %@ failed:%@", filePath, exception.reason);
}
@finally {
    [unzipFile close];
}

Can you please let me know whats problem

SunnyShah407 avatar Sep 08 '16 08:09 SunnyShah407

Were you able to solve this?

mobilekosmos avatar Jul 14 '17 10:07 mobilekosmos