Skip to content

Commit e5962af

Browse files
authored
Merge pull request ZipArchive#398 from ZipArchive/nestedZip
support nested zip by calling fclose first
2 parents 236f31d + 1fd7fa9 commit e5962af

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

SSZipArchive/SSZipArchive.m

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -434,24 +434,23 @@ + (BOOL)unzipFileAtPath:(NSString *)path
434434
}
435435

436436
if (fp) {
437-
if (nestedZipLevel && [fullPath.pathExtension.lowercaseString isEqualToString:@"zip"]) {
438-
if ([self unzipFileAtPath:fullPath
439-
toDestination:fullPath.stringByDeletingLastPathComponent
440-
preserveAttributes:preserveAttributes
441-
overwrite:overwrite
442-
nestedZipLevel:nestedZipLevel - 1
443-
password:password
444-
error:nil
445-
delegate:nil
446-
progressHandler:nil
447-
completionHandler:nil]) {
448-
[[NSFileManager defaultManager] removeItemAtPath:fullPath error:nil];
449-
}
450-
}
451-
452437
fclose(fp);
453438

454-
if (preserveAttributes) {
439+
if (nestedZipLevel
440+
&& [fullPath.pathExtension.lowercaseString isEqualToString:@"zip"]
441+
&& [self unzipFileAtPath:fullPath
442+
toDestination:fullPath.stringByDeletingLastPathComponent
443+
preserveAttributes:preserveAttributes
444+
overwrite:overwrite
445+
nestedZipLevel:nestedZipLevel - 1
446+
password:password
447+
error:nil
448+
delegate:nil
449+
progressHandler:nil
450+
completionHandler:nil]) {
451+
[directoriesModificationDates removeLastObject];
452+
[[NSFileManager defaultManager] removeItemAtPath:fullPath error:nil];
453+
} else if (preserveAttributes) {
455454

456455
// Set the original datetime property
457456
if (fileInfo.dos_date != 0) {

0 commit comments

Comments
 (0)