diff --git a/SUHost.m b/SUHost.m index c3412081..4cdaacc5 100644 --- a/SUHost.m +++ b/SUHost.m @@ -123,20 +123,15 @@ // Use a default icon if none is defined. if (!icon) { BOOL isMainBundle = (bundle == [NSBundle mainBundle]); - - // Starting with 10.6, iconForFileType: accepts a UTI. - NSString *fileType = nil; - if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_5) - fileType = isMainBundle ? NSFileTypeForHFSTypeCode(kGenericApplicationIcon) : @".bundle"; - else - fileType = isMainBundle ? (NSString*)kUTTypeApplication : (NSString*)kUTTypeBundle; + + NSString *fileType = isMainBundle ? (NSString*)kUTTypeApplication : (NSString*)kUTTypeBundle; icon = [[NSWorkspace sharedWorkspace] iconForFileType:fileType]; } return icon; } - (BOOL)isRunningOnReadOnlyVolume -{ +{ struct statfs statfs_info; statfs([[bundle bundlePath] fileSystemRepresentation], &statfs_info); return (statfs_info.f_flags & MNT_RDONLY); diff --git a/SUPlainInstallerInternals.m b/SUPlainInstallerInternals.m index ef8693e2..6c4e16eb 100644 --- a/SUPlainInstallerInternals.m +++ b/SUPlainInstallerInternals.m @@ -472,62 +472,36 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza } err = FSPathMakeRef((UInt8 *)[[dst stringByDeletingLastPathComponent] fileSystemRepresentation], &dstDirRef, NULL); - + if (err == noErr && hadFileAtDest) - { - if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5) - { - NSFileManager *manager = [[[NSFileManager alloc] init] autorelease]; - BOOL success = [manager moveItemAtPath:dst toPath:tmpPath error:error]; - if (!success && hadFileAtDest) - { - if (error != NULL) - *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath] forKey:NSLocalizedDescriptionKey]]; - return NO; - } - - } else { - err = FSMoveObjectSync(&dstRef, &tmpDirRef, (CFStringRef)[tmpPath lastPathComponent], &movedRef, 0); - if (err != noErr && hadFileAtDest) - { - if (error != NULL) - *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath] forKey:NSLocalizedDescriptionKey]]; - return NO; - } - } + { + NSFileManager *manager = [[[NSFileManager alloc] init] autorelease]; + BOOL success = [manager moveItemAtPath:dst toPath:tmpPath error:error]; + if (!success && hadFileAtDest) + { + if (error != NULL) + *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath] forKey:NSLocalizedDescriptionKey]]; + return NO; + } } - + err = FSPathMakeRef((UInt8 *)[src fileSystemRepresentation], &srcRef, NULL); if (err == noErr) { - if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5) + NSFileManager *manager = [[[NSFileManager alloc] init] autorelease]; + BOOL success = [manager copyItemAtPath:src toPath:dst error:error]; + if (!success) { - NSFileManager *manager = [[[NSFileManager alloc] init] autorelease]; - BOOL success = [manager copyItemAtPath:src toPath:dst error:error]; - if (!success) - { - // We better move the old version back to its old location - if( hadFileAtDest ) - success = [manager moveItemAtPath:tmpPath toPath:dst error:error]; - if (!success && error != NULL) - *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath] forKey:NSLocalizedDescriptionKey]]; - return NO; + // We better move the old version back to its old location + if( hadFileAtDest ) + success = [manager moveItemAtPath:tmpPath toPath:dst error:error]; + if (!success && error != NULL) + *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath] forKey:NSLocalizedDescriptionKey]]; + return NO; - } - } else { - err = FSCopyObjectSync(&srcRef, &dstDirRef, (CFStringRef)[dst lastPathComponent], NULL, 0); - if (err != noErr) - { - // We better move the old version back to its old location - if( hadFileAtDest ) - FSMoveObjectSync(&movedRef, &dstDirRef, (CFStringRef)[dst lastPathComponent], &movedRef, 0); - if (error != NULL) - *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Couldn't copy %@ to %@.", src, dst] forKey:NSLocalizedDescriptionKey]]; - return NO; - } } } - + // If the currently-running application is trusted, the new // version should be trusted as well. Remove it from the // quarantine to avoid a delay at launch, and to avoid