blob: 148e954e77b87aed114564dc3dcb60833b2556f1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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;
}
}
}
|