static DetectedPlatformInfo DetectPlatform() { var macInfo = new DetectedPlatformInfo(new OsxLoader(), "Darwin", IntPtr.Size == 4 ? "i686" : "x86_64", ".dylib"); switch (Environment.OSVersion.Platform) { case PlatformID.Unix: // Well, there are chances MacOSX is reported as Unix instead of MacOSX. // Instead of platform check, we'll do a feature checks (Mac specific root folders) if (Directory.Exists("/Applications") & Directory.Exists("/System") & Directory.Exists("/Users") & Directory.Exists("/Volumes")) { return(macInfo); } else { string cpuArch; using (var proc = Process.Start( (new ProcessStartInfo("uname", "-p") { UseShellExecute = false, RedirectStandardOutput = true }))) { proc.WaitForExit(); cpuArch = proc.StandardOutput.ReadToEnd().Trim(); } return(new DetectedPlatformInfo(new LinuxLoader(), "Linux", cpuArch, ".so")); } case PlatformID.MacOSX: return(macInfo); default: return(new DetectedPlatformInfo(new Win32Loader(), "Windows", IntPtr.Size == 4 ? "i686" : "x86_64", ".dll")); } }
static DetectedPlatformInfo DetectPlatform() { var macInfo = new DetectedPlatformInfo(new OsxLoader(), "Darwin", IntPtr.Size == 4 ? "i686" : "x86_64", ".dylib"); switch (Environment.OSVersion.Platform) { case PlatformID.Unix: // Well, there are chances MacOSX is reported as Unix instead of MacOSX. // Instead of platform check, we'll do a feature checks (Mac specific root folders) if (Directory.Exists("/Applications") & Directory.Exists("/System") & Directory.Exists("/Users") & Directory.Exists("/Volumes")) return macInfo; else { string cpuArch; using (var proc = Process.Start( (new ProcessStartInfo("uname", "-p") { UseShellExecute = false, RedirectStandardOutput = true }))) { proc.WaitForExit(); cpuArch = proc.StandardOutput.ReadToEnd().Trim(); } return new DetectedPlatformInfo(new LinuxLoader(), "Linux", cpuArch, ".so"); } case PlatformID.MacOSX: return macInfo; default: return new DetectedPlatformInfo(new Win32Loader(), "Windows", IntPtr.Size == 4 ? "i686" : "x86_64", ".dll"); } }