如何在OCaml中检测系统类型/操作系统?
我目前的想法真的很奇怪.正在运行系统调用:"uname -a"
with
let syscall ?(env=[| |]) cmd =
let ic, oc, ec = Unix.open_process_full cmd env in
let buf1 = Buffer.create 96
and buf2 = Buffer.create 48 in
(try
while true do Buffer.add_channel buf1 ic 1 done
with End_of_file -> ());
(try
while true do Buffer.add_channel buf2 ec 1 done
with End_of_file -> ());
let exit_status = Unix.close_process_full (ic, oc, ec) in
check_exit_status exit_status;
(Buffer.contents buf1,
Buffer.contents buf2)
Run Code Online (Sandbox Code Playgroud)
甚至在cygwin ......
但我想必须有一些原生的ocaml方式来检查系统类型.