如何檢測OCaml中的系統類型/操作系統?如何檢測正在運行的操作系統?
我目前的想法真的很奇怪。運行的系統調用:"uname -a"
與
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)
即使在Cygwin上...
但我想一定是有本地的ocaml的方法來檢查系統類型。