Import Upstream version 20180207
[hcoop/debian/mlton.git] / lib / mlton / basic / file.sig
1 (* Copyright (C) 1999-2005 Henry Cejtin, Matthew Fluet, Suresh
2 * Jagannathan, and Stephen Weeks.
3 *
4 * MLton is released under a BSD-style license.
5 * See the file MLton-LICENSE for details.
6 *)
7
8 signature FILE =
9 sig
10 type t = string
11 type dir = string
12 type file = string
13
14 val appendTo: t * string -> unit
15 val base: t -> string
16 val canRead: t -> bool
17 val canRun: t -> bool
18 val canWrite: t -> bool
19 val concat: t list * t -> unit
20 val contents: t -> string
21 val copy: t * t -> unit
22 val create: t -> unit (* make an empty file *)
23 val dirOf: t -> dir
24 val doesExist: t -> bool
25 val ensureRead: t -> unit
26 val ensureWrite: t -> unit
27 val extension: t -> string option
28 val fileOf: t -> file
29 (* Each line includes the newline. *)
30 val foldLines: t * 'a * (string * 'a -> 'a) -> 'a
31 val isNewer: t * t -> bool
32 val layout: t -> Layout.t
33 (* Each line includes the newline. *)
34 val lines: t -> string list
35 val modTime: t -> Time.t
36 val move: {from: t, to: t} -> unit
37 val output: t * Out.t -> unit
38 val outputContents: t * Out.t -> unit
39 val remove: t -> unit
40 val sameContents: t * t -> bool
41 val size: t -> Position.int
42 val suffix: t -> string option
43 val temp: {prefix: string, suffix: string} -> t * Out.t
44 val toString: t -> string
45 val withAppend: t * (Out.t -> 'a) -> 'a
46 val withIn: t * (In.t -> 'a) -> 'a
47 val withOut: t * (Out.t -> 'a) -> 'a
48 val withOutIn: (Out.t -> unit) * (In.t -> 'a) -> 'a
49 val withString: string * (t -> 'a) -> 'a
50 val withStringIn: string * (In.t -> 'a) -> 'a
51 val withTemp: (t -> 'a) -> 'a
52 val withTempOut: (Out.t -> unit) * (t -> 'a) -> 'a
53 val withTempOut':
54 {prefix: string, suffix: string} * (Out.t -> unit) * (t -> 'a) -> 'a
55 end