Merge pull request #639 from sparkle-project/at-least-version

Use proper version checking.
This commit is contained in:
Jake Petroules committed 2015-09-27 16:00:32 -07:00
commit f9b9184a39
4 files changed
+19 -5

No files matched your search

+4 -3
View File
@@ -7,6 +7,7 @@
//
#import "SUFileManager.h"
#import "SUHost.h"
#include <sys/xattr.h>
#include <sys/errno.h>
@@ -699,8 +700,8 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
NSURL *trashURL = nil;
BOOL canUseNewTrashAPI = YES;
#if __MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8
canUseNewTrashAPI = [_fileManager respondsToSelector:@selector(trashItemAtURL:resultingItemURL:error:)];
#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1080
canUseNewTrashAPI = [SUHost isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){10, 8, 0}];
if (!canUseNewTrashAPI) {
FSRef trashRef;
if (FSFindFolder(kUserDomain, kTrashFolderType, kDontCreateFolder, &trashRef) == noErr) {
@@ -747,7 +748,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
// If we get here, we should be able to trash the item normally without authentication
BOOL success = NO;
#if __MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8
#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1080
if (!canUseNewTrashAPI) {
NSString *tempParentPath = tempItemURL.URLByDeletingLastPathComponent.path;
success = [[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:tempParentPath destination:@"" files:@[tempItemURL.lastPathComponent] tag:NULL];
+1
View File
@@ -24,6 +24,7 @@ typedef struct {
@property (strong, readonly) NSBundle *bundle;
+ (NSOperatingSystemVersion)operatingSystemVersion;
+ (BOOL)isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion)version;
+ (NSString *)systemVersionString;
- (instancetype)initWithBundle:(NSBundle *)aBundle;
+13 -1
View File
@@ -286,7 +286,7 @@
+ (NSOperatingSystemVersion)operatingSystemVersion
{
#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1090 // Present in 10.9 despite NS_AVAILABLE's claims
#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101000
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wselector"
// Xcode 5.1.1: operatingSystemVersion is clearly declared, must warn due to a compiler bug?
@@ -305,6 +305,18 @@
return [[NSProcessInfo processInfo] operatingSystemVersion];
}
+ (BOOL)isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion)version
{
const NSOperatingSystemVersion systemVersion = self.operatingSystemVersion;
if (systemVersion.majorVersion == version.majorVersion) {
if (systemVersion.minorVersion == version.minorVersion) {
return systemVersion.patchVersion >= version.patchVersion;
}
return systemVersion.minorVersion >= version.minorVersion;
}
return systemVersion.majorVersion >= version.majorVersion;
}
+ (NSString *)systemVersionString
{
NSOperatingSystemVersion version = self.operatingSystemVersion;
+1 -1
View File
@@ -128,7 +128,7 @@
- (NSString *)localizedStringFromByteCount:(long long)value
{
if (SUHost.operatingSystemVersion.minorVersion < 8) {
if (![SUHost isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){10, 8, 0}]) {
if (value < 1000) {
return [NSString stringWithFormat:@"%.0lf %@", value / 1.0,
SULocalizedString(@"B", @"the unit for bytes")];