1 (**************************************************************************)
2 (* *)
3 (* OCaml *)
4 (* *)
5 (* Jeremie Dimino, Jane Street Europe *)
6 (* *)
7 (* Copyright 2018 Jane Street Group LLC *)
8 (* *)
9 (* All rights reserved. This file is distributed under the terms of *)
10 (* the GNU Lesser General Public License version 2.1, with the *)
11 (* special exception on linking described in the file LICENSE. *)
12 (* *)
13 (**************************************************************************)
14
15 (** Management of include directories.
16
17 This module offers a high level interface to locating files in the
18 load path, which is constructed from [-I] command line flags and a few
19 other parameters.
20
21 It makes the assumption that the contents of include directories
22 doesn't change during the execution of the compiler.
23 *)
24
25 val add_dir : string -> unit
26 (** Add a directory to the load path *)
27
28 val remove_dir : string -> unit
29 (** Remove a directory from the load path *)
30
31 val reset : unit -> unit
32 (** Remove all directories *)
33
34 val init : string list -> unit
35 (** [init l] is the same as [reset (); List.iter add_dir (List.rev l)] *)
36
37 val get_paths : unit -> string list
38 (** Return the list of directories passed to [add_dir] so far, in
39 reverse order. *)
40
41 val find : string -> string
42 (** Locate a file in the load path. Raise [Not_found] if the file
43 cannot be found. This function is optimized for the case where the
44 filename is a basename, i.e. doesn't contain a directory
45 separator. *)
46
47 val find_uncap : string -> string
48 (** Same as [find], but search also for uncapitalized name, i.e. if
49 name is Foo.ml, allow /path/Foo.ml and /path/foo.ml to match. *)
50
51 module Dir : sig
52 type t
53 (** Represent one directory in the load path. *)
54
55 val create : string -> t
56
57 val path : t -> string
58
59 val files : t -> string list
60 (** All the files in that directory. This doesn't include files in
61 sub-directories of this directory. *)
62 end
63
64 val add : Dir.t -> unit
65
66 val get : unit -> Dir.t list
67 (** Same as [get_paths ()], except that it returns a [Dir.t list]. *)
68