1

I am using SSZipArchive for iOS. Is there a possibility to get the filename of every file unzipped with:

[SSZipArchive unzipFileAtPath:zipFile toDestination:docDir delegate:self];

I tried to get it with

- (void)zipArchiveDidUnzipArchiveFile:(NSString *)zipFile entryPath:(NSString *)entryPath destPath:(NSString *)destPath

and

- (void)zipArchiveDidUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath unzippedFilePath:(NSString *)unzippedFilePath

but sadly both functions are not called.

Cœur
  • 37,241
  • 25
  • 195
  • 267
TomWayne
  • 230
  • 2
  • 11
  • A quick look at the source code of SSZipArchive source and it seems that "zipArchiveDidUnzipArchiveFile" is never actually called in their code even though it's declared in the header – chedabob May 13 '15 at 19:03

1 Answers1

1

Not tested, but something like that should work:

NSString *destination = [NSTemporaryDirectory() stringByAppendingString:@"DirectoryDestination"];
[SSZipArchive unzipFileAtPath:yourZipPath toDestination:destination];
NSArray *directoryContent = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:destination error:nil];
for (NSURL *url in directoryContent) {
    NSLog(@"Filename: %@", [url lastPathComponent]);
}

Explanations:

  1. Unzip your zip file in a destination directory
  2. Get all the files contains in the destination directory (there your SSZipArchive put your files from the zip)
  3. Just log the filenames and do whatever with them
tbaranes
  • 3,560
  • 1
  • 23
  • 31
  • I had a similar idea but I would prefer if SSZipArchive could get me the names :/ – TomWayne May 13 '15 at 20:05
  • Sadly, it doesn't procure any features like this. You have to do it manually... Maybe it will be add in a future release – tbaranes May 13 '15 at 20:06