Import Upstream version 20180207
[hcoop/debian/mlton.git] / doc / guide / src / MLtonIO.adoc
1 MLtonIO
2 =======
3
4 [source,sml]
5 ----
6 signature MLTON_IO =
7 sig
8 type instream
9 type outstream
10
11 val inFd: instream -> Posix.IO.file_desc
12 val mkstemp: string -> string * outstream
13 val mkstemps: {prefix: string, suffix: string} -> string * outstream
14 val newIn: Posix.IO.file_desc * string -> instream
15 val newOut: Posix.IO.file_desc * string -> outstream
16 val outFd: outstream -> Posix.IO.file_desc
17 val tempPrefix: string -> string
18 end
19 ----
20
21 * `inFd ins`
22 +
23 returns the file descriptor corresponding to `ins`.
24
25 * `mkstemp s`
26 +
27 like the C `mkstemp` function, generates and open a temporary file
28 with prefix `s`.
29
30 * `mkstemps {prefix, suffix}`
31 +
32 like `mkstemp`, except it has both a prefix and suffix.
33
34 * `newIn (fd, name)`
35 +
36 creates a new instream from file descriptor `fd`, with `name` used in
37 any `Io` exceptions later raised.
38
39 * `newOut (fd, name)`
40 +
41 creates a new outstream from file descriptor `fd`, with `name` used in
42 any `Io` exceptions later raised.
43
44 * `outFd out`
45 +
46 returns the file descriptor corresponding to `out`.
47
48 * `tempPrefix s`
49 +
50 adds a suitable system or user specific prefix (directory) for temp
51 files.