LzmaSDKObjC icon indicating copy to clipboard operation
LzmaSDKObjC copied to clipboard

How to know a 7z file is password protected

Open nandhakumargdr opened this issue 2 years ago • 1 comments

Hi,

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

nandhakumargdr avatar Jan 23 '22 16:01 nandhakumargdr

// 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

brotherand2 avatar Mar 01 '23 08:03 brotherand2