From c5d692199a20c9ff15f9a3f2aa53cceeb9224df6 Mon Sep 17 00:00:00 2001 From: Antonin Hildebrand Date: Sun, 14 Jun 2015 16:03:43 +0200 Subject: [PATCH] get rid of MAC_OS_X_VERSION_MIN_REQUIRED --- SUAppcast.m | 8 -------- SUBasicUpdateDriver.m | 20 -------------------- SUBinaryDeltaCommon.m | 8 -------- SUHost.m | 7 ------- SUPipedUnarchiver.m | 4 ---- SUPlainInstallerInternals.m | 8 -------- SUUIBasedUpdateDriver.m | 4 ---- finish_installation.m | 4 ---- 8 files changed, 63 deletions(-) diff --git a/SUAppcast.m b/SUAppcast.m index 04af5a19..ed5cb536 100644 --- a/SUAppcast.m +++ b/SUAppcast.m @@ -104,11 +104,7 @@ } document = [[[NSXMLDocument alloc] initWithContentsOfURL:[NSURL fileURLWithPath:downloadFilename] options:options error:&error] autorelease]; -#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 - [[NSFileManager defaultManager] removeFileAtPath:downloadFilename handler:nil]; -#else [[NSFileManager defaultManager] removeItemAtPath:downloadFilename error:nil]; -#endif [downloadFilename release]; downloadFilename = nil; } @@ -234,11 +230,7 @@ { if (downloadFilename) { -#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 - [[NSFileManager defaultManager] removeFileAtPath:downloadFilename handler:nil]; -#else [[NSFileManager defaultManager] removeItemAtPath:downloadFilename error:nil]; -#endif } [downloadFilename release]; downloadFilename = nil; diff --git a/SUBasicUpdateDriver.m b/SUBasicUpdateDriver.m index 69fa2c48..e4af2f2e 100644 --- a/SUBasicUpdateDriver.m +++ b/SUBasicUpdateDriver.m @@ -180,19 +180,7 @@ } // Create the temporary directory if necessary. -#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 - BOOL success = YES; - NSEnumerator *pathComponentEnumerator = [[tempDir pathComponents] objectEnumerator]; - NSString *pathComponentAccumulator = @""; - NSString *currentPathComponent; - while ((currentPathComponent = [pathComponentEnumerator nextObject])) { - pathComponentAccumulator = [pathComponentAccumulator stringByAppendingPathComponent:currentPathComponent]; - if ([[NSFileManager defaultManager] fileExistsAtPath:pathComponentAccumulator]) continue; - success &= [[NSFileManager defaultManager] createDirectoryAtPath:pathComponentAccumulator attributes:nil]; - } -#else BOOL success = [[NSFileManager defaultManager] createDirectoryAtPath:tempDir withIntermediateDirectories:YES attributes:nil error:NULL]; -#endif if (!success) { // Okay, something's really broken with this user's file structure. @@ -320,11 +308,7 @@ NSString *targetPath = [[host appSupportPath] stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]]; // Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems. NSError *error = nil; -#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 - [[NSFileManager defaultManager] createDirectoryAtPath: [targetPath stringByDeletingLastPathComponent] attributes: [NSDictionary dictionary]]; -#else [[NSFileManager defaultManager] createDirectoryAtPath: [targetPath stringByDeletingLastPathComponent] withIntermediateDirectories: YES attributes: [NSDictionary dictionary] error: &error]; -#endif // Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems. if( [SUPlainInstaller copyPathWithAuthentication: relaunchPathToCopy overPath: targetPath temporaryName: nil error: &error] ) @@ -372,12 +356,8 @@ - (void)installerForHost:(SUHost *)aHost failedWithError:(NSError *)error { if (aHost != host) { return; } -#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 - [[NSFileManager defaultManager] removeFileAtPath: relaunchPath handler: nil]; // Clean up the copied relauncher -#else NSError * dontThrow = nil; [[NSFileManager defaultManager] removeItemAtPath: relaunchPath error: &dontThrow]; // Clean up the copied relauncher -#endif [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:SULocalizedString(@"An error occurred while installing the update. Please try again later.", nil), NSLocalizedDescriptionKey, [error localizedDescription], NSLocalizedFailureReasonErrorKey, nil]]]; } diff --git a/SUBinaryDeltaCommon.m b/SUBinaryDeltaCommon.m index 4315d95d..a8fbb7be 100644 --- a/SUBinaryDeltaCommon.m +++ b/SUBinaryDeltaCommon.m @@ -148,18 +148,10 @@ NSString *hashOfTree(NSString *path) void removeTree(NSString *path) { -#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 [[NSFileManager defaultManager] removeItemAtPath:path error:0]; -#else - [[NSFileManager defaultManager] removeFileAtPath:path handler:nil]; -#endif } void copyTree(NSString *source, NSString *dest) { -#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 [[NSFileManager defaultManager] copyItemAtPath:source toPath:dest error:0]; -#else - [[NSFileManager defaultManager] copyPath:source toPath:dest handler:nil]; -#endif } diff --git a/SUHost.m b/SUHost.m index e12af606..eba2fe21 100644 --- a/SUHost.m +++ b/SUHost.m @@ -249,7 +249,6 @@ // There may be a better way to deal with the problem that gestaltSystemVersionMajor // et al. are not defined in 10.3, but this is probably good enough. NSString* verStr = nil; -#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4 SInt32 major, minor, bugfix; OSErr err1 = Gestalt(gestaltSystemVersionMajor, &major); OSErr err2 = Gestalt(gestaltSystemVersionMinor, &minor); @@ -258,12 +257,6 @@ { verStr = [NSString stringWithFormat:@"%ld.%ld.%ld", (long)major, (long)minor, (long)bugfix]; } - else -#endif - { - NSString *versionPlistPath = @"/System/Library/CoreServices/SystemVersion.plist"; - verStr = [[NSDictionary dictionaryWithContentsOfFile:versionPlistPath] objectForKey:@"ProductVersion"]; - } return verStr; } diff --git a/SUPipedUnarchiver.m b/SUPipedUnarchiver.m index e70f0797..3c0a6c31 100644 --- a/SUPipedUnarchiver.m +++ b/SUPipedUnarchiver.m @@ -56,11 +56,7 @@ SULog(@"Extracting %@ using '%@'",archivePath,command); // Get the file size. -#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 - NSNumber *fs = [[[NSFileManager defaultManager] fileAttributesAtPath:archivePath traverseLink:NO] objectForKey:NSFileSize]; -#else NSNumber *fs = [[[NSFileManager defaultManager] attributesOfItemAtPath:archivePath error:nil] objectForKey:NSFileSize]; -#endif if (fs == nil) goto reportError; // Thank you, Allan Odgaard! diff --git a/SUPlainInstallerInternals.m b/SUPlainInstallerInternals.m index 15eb16b4..0a389683 100644 --- a/SUPlainInstallerInternals.m +++ b/SUPlainInstallerInternals.m @@ -392,11 +392,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza + (BOOL)_removeFileAtPath:(NSString *)path error: (NSError**)error { BOOL success = YES; -#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 - if( ![[NSFileManager defaultManager] removeFileAtPath: path handler: nil] ) -#else if( ![[NSFileManager defaultManager] removeItemAtPath: path error: NULL] ) -#endif { success = [self _removeFileAtPathWithForcedAuthentication: path error: error]; } @@ -585,11 +581,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza // Only recurse if it's actually a directory. Don't recurse into a // root-level symbolic link. -#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 - NSDictionary* rootAttributes = [[NSFileManager defaultManager] fileAttributesAtPath:root traverseLink:NO]; -#else NSDictionary* rootAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:root error:nil]; -#endif NSString* rootType = [rootAttributes objectForKey:NSFileType]; if (rootType == NSFileTypeDirectory) { diff --git a/SUUIBasedUpdateDriver.m b/SUUIBasedUpdateDriver.m index 2110635d..0bd2e0b3 100644 --- a/SUUIBasedUpdateDriver.m +++ b/SUUIBasedUpdateDriver.m @@ -141,11 +141,7 @@ if ([statusController maxProgressValue] == 0.0) { NSDictionary * attributes; -#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 - attributes = [[NSFileManager defaultManager] fileAttributesAtPath:downloadPath traverseLink:NO]; -#else attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:downloadPath error:nil]; -#endif [statusController setMaxProgressValue:[[attributes objectForKey:NSFileSize] doubleValue]]; } [statusController setProgressValue:[statusController progressValue] + (double)length]; diff --git a/finish_installation.m b/finish_installation.m index 740de4b4..04e43dd5 100644 --- a/finish_installation.m +++ b/finish_installation.m @@ -128,11 +128,7 @@ if( ![SUPlainInstaller _removeFileAtPath: [SUInstaller updateFolder] error: &theError] ) SULog( @"Couldn't remove update folder: %@.", theError ); } -#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 - [[NSFileManager defaultManager] removeFileAtPath: selfPath handler: nil]; -#else [[NSFileManager defaultManager] removeItemAtPath: selfPath error: NULL]; -#endif exit(EXIT_SUCCESS); }