diff options
| author | Ignacio Etcheverry <neikeq@users.noreply.github.com> | 2018-09-17 20:22:05 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-09-17 20:22:05 +0200 |
| commit | a4e4dd396665a29dac63339930a97852bb8cd449 (patch) | |
| tree | da11096af8a17222c1ce1ddfee37617315cf5185 /modules/mono/editor/GodotSharpTools/Utils/OS.cs | |
| parent | 9610bc95803a3524ff1aa21b2fb7d2f94c41e4b4 (diff) | |
| parent | 50f6dbff871e9e7997b3b9e5a312cde206de62d4 (diff) | |
| download | redot-engine-a4e4dd396665a29dac63339930a97852bb8cd449.tar.gz | |
Merge pull request #22193 from neikeq/idontlikesanditscoarseandroughandirritatinganditgetseverywhere
Mono: Build and external editor improvements for OSX
Diffstat (limited to 'modules/mono/editor/GodotSharpTools/Utils/OS.cs')
| -rw-r--r-- | modules/mono/editor/GodotSharpTools/Utils/OS.cs | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/modules/mono/editor/GodotSharpTools/Utils/OS.cs b/modules/mono/editor/GodotSharpTools/Utils/OS.cs new file mode 100644 index 0000000000..148e954e77 --- /dev/null +++ b/modules/mono/editor/GodotSharpTools/Utils/OS.cs @@ -0,0 +1,62 @@ +using System; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace GodotSharpTools.Utils +{ + public static class OS + { + [MethodImpl(MethodImplOptions.InternalCall)] + extern static string GetPlatformName(); + + const string HaikuName = "Haiku"; + const string OSXName = "OSX"; + const string ServerName = "Server"; + const string UWPName = "UWP"; + const string WindowsName = "Windows"; + const string X11Name = "X11"; + + public static bool IsHaiku() + { + return HaikuName.Equals(GetPlatformName(), StringComparison.OrdinalIgnoreCase); + } + + public static bool IsOSX() + { + return OSXName.Equals(GetPlatformName(), StringComparison.OrdinalIgnoreCase); + } + + public static bool IsServer() + { + return ServerName.Equals(GetPlatformName(), StringComparison.OrdinalIgnoreCase); + } + + public static bool IsUWP() + { + return UWPName.Equals(GetPlatformName(), StringComparison.OrdinalIgnoreCase); + } + + public static bool IsWindows() + { + return WindowsName.Equals(GetPlatformName(), StringComparison.OrdinalIgnoreCase); + } + + public static bool IsX11() + { + return X11Name.Equals(GetPlatformName(), StringComparison.OrdinalIgnoreCase); + } + + static bool? IsUnixCache = null; + static readonly string[] UnixPlatforms = new string[] { HaikuName, OSXName, ServerName, X11Name }; + + public static bool IsUnix() + { + if (IsUnixCache.HasValue) + return IsUnixCache.Value; + + string osName = GetPlatformName(); + IsUnixCache = UnixPlatforms.Any(p => p.Equals(osName, StringComparison.OrdinalIgnoreCase)); + return IsUnixCache.Value; + } + } +} |
