Navigation Menu

Skip to content

Commit

Permalink
[fix] file.ml: revert to previous check_create_path behavioour
Browse files Browse the repository at this point in the history
see commit 97e53b1
  • Loading branch information
Frederic Ye committed Nov 27, 2012
1 parent 7bcd8f6 commit f771f1f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ocamllib/libbase/file.ml
@@ -1,5 +1,5 @@
(* (*
Copyright © 2011 MLstate Copyright © 2011, 2012 MLstate
This file is part of Opa. This file is part of Opa.
Expand Down Expand Up @@ -324,20 +324,21 @@ let rec remove_all_symlinks path =


(** create all necessary directories to access a file path *) (** create all necessary directories to access a file path *)
let rec check_create_path ?(rights=0o755) ?(nobackslash=true) ?(isdirectory=false) 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 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 path = if nobackslash then Base.String.map (fun c -> if c='\\' then '/' else c) path else path in
let dirname = Filename.dirname path in let dirname = Filename.dirname path in
if dirname=path || dirname=".." || path="." || path="/" then ( if dirname=path || dirname=".." || path="." || path="/" then (
true (*terminal case*) true (*terminal case*)
) else ) else
try try
Sys.is_directory dirname || ( Sys.is_directory dirname || (
failwith ("Not a directory but exists: "^dirname) failwith ("Not a directory but exists: "^dirname)
) )
(* terminal case *) (* terminal case *)
with Sys_error _ -> ( with Sys_error _ -> (
check_create_path ~rights dirname check_create_path ~rights dirname
&& (try Unix.mkdir dirname rights; true with Unix.Unix_error _ -> Printf.printf "mkdir error%s\n" dirname; false) && (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 *) (** hopefully, this is the ultimate and portable version of cp *)
Expand Down

0 comments on commit f771f1f

Please sign in to comment.