Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Colab.Core.OS
- open System
- open System.Diagnostics
- type Version =
- | Windows
- | Unix
- | OSX
- | Unknown
- let isDarwin = ref None
- let queryUname() =
- try
- let proc = new Process()
- let info = new ProcessStartInfo("uname", "-a")
- info.RedirectStandardOutput <- true
- info.WindowStyle <- ProcessWindowStyle.Hidden
- info.UseShellExecute <- false
- info.CreateNoWindow <- true
- proc.StartInfo <- info
- proc.Start() |> ignore
- let output = proc.StandardOutput.ReadToEnd()
- proc.WaitForExit()
- isDarwin := Some(output.Contains("Darwin Kernel"))
- with
- | _ ->
- ()
- let isWindows() =
- Environment.OSVersion.Platform = PlatformID.Win32S ||
- Environment.OSVersion.Platform = PlatformID.Win32NT ||
- Environment.OSVersion.Platform = PlatformID.Win32Windows ||
- Environment.OSVersion.Platform = PlatformID.WinCE ||
- Environment.OSVersion.Platform = PlatformID.Xbox
- let version =
- if isWindows() then Windows
- else
- queryUname()
- match !isDarwin with
- | Some(darwin) -> if darwin then OSX else Unix
- | None -> Unknown
- let isPosix = match version with | Unix -> true | OSX -> true | _ -> false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement