let mkdir ?(parent=false) ?(mode=0o0755) fln =
let mkdir_simple fln =
if test Exists fln then
if test Is_dir fln then
()
else
raise (MkdirDirnameAlreadyUsed fln)
else
try
Unix.mkdir fln mode
with Unix.Unix_error(Unix.ENOENT,_,_) | Unix.Unix_error(Unix.ENOTDIR,_,_) ->
raise (MkdirMissingComponentPath fln)
in
let directories =
if parent then
all_upper_dir fln
else
[fln]
in
List.iter mkdir_simple directories