X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;ds=inline;f=components%2Fextlib%2FhExtlib.ml;h=07886f2690e8eaba64137d434f330793c2423e04;hb=9333fdbe385f6e80b272b194e88001f28dbc8d73;hp=d4572789ad55f39795d000fd09192e839cfee02f;hpb=ad17757edcc6cf75be576268fab8cf52751d679a;p=helm.git diff --git a/components/extlib/hExtlib.ml b/components/extlib/hExtlib.ml index d4572789a..07886f269 100644 --- a/components/extlib/hExtlib.ml +++ b/components/extlib/hExtlib.ml @@ -164,6 +164,17 @@ let list_rev_map_filter f l = in aux [] l +let list_rev_map_filter_fold f v l = + let rec aux v a = function + | [] -> v, a + | hd :: tl -> + begin match f v hd with + | v, None -> aux v a tl + | v, Some b -> aux v (b :: a) tl + end + in + aux v [] l + let list_concat ?(sep = []) = let rec aux acc = function @@ -203,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