diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 14c5404c52..05a39a181d 100755 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -219,6 +219,8 @@ namespace OpenRA internal static void Initialize(Arguments args) { + Console.WriteLine("Platform is {0}", Platform.CurrentPlatform); + AppDomain.CurrentDomain.AssemblyResolve += FileSystem.ResolveAssembly; var defaultSupport = Environment.GetFolderPath(Environment.SpecialFolder.Personal) diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 6f79fa88d0..630fedc69d 100755 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -199,6 +199,7 @@ + diff --git a/OpenRA.Game/Platform.cs b/OpenRA.Game/Platform.cs new file mode 100644 index 0000000000..8718d6bff8 --- /dev/null +++ b/OpenRA.Game/Platform.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Diagnostics; +using OpenRA.FileFormats; + +namespace OpenRA +{ + enum PlatformType + { + Unknown, + Windows, + OSX, + Linux + } + + static class Platform + { + public static PlatformType CurrentPlatform + { + get + { + return currentPlatform.Value; + } + } + + static Lazy currentPlatform = new Lazy(GetCurrentPlatform); + + static PlatformType GetCurrentPlatform() + { + if (Environment.OSVersion.Platform == PlatformID.Win32NT) return PlatformType.Windows; + + try + { + var psi = new ProcessStartInfo("uname", "-s"); + psi.UseShellExecute = false; + psi.RedirectStandardOutput = true; + var p = Process.Start(psi); + var kernelName = p.StandardOutput.ReadToEnd(); + if (kernelName.Contains("Linux") || kernelName.Contains("BSD")) + return PlatformType.Linux; + if (kernelName.Contains("Darwin")) + return PlatformType.OSX; + } + catch { } + + return PlatformType.Unknown; + } + } +}