diff --git a/ocamllib/libbase/file.ml b/ocamllib/libbase/file.ml index b32aa683..2cf59549 100644 --- a/ocamllib/libbase/file.ml +++ b/ocamllib/libbase/file.ml @@ -1,5 +1,5 @@ (* - Copyright © 2011 MLstate + Copyright © 2011, 2012 MLstate This file is part of Opa. @@ -324,20 +324,21 @@ let rec remove_all_symlinks path = (** create all necessary directories to access a file path *) let rec check_create_path ?(rights=0o755) ?(nobackslash=true) ?(isdirectory=false) path = + let path = remove_all_symlinks path in let path = if isdirectory then Filename.concat path "test" else path in let path = if nobackslash then Base.String.map (fun c -> if c='\\' then '/' else c) path else path in let dirname = Filename.dirname path in if dirname=path || dirname=".." || path="." || path="/" then ( true (*terminal case*) - ) else + ) else try Sys.is_directory dirname || ( failwith ("Not a directory but exists: "^dirname) ) (* terminal case *) with Sys_error _ -> ( - check_create_path ~rights dirname - && (try Unix.mkdir dirname rights; true with Unix.Unix_error _ -> Printf.printf "mkdir error%s\n" dirname; false) + check_create_path ~rights dirname + && (try Unix.mkdir dirname rights; true with Unix.Unix_error _ -> Printf.printf "mkdir error %s\n" dirname; false) ) (** hopefully, this is the ultimate and portable version of cp *)