]> matita.cs.unibo.it Git - helm.git/commitdiff
added an utility function
authorEnrico Tassi <enrico.tassi@inria.fr>
Thu, 30 Aug 2007 13:08:24 +0000 (13:08 +0000)
committerEnrico Tassi <enrico.tassi@inria.fr>
Thu, 30 Aug 2007 13:08:24 +0000 (13:08 +0000)
components/extlib/hExtlib.ml
components/extlib/hExtlib.mli

index 07886f2690e8eaba64137d434f330793c2423e04..d9b24c2eb38d92bd4377bbafcf08d4ab6322700c 100644 (file)
@@ -229,6 +229,13 @@ let is_regular fname =
     (Unix.stat fname).Unix.st_kind = Unix.S_REG
   with Unix.Unix_error _ -> false
 
+let is_executable fname =
+  try
+    let stat = (Unix.stat fname) in
+    stat.Unix.st_kind = Unix.S_REG &&
+    (stat.Unix.st_perm land 0o001 > 0)
+  with Unix.Unix_error _ -> false
+
 let mkdir path =
   let components = split ~sep:'/' path in
   let rec aux where = function
index 99727331a601c6fc90f7bba439bedcf379ae44d9..815c2052665c6d6a4587612e6ceee38c6da88f0a 100644 (file)
@@ -34,6 +34,7 @@ val unopt: 'a option -> 'a  (** @raise Failure *)
 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 is_executable: string -> bool  (** @return true if file is executable *)
 val mkdir: string -> unit (** create dir and parents. @raise Failure *)
 val tilde_expand: string -> string  (** bash-like (head) tilde expansion *)
 val safe_remove: string -> unit (** removes a file if it exists *)