Add Misc.split_path_contents

master
Nicolás Ojeda Bär 2018-06-15 11:47:14 +02:00
parent 409fe6d1e6
commit 223f2e2ffa
3 changed files with 16 additions and 6 deletions

View File

@ -133,16 +133,11 @@ let ld_conf_contents () =
(* Split the CAML_LD_LIBRARY_PATH environment variable and return
the corresponding list of directories. *)
let ld_library_path_contents () =
let path_separator =
match Sys.os_type with
| "Unix" | "Cygwin" -> ':'
| "Win32" -> ';'
| _ -> assert false in
match Sys.getenv "CAML_LD_LIBRARY_PATH" with
| exception Not_found ->
[]
| s ->
String.split_on_char path_separator s
Misc.split_path_contents s
let split_dll_path path =
String.split_on_char '\000' path

View File

@ -272,6 +272,17 @@ let expand_directory alt s =
(String.sub s 1 (String.length s - 1))
else s
(* Split contents of "PATH"-like variable and return
the corresponding list of directories. *)
let split_path_contents s =
let path_separator =
match Sys.os_type with
| "Unix" | "Cygwin" -> ':'
| "Win32" -> ';'
| _ -> assert false
in
String.split_on_char path_separator s
(* Hashtable functions *)
let create_hashtable size init =

View File

@ -163,6 +163,10 @@ val expand_directory: string -> string -> string
(* [expand_directory alt file] eventually expands a [+] at the
beginning of file into [alt] (an alternate root directory) *)
val split_path_contents: string -> string list
(* Split contents of "PATH"-like variable and return
the corresponding list of directories. *)
val create_hashtable: int -> ('a * 'b) list -> ('a, 'b) Hashtbl.t
(* Create a hashtable of the given size and fills it with the
given bindings. *)