OlehKulykov / LzmaSDKObjC

Lzma SDK for Swift and Objective-C ( iOS & MacOS ) based on extended functionality of the C++ LZMA SDK code.
MIT License
171 stars 45 forks source link

How to know a 7z file is password protected #49

Open nandhakumargdr opened 2 years ago

nandhakumargdr commented 2 years ago

Hi,

How can I get to know a 7zip file is password protected. Right now the library is throwing a generic error

brotherand2 commented 1 year ago

// Select full path to archive file with 7z extension. NSString * archivePath = ;

// 1.1 Create and hold strongly reader object. self.reader = [[LzmaSDKObjCReader alloc] initWithFileURL:[NSURL fileURLWithPath:archivePath]]; // 1.2 Or create with predefined archive type if path doesn't containes suitable extension self.reader = [[LzmaSDKObjCReader alloc] initWithFileURL:[NSURL fileURLWithPath:archivePath] andType:LzmaSDKObjCFileType7z];

// Optionaly: assign weak delegate for tracking extract progress. _reader.delegate = self;

// If achive encrypted - define password getter handler. // NOTES: // - Encrypted file needs password for extract process. // - Encrypted file with encrypted header needs password for list(iterate) and extract archive items. _reader.passwordGetter = ^NSString*(void){ return @"password to my achive"; };

when block passwordGetter iscall ,you know 7zip file is password protected