Import Upstream version 20180207
[hcoop/debian/mlton.git] / basis-library / posix / file-sys.sig
1 signature POSIX_FILE_SYS =
2 sig
3 eqtype uid
4 eqtype gid
5
6 eqtype file_desc
7 val fdToWord: file_desc -> SysWord.word
8 val wordToFD: SysWord.word -> file_desc
9
10 (* identity functions *)
11 val fdToIOD: file_desc -> OS.IO.iodesc
12 val iodToFD: OS.IO.iodesc -> file_desc option
13
14 type dirstream
15 val opendir: string -> dirstream
16 val readdir: dirstream -> string option
17 val rewinddir: dirstream -> unit
18 val closedir: dirstream -> unit
19
20 val chdir: string -> unit
21 val getcwd: unit -> string
22
23 val stdin: file_desc
24 val stdout: file_desc
25 val stderr: file_desc
26
27 structure S:
28 sig
29 eqtype mode
30 include BIT_FLAGS where type flags = mode
31
32 val irwxu: mode
33 val irusr: mode
34 val iwusr: mode
35 val ixusr: mode
36 val irwxg: mode
37 val irgrp: mode
38 val iwgrp: mode
39 val ixgrp: mode
40 val irwxo: mode
41 val iroth: mode
42 val iwoth: mode
43 val ixoth: mode
44 val isuid: mode
45 val isgid: mode
46 end
47
48 structure O:
49 sig
50 include BIT_FLAGS
51
52 val append: flags
53 val excl: flags
54 val noctty: flags
55 val nonblock: flags
56 val sync: flags
57 val trunc: flags
58 end
59
60 datatype open_mode = O_RDONLY | O_WRONLY | O_RDWR
61
62 val openf: string * open_mode * O.flags -> file_desc
63 val createf: string * open_mode * O.flags * S.mode -> file_desc
64 val creat: string * S.mode -> file_desc
65 val umask: S.mode -> S.mode
66 val link: {old: string, new: string} -> unit
67 val mkdir: string * S.mode -> unit
68 val mkfifo: string * S.mode -> unit
69 val unlink: string -> unit
70 val rmdir: string -> unit
71 val rename: {old: string, new: string} -> unit
72 val symlink: {old: string, new: string} -> unit
73 val readlink: string -> string
74
75 eqtype dev
76 val wordToDev: SysWord.word -> dev
77 val devToWord: dev -> SysWord.word
78
79 eqtype ino
80 val wordToIno: SysWord.word -> ino
81 val inoToWord: ino -> SysWord.word
82
83 structure ST:
84 sig
85 type stat
86
87 val isDir: stat -> bool
88 val isChr: stat -> bool
89 val isBlk: stat -> bool
90 val isReg: stat -> bool
91 val isFIFO: stat -> bool
92 val isLink: stat -> bool
93 val isSock: stat -> bool
94 val mode: stat -> S.mode
95 val ino: stat -> ino
96 val dev: stat -> dev
97 val nlink: stat -> int
98 val uid: stat -> uid
99 val gid: stat -> gid
100 val size: stat -> Position.int
101 val atime: stat -> Time.time
102 val mtime: stat -> Time.time
103 val ctime: stat -> Time.time
104 end
105
106 val stat: string -> ST.stat
107 val lstat: string -> ST.stat
108 val fstat: file_desc -> ST.stat
109
110 datatype access_mode = A_READ | A_WRITE | A_EXEC
111
112 val access: string * access_mode list -> bool
113 val chmod: string * S.mode -> unit
114 val fchmod: file_desc * S.mode -> unit
115 val chown: string * uid * gid -> unit
116 val fchown: file_desc * uid * gid -> unit
117 val utime: string * {actime: Time.time, modtime: Time.time} option -> unit
118 val ftruncate: file_desc * Position.int -> unit
119 val pathconf: string * string -> SysWord.word option
120 val fpathconf: file_desc * string -> SysWord.word option
121 end
122
123 signature POSIX_FILE_SYS_EXTRA =
124 sig
125 include POSIX_FILE_SYS
126
127 val flagsToOpenMode: O.flags -> open_mode
128 end