]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/components/extlib/hExtlib.mli
added is_writabledir to extlib
[helm.git] / helm / software / components / extlib / hExtlib.mli
index aed9b240693cdd4a9621984ddec60d1bbc4356b6..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 *)
@@ -40,8 +41,8 @@ val safe_rmdir: string -> unit (** removes a dir if it exists and is empty *)
 val is_dir_empty: string -> bool (** checks if the dir is empty *)
 val rmdir_descend: string -> unit (** rmdir -p *)
 
-
-  (** find all _files_ matching test under a filesystem root *)
+  (** find all _files_ whose name matches test under a filesystem root.
+   * Test is passed the filename path relative to the given filesystem root *)
 val find: ?test:(string -> bool) -> string -> string list 
 
 (** {2 File I/O} *)
@@ -52,6 +53,10 @@ val output_file: filename:string -> text:string -> unit (** other way round *)
 
 (** {2 Exception handling} *)
 
+  (** @param finalizer finalization function (execution both in case of success
+   * and in case of raised exception
+   * @param f function to be invoked
+   * @param arg argument to be passed to function *)
 val finally: (unit -> unit) -> ('a -> 'b) -> 'a -> 'b
 
 (** {2 Char processing} *)
@@ -71,8 +76,18 @@ val trim_blanks: string -> string (** strip heading and trailing blanks *)
 val list_uniq: 
   ?eq:('a->'a->bool) -> 'a list -> 'a list (** uniq unix filter on lists *)
 val filter_map: ('a -> 'b option) -> 'a list -> 'b list (** filter + map *)
+val list_rev_map_filter: ('a -> 'b option) -> 'a list -> 'b list
+val list_rev_map_filter_fold: ('c -> 'a -> 'c * 'b option) -> 'c -> 'a list -> 'c * 'b list
 val list_concat: ?sep:'a list -> 'a list list -> 'a list (**String.concat-like*)
 val list_findopt: ('a -> 'b option) -> 'a list -> 'b option
+val flatten_map: ('a -> 'b list) -> 'a list -> 'b list
+val list_last: 'a list -> 'a
+
+  (** split_nth n l
+   * @returns two list, the first contains at least n elements, the second the
+   * remaining one
+   * @raise Failure when List.length l < n *)
+val split_nth: int -> 'a list -> 'a list * 'a list
 
 (** {2 Debugging & Profiling} *)
 
@@ -81,7 +96,7 @@ type profiler = { profile : 'a 'b. ('a -> 'b) -> 'a -> 'b }
   (** @return a profiling function; [s] is used for labelling the total time at
    * the end of the execution *)
 val profile : ?enable:bool -> string -> profiler
-val set_profiling_printings : (unit -> bool) -> unit
+val set_profiling_printings : (string -> bool) -> unit
 
 (** {2 Localized exceptions } *)
 
@@ -93,3 +108,7 @@ val floc_of_loc: int * int -> Token.flocation
 val dummy_floc: Lexing.position * Lexing.position
 
 val raise_localized_exception: offset:int -> Token.flocation -> exn -> 'a
+
+(* size in KB (SLOW) *)
+val estimate_size: 'a -> int
+