Make directory path: Difference between revisions

Content added Content deleted
(Added Delphi example)
(Added OCaml)
Line 497: Line 497:
}
}
}</lang>
}</lang>


=={{header|OCaml}}==

<lang ocaml>#load "unix.cma"

let mkdir_p ~path ~perms =
let ps = String.split_on_char '/' path in
let rec aux acc = function [] -> ()
| p::ps ->
let this = String.concat Filename.dir_sep (List.rev (p::acc)) in
Unix.mkdir this 0o700;
aux (p::acc) ps
in
aux [] ps

let () =
mkdir_p "path/to/dir" 0o700</lang>


=={{header|Perl}}==
=={{header|Perl}}==