Browse Source

Added missing Platform class file.

pull/499/head
triton 10 years ago
parent
commit
d0b7ad72a0
  1. 50
      src/Core/Platform.cs

50
src/Core/Platform.cs

@ -0,0 +1,50 @@ @@ -0,0 +1,50 @@
using System;
using System.Runtime.InteropServices;
namespace CppSharp
{
public static class Platform
{
public static bool IsWindows
{
get
{
switch (Environment.OSVersion.Platform)
{
case PlatformID.Win32NT:
case PlatformID.Win32S:
case PlatformID.Win32Windows:
case PlatformID.WinCE:
return true;
}
return false;
}
}
[DllImport("libc")]
static extern int uname(IntPtr buf);
public static bool IsMacOS
{
get
{
if (Environment.OSVersion.Platform != PlatformID.Unix)
return false;
IntPtr buf = Marshal.AllocHGlobal(8192);
if (uname(buf) == 0)
{
string os = Marshal.PtrToStringAnsi(buf);
switch (os)
{
case "Darwin":
return true;
}
}
Marshal.FreeHGlobal(buf);
return false;
}
}
}
Loading…
Cancel
Save