From 32d4de464d47316c29f79a067c8244ac868e5540 Mon Sep 17 00:00:00 2001 From: "C.W. Betts" Date: Sat, 19 Jul 2014 15:05:08 -0600 Subject: [PATCH] Don't use new code if specifically targeting OS versions that have the new API. --- Sparkle/SUPlainInstallerInternals.m | 41 ++++++++++++++++------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/Sparkle/SUPlainInstallerInternals.m b/Sparkle/SUPlainInstallerInternals.m index 12f8e1b1..9974cf43 100644 --- a/Sparkle/SUPlainInstallerInternals.m +++ b/Sparkle/SUPlainInstallerInternals.m @@ -569,25 +569,8 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza // *** MUST BE SAFE TO CALL ON NON-MAIN THREAD! NSFileManager *manager = [NSFileManager defaultManager]; - if (&NSURLQuarantinePropertiesKey) { - NSURL *rootURL = [NSURL fileURLWithPath:root]; - [rootURL setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:NULL]; - - // Only recurse if it's actually a directory. Don't recurse into a - // root-level symbolic link. - NSDictionary *rootAttributes = [manager attributesOfItemAtPath:root error:nil]; - NSString *rootType = rootAttributes[NSFileType]; - - if (rootType == NSFileTypeDirectory) { - // The NSDirectoryEnumerator will avoid recursing into any contained - // symbolic links, so no further type checks are needed. - NSDirectoryEnumerator *directoryEnumerator = [manager enumeratorAtURL:rootURL includingPropertiesForKeys:nil options:(NSDirectoryEnumerationOptions)0 errorHandler:nil]; - - for (NSURL *file in directoryEnumerator) { - [file setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:NULL]; - } - } - } else { +#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101000 + if (!&NSURLQuarantinePropertiesKey) { NSString *const quarantineAttribute = (NSString*)kLSItemQuarantineProperties; const int removeXAttrOptions = XATTR_NOFOLLOW; @@ -611,7 +594,27 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza options:removeXAttrOptions]; } } + return; } +#endif + NSURL *rootURL = [NSURL fileURLWithPath:root]; + [rootURL setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:NULL]; + + // Only recurse if it's actually a directory. Don't recurse into a + // root-level symbolic link. + NSDictionary *rootAttributes = [manager attributesOfItemAtPath:root error:nil]; + NSString *rootType = rootAttributes[NSFileType]; + + if (rootType == NSFileTypeDirectory) { + // The NSDirectoryEnumerator will avoid recursing into any contained + // symbolic links, so no further type checks are needed. + NSDirectoryEnumerator *directoryEnumerator = [manager enumeratorAtURL:rootURL includingPropertiesForKeys:nil options:(NSDirectoryEnumerationOptions)0 errorHandler:nil]; + + for (NSURL *file in directoryEnumerator) { + [file setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:NULL]; + } + } + return; } @end