-let mkdir path =
- let components = Str.split (Str.regexp "/") path in
- let rec aux where = function
- | [] -> ()
- | piece::tl ->
- let path = where ^ "/" ^ piece in
- (try
- Unix.mkdir path 0o755
- with
- | Unix.Unix_error (Unix.EEXIST,_,_) -> ()
- | Unix.Unix_error (e,_,_) -> raise (Failure (Unix.error_message e)));
- aux path tl
- in
- aux "" components
-
-let strip_trailing_blanks =
- let rex = Pcre.regexp "\\s*$" in
- fun s -> Pcre.replace ~rex s
-
-let split ?(char = ' ') s =
- let pieces = ref [] in
- let rec aux idx =
- match (try Some (String.index_from s idx char) with Not_found -> None) with
- | Some pos ->
- pieces := String.sub s idx (pos - idx) :: !pieces;
- aux (pos + 1)
- | None -> pieces := String.sub s idx (String.length s - idx) :: !pieces
- in
- aux 0;
- List.rev !pieces
-