mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-07 09:56:59 +00:00
Use NSOperatingSystemVersion to get macOS version when possible
This commit is contained in:
parent
3343485acf
commit
46dbffa45f
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#elif __APPLE__ // Mac OS X
|
#elif __APPLE__ // Mac OS X
|
||||||
|
|
||||||
void getMacOSXVersion(int* major, int* minor, int* bugFix);
|
void getMacOSXVersion(int& major, int& minor, int& patch);
|
||||||
|
|
||||||
#else // Unix-like system
|
#else // Unix-like system
|
||||||
|
|
||||||
@ -82,9 +82,9 @@ std::string getUserAgent()
|
|||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Mac OS X
|
// Mac OS X
|
||||||
|
|
||||||
int major, minor, bugFix;
|
int major, minor, patch;
|
||||||
getMacOSXVersion(&major, &minor, &bugFix);
|
getMacOSXVersion(major, minor, patch);
|
||||||
userAgent << "Mac OS X " << major << "." << minor << "." << bugFix;
|
userAgent << "Mac OS X " << major << "." << minor << "." << patch;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2015 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -10,28 +10,34 @@
|
|||||||
|
|
||||||
#include <Cocoa/Cocoa.h>
|
#include <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
void getMacOSXVersion(int* major, int* minor, int* bugFix)
|
void getMacOSXVersion(int& major, int& minor, int& patch)
|
||||||
{
|
{
|
||||||
OSErr err;
|
major = 10;
|
||||||
SInt32 systemVersion, versionMajor, versionMinor, versionBugFix;
|
minor = 0;
|
||||||
if (Gestalt(gestaltSystemVersion, &systemVersion) != noErr) goto fail;
|
patch = 0;
|
||||||
if (systemVersion < 0x1040) {
|
|
||||||
if (major) *major = ((systemVersion & 0xF000) >> 12) * 10 + ((systemVersion & 0x0F00) >> 8);
|
NSProcessInfo* info = [NSProcessInfo processInfo];
|
||||||
if (minor) *minor = (systemVersion & 0x00F0) >> 4;
|
if ([info respondsToSelector:@selector(operatingSystemVersion)]) {
|
||||||
if (bugFix) *bugFix = (systemVersion & 0x000F);
|
NSOperatingSystemVersion osVer = [info operatingSystemVersion];
|
||||||
|
major = osVer.majorVersion;
|
||||||
|
minor = osVer.minorVersion;
|
||||||
|
patch = osVer.patchVersion;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ((err = Gestalt(gestaltSystemVersionMajor, &versionMajor)) != noErr) goto fail;
|
SInt32 systemVersion, majorVersion, minorVersion, patchVersion;
|
||||||
if ((err = Gestalt(gestaltSystemVersionMinor, &versionMinor)) != noErr) goto fail;
|
if (Gestalt(gestaltSystemVersion, &systemVersion) != noErr)
|
||||||
if ((err = Gestalt(gestaltSystemVersionBugFix, &versionBugFix)) != noErr) goto fail;
|
return;
|
||||||
if (major) *major = versionMajor;
|
if (systemVersion < 0x1040) {
|
||||||
if (minor) *minor = versionMinor;
|
major = ((systemVersion & 0xF000) >> 12) * 10 + ((systemVersion & 0x0F00) >> 8);
|
||||||
if (bugFix) *bugFix = versionBugFix;
|
minor = (systemVersion & 0x00F0) >> 4;
|
||||||
|
patch = (systemVersion & 0x000F);
|
||||||
|
}
|
||||||
|
else if (Gestalt(gestaltSystemVersionMajor, &majorVersion) == noErr &&
|
||||||
|
Gestalt(gestaltSystemVersionMinor, &minorVersion) == noErr &&
|
||||||
|
Gestalt(gestaltSystemVersionBugFix, &patchVersion) == noErr) {
|
||||||
|
major = majorVersion;
|
||||||
|
minor = minorVersion;
|
||||||
|
patch = patchVersion;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
|
|
||||||
fail:
|
|
||||||
if (major) *major = 10;
|
|
||||||
if (minor) *minor = 0;
|
|
||||||
if (bugFix) *bugFix = 0;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user