Reputation: 2040
I am trying to unzip a folder using ssziparchive lib I found at: https://github.com/soffes/ssziparchive. The code I used:
NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *zipFilePath = [documentsDirectory stringByAppendingPathComponent:@"ZippSecretExcel.zip"];
NSString *unzipFilePath = [documentsDirectory stringByAppendingPathComponent:@"UnZipSecretExcel"];
BOOL
status = [SSZipArchive unzipFileAtPath:zipFilePath toDestination:unzipFilePath];
if(status)
{
NSLog(@"File successfully uncompressed");
}
else{
NSLog(@"File failed to compressed");
}
I checked ZippSecretExcel exists in projects document directory, but the above code fail to unzip it.The program compiles and there is no error or crash. My zip folder contains three folders which themselves contain files and folders. Do I have to perform any additional step to unzip the file?
Upvotes: 2
Views: 1027
Reputation: 66
Will this code 'status = [SSZipArchive unzipFileAtPath:zipFilePath toDestination:unzipFilePath];' create a directory first for the destination path ?..
If not , use the below code to create folder before unzip
BOOL isDire = YES;
NSFileManager *fileManager = [NSFileManager defaultManager];
if(![fileManager fileExistsAtPath:unzipFilePath isDirectory:&isDire]){
[fileManager createDirectoryAtPath:unzipFilePath withIntermediateDirectories:YES attributes:nil error:NULL];
}
Upvotes: 0