summaryrefslogtreecommitdiff
path: root/src/os/macosx/macos.h
diff options
context:
space:
mode:
authoregladil <egladil@openttd.org>2007-11-25 14:43:16 +0000
committeregladil <egladil@openttd.org>2007-11-25 14:43:16 +0000
commit35159d5db3b9e739f640d04616f0ee131e65c70b (patch)
tree8ee1ef0bc994c64d37a179e595db5424e0af4375 /src/os/macosx/macos.h
parentb24392dfddb6710584927efba2ba6d4cc971aad6 (diff)
downloadopenttd-35159d5db3b9e739f640d04616f0ee131e65c70b.tar.xz
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
Diffstat (limited to 'src/os/macosx/macos.h')
-rw-r--r--src/os/macosx/macos.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/os/macosx/macos.h b/src/os/macosx/macos.h
index b8a6cd511..dc2637acc 100644
--- a/src/os/macosx/macos.h
+++ b/src/os/macosx/macos.h
@@ -27,4 +27,44 @@ 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();
+
+/**
+ * Check if we are at least running on the specified version of Mac OS.
+ * @param major major version of the os. This would be 10 in the case of 10.4.11.
+ * @param minor minor version of the os. This would be 4 in the case of 10.4.11.
+ * @param bugfix bugfix version of the os. This would be 11 in the case of 10.4.11.
+ * @return true if the running os is at least what we asked, false otherwise.
+ */
+static inline bool MacOSVersionIsAtLeast(long major, long minor, long bugfix)
+{
+ long maj = GetMacOSVersionMajor();
+ long min = GetMacOSVersionMinor();
+ long bf = GetMacOSVersionBugfix();
+
+ if (maj < major) return false;
+ if (maj == major && min < minor) return false;
+ if (maj == major && min == minor && bf < bugfix) return false;
+
+ return true;
+}
+
#endif /* MACOS_H */