From aeb75cae8119fb93fa3561278f7eea3d59727bdb Mon Sep 17 00:00:00 2001 From: Enrico Tassi Date: Wed, 23 May 2007 14:05:40 +0000 Subject: [PATCH] added is_writabledir to extlib --- helm/software/components/extlib/hExtlib.ml | 10 ++++++++++ helm/software/components/extlib/hExtlib.mli | 1 + 2 files changed, 11 insertions(+) diff --git a/helm/software/components/extlib/hExtlib.ml b/helm/software/components/extlib/hExtlib.ml index 073c56959..07886f269 100644 --- a/helm/software/components/extlib/hExtlib.ml +++ b/helm/software/components/extlib/hExtlib.ml @@ -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 diff --git a/helm/software/components/extlib/hExtlib.mli b/helm/software/components/extlib/hExtlib.mli index 5b467d005..99727331a 100644 --- a/helm/software/components/extlib/hExtlib.mli +++ b/helm/software/components/extlib/hExtlib.mli @@ -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 *) -- 2.39.2