Don't use new code if specifically targeting OS versions that have the new API.

This commit is contained in:
C.W. Betts committed 2014-07-19 15:05:08 -06:00
1 parent 578666e9e6
commit 32d4de464d
1 file changed
+22 -19
+22 -19
View File
@@ -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