Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete PR #78 #82

Merged
merged 7 commits into from
May 10, 2019
Prev Previous commit
Next Next commit
Consolidated directory creation code, which is necessary whether the …
…file being extracted is a directory or not (Issue #74)
  • Loading branch information
abbeycode committed Apr 29, 2019
commit 89c53d73e8fd0c0a7a0ea19860d3ac6b18af2830
13 changes: 4 additions & 9 deletions Source/UZKArchive.m
Original file line number Diff line number Diff line change
Expand Up @@ -550,14 +550,9 @@ - (BOOL)extractFilesTo:(NSString *)destinationDirectory
return;
}

if (info.isDirectory) {
[fm createDirectoryAtPath:extractPath withIntermediateDirectories:YES
attributes:nil error:error];
continue;
}

BOOL isDirectory = YES;
NSString *extractDir = extractPath.stringByDeletingLastPathComponent;
NSString *extractDir = (info.isDirectory
? extractPath
: extractPath.stringByDeletingLastPathComponent);
if (![fm fileExistsAtPath:extractDir]) {
UZKLogDebug("Creating directories for path %{public}@", extractDir);
BOOL directoriesCreated = [fm createDirectoryAtPath:extractDir
Expand All @@ -572,7 +567,7 @@ - (BOOL)extractFilesTo:(NSString *)destinationDirectory
detail:detail];
return;
}
} else if (!isDirectory) {
} else if (!info.isDirectory) {
NSString *detail = [NSString localizedStringWithFormat:NSLocalizedStringFromTableInBundle(@"Extract path exists, but is not a directory: %@", @"UnzipKit", _resources, @"Detailed error string"),
extractDir];
UZKLogError("UZKErrorCodeOutputErrorPathIsAFile: %{public}@", detail);
Expand Down