GSF.Common.GetOSPlatformID C# (CSharp) Method

GetOSPlatformID() public static method

Gets the operating system PlatformID
This function will properly detect the platform ID, even if running on Mac.
public static GetOSPlatformID ( ) : PlatformID
return PlatformID
        public static PlatformID GetOSPlatformID()
        {
            if (s_osPlatformID != PlatformID.Win32S)
                return s_osPlatformID;

            s_osPlatformID = Environment.OSVersion.Platform;

            if (s_osPlatformID == PlatformID.Unix)
            {
                // Environment.OSVersion.Platform can report Unix when running on Mac OS X
                try
                {
                    s_osPlatformID = Command.Execute("uname").StandardOutput.StartsWith("Darwin", StringComparison.OrdinalIgnoreCase) ? PlatformID.MacOSX : PlatformID.Unix;
                }
                catch
                {
                    // Fall back on looking for Mac specific root folders:
                    if (Directory.Exists("/Applications") && Directory.Exists("/System") && Directory.Exists("/Users") && Directory.Exists("/Volumes"))
                        s_osPlatformID = PlatformID.MacOSX;
                }
            }

            return s_osPlatformID;
        }