File: fs.mli

package info (click to toggle)
ocaml-odoc 1.5.2%2Bdfsg2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 5,972 kB
  • sloc: ml: 26,974; makefile: 59; sh: 35
file content (71 lines) | stat: -rw-r--r-- 2,006 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
open Or_error

(*
 * Copyright (c) 2016 Thomas Refis <trefis@janestreet.com>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 *)

(** Utilities to manipulate files and paths. *)

type file

type directory

module Directory : sig

  open Or_error

  type t = directory

  val dirname : t -> t
  val basename : t -> t

  val append : t -> t -> t

  val reach_from : dir:t -> string -> t
  (** raises [Invalid_arg _] if [parent/name] exists but is not a directory. *)

  val mkdir_p : t -> unit

  val of_string : string -> t
  val to_string : t -> string

  val fold_files_rec_result : ?ext:string ->
    ('a -> file -> ('a, msg) result) -> 'a -> t -> ('a, [> msg ]) result
  (** [fold_files_rec_result ~ext f acc d] recursively folds [f] over the files
      with extension matching [ext] (defaults to [""]) contained in [d]
      and its sub directories. Stop as soon as [f] returns [Error _]. *)

  module Table : Hashtbl.S with type key = t
end

module File : sig

  type t = file

  val create : directory:Directory.t -> name:string -> t

  val dirname : t -> Directory.t
  val basename : t -> t

  val set_ext : string -> t -> t
  val has_ext : string -> t -> bool

  val of_string : string -> t
  val to_string : t -> string

  val read : t -> (string, [> msg ]) result

  module Table : Hashtbl.S with type key = t
end