]> matita.cs.unibo.it Git - helm.git/commitdiff
added is_writabledir to extlib
authorEnrico Tassi <enrico.tassi@inria.fr>
Wed, 23 May 2007 14:05:40 +0000 (14:05 +0000)
committerEnrico Tassi <enrico.tassi@inria.fr>
Wed, 23 May 2007 14:05:40 +0000 (14:05 +0000)
components/extlib/hExtlib.ml
components/extlib/hExtlib.mli

index 073c5695959480e657070af45a68ec3029132ef6..07886f2690e8eaba64137d434f330793c2423e04 100644 (file)
@@ -214,6 +214,16 @@ let is_dir fname =
     (Unix.stat fname).Unix.st_kind = Unix.S_DIR
   with Unix.Unix_error _ -> false
 
+let writable_dir path =
+  try
+    let file = path ^ "/prova_matita" in
+    let oc = open_out file in
+    close_out oc;
+    Sys.remove file;
+    true
+  with Sys_error _ -> false
+
+
 let is_regular fname =
   try
     (Unix.stat fname).Unix.st_kind = Unix.S_REG
index 5b467d00577fb71a44296fc54d537b4301d31453..99727331a601c6fc90f7bba439bedcf379ae44d9 100644 (file)
@@ -32,6 +32,7 @@ val unopt: 'a option -> 'a  (** @raise Failure *)
 (** {2 Filesystem} *)
 
 val is_dir: string -> bool  (** @return true if file is a directory *)
+val writable_dir: string -> bool  (** @return true if the directory is writable *)
 val is_regular: string -> bool  (** @return true if file is a regular file *)
 val mkdir: string -> unit (** create dir and parents. @raise Failure *)
 val tilde_expand: string -> string  (** bash-like (head) tilde expansion *)