Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 188 lines (129 sloc) 5.12 kb
aa67aa9 @samoht Big refactoring work.
samoht authored
1 (***********************************************************************)
2 (* *)
3 (* Copyright 2012 OCamlPro *)
4 (* Copyright 2012 INRIA *)
5 (* *)
6 (* All rights reserved. This file is distributed under the terms of *)
7 (* the GNU Public License version 3.0. *)
8 (* *)
9 (* OPAM is distributed in the hope that it will be useful, *)
10 (* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
11 (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
12 (* GNU General Public License for more details. *)
13 (* *)
14 (***********************************************************************)
15
16 (** Typed filename manipulation *)
17
18 (** Basenames *)
19 module Base: OpamMisc.ABSTRACT
20
21 (** Directory names *)
22 module Dir: OpamMisc.ABSTRACT
23
24 (** Return the current working directory *)
25 val cwd: unit -> Dir.t
26
27 (** Remove a directory *)
28 val rmdir: Dir.t -> unit
29
30 (** Create a directory *)
31 val mkdir: Dir.t -> unit
32
33 (** List the sub-directory *)
34 val list_dirs: Dir.t -> Dir.t list
35
36 (** Evaluate a function in a given directory *)
37 val in_dir: Dir.t -> (unit -> 'a) -> 'a
38
39 (** Execute a list of commands in a given directory *)
40 val exec: Dir.t
41 -> ?add_to_env:(string * string) list
42 -> ?add_to_path:Dir.t list -> string list list -> unit
43
44 (** Move a directory *)
45 val move_dir: Dir.t -> Dir.t -> unit
46
47 (** Copy a directory *)
48 val copy_dir: Dir.t -> Dir.t -> unit
49
50 (** Link a directory *)
51 val link_dir: Dir.t -> Dir.t -> unit
52
53 (** Does the directory exists ? *)
54 val exists_dir: Dir.t -> bool
55
56 (** Return the parent directory *)
57 val dirname_dir: Dir.t -> Dir.t
58
59 (** Return the deeper directory name *)
60 val basename_dir: Dir.t -> Base.t
61
62 (** Creation from a raw string (as {i http://<path>}) *)
63 val raw_dir: string -> Dir.t
64
65 (** Execute a function in a temp directory *)
66 val with_tmp_dir: (Dir.t -> 'a) -> 'a
67
68 include OpamMisc.ABSTRACT
69
70 (** Create a filename from a Dir.t and a basename *)
71 val create: Dir.t -> Base.t -> t
72
73 (** Create a file from a basename and the current working directory
74 as dirname *)
75 val of_basename: Base.t -> t
76
77 (** Creation from a raw string (as {i http://<path>}) *)
78 val raw_file: string -> t
79
80 (** Return the directory name *)
81 val dirname: t -> Dir.t
82
83 (** Return the base name *)
84 val basename: t -> Base.t
85
86 (** Retrieves the contents from the hard disk. *)
87 val read: t -> string
88
89 (** Removes everything in [filename] if existed. *)
90 val remove: t -> unit
91
92 (** Removes everything in [filename] if existed, then write [contents] instead. *)
93 val write: t -> string -> unit
94
95 (** see [Sys.file_exists] *)
96 val exists: t -> bool
97
98 (** Check whether a file has a given suffix *)
99 val check_suffix: t -> string -> bool
100
101 (** Add a file extension *)
102 val add_extension: t -> string -> t
103
104 (** Remove the file extension *)
105 val chop_extension: t -> t
106
107 (** List all the filenames, recursively *)
108 val list_files: Dir.t -> t list
109
110 (** Apply a function on the contents of a file *)
111 val with_contents: (string -> 'a) -> t -> 'a
112
113 (** Copy a file in a directory *)
114 val copy_in: t -> Dir.t -> unit
115
116 (** Move a file *)
117 val move: t -> t -> unit
118
119 (** Symlink a file in a directory *)
120 val link_in: t -> Dir.t -> unit
121
122 (** Copy a file *)
123 val copy: t -> t -> unit
124
125 (** Symlink a file. If symlink is not possible on the system, use copy instead. *)
126 val link: t -> t -> unit
127
128 (** Extract an archive in a given directory (it rewrites the root to
129 match [Dir.t] dir if needed) *)
130 val extract: t -> Dir.t -> unit
131
132 (** Extract an archive in a given directory (which should already exists) *)
133 val extract_in: t -> Dir.t -> unit
134
135 (** Check wether a filename starts by a given Dir.t *)
136 val starts_with: Dir.t -> t -> bool
137
138 (** Remove a prefix from a file name *)
139 val remove_prefix: prefix:Dir.t -> t -> string
140
141 (** download a remote file in a given directory. Return the location
142 of the downloaded file if the download is successful. *)
143 val download: t -> Dir.t -> t
144
145 (** iterate downloads until one is sucessful *)
146 val download_iter: t list -> Dir.t -> t
147
148 (** Apply a patch to a directory *)
149 val patch: t -> Dir.t -> unit
150
151 (** Compute the MD5 digest of a file *)
152 val digest: t -> string
153
154 (** Create an empty file *)
155 val touch: t -> unit
156
157 (** Change file permissions *)
158 val chmod: t -> int -> unit
159
160 module OP: sig
161
162 (** Create a new directory *)
163 val (/): Dir.t -> string -> Dir.t
164
165 (** Create a new filename *)
166 val (//): Dir.t -> string -> t
167
168 end
169
170 (** Simple structure to hanle file attributes *)
171 module Attribute: sig
172
173 include OpamMisc.ABSTRACT
174
175 (** Get remote filename *)
176 val base: t -> Base.t
177
178 (** MD5 digest of the remote file *)
179 val md5: t -> string
180
181 (** File permission *)
182 val perm: t -> int option
183
184 (** Constructor*)
185 val create: Base.t -> string -> int -> t
186
187 end
Something went wrong with that request. Please try again.