mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-27 05:04:27 +00:00
Merge pull request #639 from sparkle-project/at-least-version
Use proper version checking.
This commit is contained in:
commit
f9b9184a39
4 files changed
+19
-5
No files matched your search
Vendored
+4
-3
@@ -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];
|
||||
|
||||
Vendored
+1
@@ -24,6 +24,7 @@ typedef struct {
|
||||
@property (strong, readonly) NSBundle *bundle;
|
||||
|
||||
+ (NSOperatingSystemVersion)operatingSystemVersion;
|
||||
+ (BOOL)isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion)version;
|
||||
+ (NSString *)systemVersionString;
|
||||
|
||||
- (instancetype)initWithBundle:(NSBundle *)aBundle;
|
||||
|
||||
Vendored
+13
-1
@@ -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;
|
||||
|
||||
Vendored
+1
-1
@@ -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")];
|
||||
|
||||
Reference in new issue
Block a user