Skip to content

Commit

Permalink
Fixes sparkle-project#109: Error extracting dmg archives
Browse files Browse the repository at this point in the history
  • Loading branch information
andymatuschak committed Oct 28, 2011
1 parent 613b759 commit 5457476
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions SUDiskImageUnarchiver.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,28 @@ - (void)extractDMG
// Now that we've mounted it, we need to copy out its contents.
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5) {
// On 10.6 and later we don't want to use the File Manager API and instead want to use NSFileManager (fixes #827357).
NSFileManager *manager = [[NSFileManager alloc] init];
if (![manager copyItemAtPath:mountPoint toPath:[archivePath stringByDeletingLastPathComponent] error:NULL]) {
goto reportError;
}
NSFileManager *manager = [[[NSFileManager alloc] init] autorelease];
NSError *error = nil;
NSArray *contents = [manager contentsOfDirectoryAtPath:mountPoint error:&error];
if (error)
{
SULog(@"Couldn't enumerate contents of archive mounted at %@: %@", mountPoint, error);
goto reportError;
}

for (NSString *fileItem in contents)
{
NSString *fromPath = [mountPoint stringByAppendingPathComponent:fileItem];
NSString *toPath = [[archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:fileItem];

SULog(@"copyItemAtPath:%@ toPath:%@", fromPath, toPath);

if (![manager copyItemAtPath:fromPath toPath:toPath error:&error])
{
SULog(@"Couldn't copy item: %@", error);
goto reportError;
}
}
}
else {
FSRef srcRef, dstRef;
Expand Down

0 comments on commit 5457476

Please sign in to comment.