Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readCurrentFileInZipWithPassword now taking password #49

Open
SunnyShah407 opened this issue Sep 8, 2016 · 1 comment
Open

readCurrentFileInZipWithPassword now taking password #49

SunnyShah407 opened this issue Sep 8, 2016 · 1 comment

Comments

@SunnyShah407
Copy link

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

@mobilekosmos
Copy link

Were you able to solve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants