20 lines
578 B
OCaml
20 lines
578 B
OCaml
let dune_exe_rx = Str.regexp "^Dune__exe__"
|
|
let dune_underscore_rx = Str.regexp "__"
|
|
|
|
let parse_module_name (name : string) : string list =
|
|
match String.split_on_char '.' name with
|
|
| [] -> []
|
|
| fst::rst ->
|
|
let fst = Str.global_replace dune_exe_rx "[EXE]" fst in
|
|
(Str.split dune_underscore_rx fst) @ rst
|
|
|
|
external unix_code_of_unix_error : Unix.error -> int = "caml_unix_code_of_unix_error"
|
|
|
|
let get_errno errno exn =
|
|
if errno != 0 then
|
|
errno
|
|
else
|
|
match exn with
|
|
| Some ((Unix.Unix_error (err, _, _)), _) -> unix_code_of_unix_error err
|
|
| _ -> 0
|