corrade-vassal – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 1 | using System; |
2 | using System.IO; |
||
3 | |||
4 | namespace GridProxyGUI |
||
5 | { |
||
6 | public static class PlatformDetection |
||
7 | { |
||
8 | public readonly static bool IsWindows; |
||
9 | public readonly static bool IsMac; |
||
10 | |||
11 | static PlatformDetection() |
||
12 | { |
||
13 | IsWindows = Path.DirectorySeparatorChar == '\\'; |
||
14 | IsMac = !IsWindows && IsRunningOnMac(); |
||
15 | } |
||
16 | |||
17 | //From Managed.Windows.Forms/XplatUI |
||
18 | static bool IsRunningOnMac() |
||
19 | { |
||
20 | IntPtr buf = IntPtr.Zero; |
||
21 | try |
||
22 | { |
||
23 | buf = System.Runtime.InteropServices.Marshal.AllocHGlobal(8192); |
||
24 | // This is a hacktastic way of getting sysname from uname () |
||
25 | if (uname(buf) == 0) |
||
26 | { |
||
27 | string os = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(buf); |
||
28 | if (os == "Darwin") |
||
29 | return true; |
||
30 | } |
||
31 | } |
||
32 | catch |
||
33 | { |
||
34 | } |
||
35 | finally |
||
36 | { |
||
37 | if (buf != IntPtr.Zero) |
||
38 | System.Runtime.InteropServices.Marshal.FreeHGlobal(buf); |
||
39 | } |
||
40 | return false; |
||
41 | } |
||
42 | |||
43 | [System.Runtime.InteropServices.DllImport("libc")] |
||
44 | static extern int uname(IntPtr buf); |
||
45 | } |
||
46 | } |
||
47 |