(svn r17704) -Codechange: [OSX] Improve detection of OS X version. (planetmaker)

This commit is contained in:
michi_cc
2009-10-04 20:53:30 +00:00
parent 6db8927ecc
commit 1c7e5658cd
2 changed files with 42 additions and 106 deletions

View File

@@ -54,25 +54,7 @@ void ShowMacErrorDialog(const char *error);
(__builtin_expect(!(e), 0) ? ShowMacAssertDialog ( __func__, __FILE__, __LINE__, #e ): (void)0 )
#endif
/**
* Get the major version of Mac OS we are running under. Useful for things like the cocoa driver.
* @return major version of the os. This would be 10 in the case of 10.4.11.
*/
long GetMacOSVersionMajor();
/**
* Get the minor version of Mac OS we are running under. Useful for things like the cocoa driver.
* @return minor version of the os. This would be 4 in the case of 10.4.11.
*/
long GetMacOSVersionMinor();
/**
* Get the bugfix version of Mac OS we are running under. Useful for things like the cocoa driver.
* @return bugfix version of the os. This would be 11 in the case of 10.4.11.
*/
long GetMacOSVersionBugfix();
void GetMacOSVersion(int *return_major, int *return_minor, int *return_bugfix);
/**
* Check if we are at least running on the specified version of Mac OS.
@@ -83,13 +65,12 @@ long GetMacOSVersionBugfix();
*/
static inline bool MacOSVersionIsAtLeast(long major, long minor, long bugfix)
{
long maj = GetMacOSVersionMajor();
long min = GetMacOSVersionMinor();
long bf = GetMacOSVersionBugfix();
int version_major, version_minor, version_bugfix;
GetMacOSVersion(&version_major, &version_minor, &version_bugfix);
if (maj < major) return false;
if (maj == major && min < minor) return false;
if (maj == major && min == minor && bf < bugfix) return false;
if (version_major < major) return false;
if (version_major == major && version_minor < minor) return false;
if (version_major == major && version_minor == minor && version_bugfix < bugfix) return false;
return true;
}