Merge commit 'ocaml3102'
[ocaml.git] / ocamlbuild / slurp.mli
blob1b28cc1bc2ed5de1eb83d176ae0bd1a338903c36
1 (***********************************************************************)
2 (* ocamlbuild *)
3 (* *)
4 (* Nicolas Pouillard, Berke Durak, projet Gallium, INRIA Rocquencourt *)
5 (* *)
6 (* Copyright 2007 Institut National de Recherche en Informatique et *)
7 (* en Automatique. All rights reserved. This file is distributed *)
8 (* under the terms of the Q Public License version 1.0. *)
9 (* *)
10 (***********************************************************************)
12 (* $Id$ *)
13 (* Original author: Berke Durak *)
14 (* Slurp *)
16 (** Scans a directory lazily to build a tree that can be user-decorated. *)
18 type 'a entry =
19 Dir of string * string * My_unix.stats Lazy.t * 'a * 'a entry list Lazy.t
20 (** [Dir(path, name, lst, decoration, lentries)] is a directory named [name] whose path is [path].
21 Its stat is lazily stored in [lst] and its entries are lazily scanned in [lentries]. [decoration]
22 is of type 'a. *)
23 | File of string * string * My_unix.stats Lazy.t * 'a
24 (** [File(path, name, lst, decoration)] is a file named [name] whose path is [path].
25 Its stat is lazily stored in [lst]. [decoration] is of type 'a. *)
26 | Error of exn
27 (** [Error x] means that the exception [x] was raised while scanning or statting an entry. *)
28 | Nothing
29 (** Convenient when filtering out entries. *)
31 (** Recursively scan the filesystem starting at the given directory. *)
32 val slurp : string -> unit entry
34 (** [filter f entry] only retains from [entry] the nodes for which
35 [f path name] returns [true]. *)
36 val filter : (string -> string -> 'a -> bool) -> 'a entry -> 'a entry
38 (** [map f entries] changes the decoration in [entries] by applying
39 [f] to them. [f] is called as [f path name decoration]. *)
40 val map : (string -> string -> 'a -> 'b) -> 'a entry -> 'b entry
42 (** [fold f entry x] iterates [f] over the entries and an accumulator
43 initially containing [x]; at each iteration, [f] gets the current
44 value of the accumulator and returns its new value. *)
45 val fold : (string -> string -> 'b -> 'a -> 'a) -> 'b entry -> 'a -> 'a
47 (** Force the evaluation of the whole entry. *)
48 val force : 'a entry -> unit