@grain/stdlib 0.5.13 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +193 -0
- package/LICENSE +1 -1
- package/README.md +25 -2
- package/array.gr +1512 -199
- package/array.md +2032 -94
- package/bigint.gr +239 -140
- package/bigint.md +450 -106
- package/buffer.gr +595 -102
- package/buffer.md +903 -145
- package/bytes.gr +401 -110
- package/bytes.md +551 -63
- package/char.gr +228 -49
- package/char.md +373 -7
- package/exception.gr +26 -12
- package/exception.md +29 -5
- package/float32.gr +130 -109
- package/float32.md +185 -57
- package/float64.gr +112 -99
- package/float64.md +185 -57
- package/hash.gr +47 -37
- package/hash.md +21 -3
- package/int16.gr +430 -0
- package/int16.md +618 -0
- package/int32.gr +200 -269
- package/int32.md +254 -289
- package/int64.gr +142 -225
- package/int64.md +254 -289
- package/int8.gr +511 -0
- package/int8.md +786 -0
- package/json.gr +2084 -0
- package/json.md +608 -0
- package/list.gr +120 -68
- package/list.md +125 -80
- package/map.gr +560 -57
- package/map.md +672 -56
- package/marshal.gr +239 -227
- package/marshal.md +36 -4
- package/number.gr +626 -676
- package/number.md +738 -153
- package/option.gr +33 -35
- package/option.md +58 -42
- package/package.json +2 -2
- package/path.gr +148 -187
- package/path.md +47 -96
- package/pervasives.gr +75 -416
- package/pervasives.md +85 -180
- package/priorityqueue.gr +433 -74
- package/priorityqueue.md +422 -54
- package/queue.gr +362 -80
- package/queue.md +433 -38
- package/random.gr +67 -75
- package/random.md +68 -40
- package/range.gr +135 -63
- package/range.md +198 -43
- package/rational.gr +284 -0
- package/rational.md +545 -0
- package/regex.gr +933 -1066
- package/regex.md +59 -60
- package/result.gr +23 -25
- package/result.md +54 -39
- package/runtime/atof/common.gr +78 -82
- package/runtime/atof/common.md +22 -10
- package/runtime/atof/decimal.gr +102 -127
- package/runtime/atof/decimal.md +28 -7
- package/runtime/atof/lemire.gr +56 -71
- package/runtime/atof/lemire.md +9 -1
- package/runtime/atof/parse.gr +83 -110
- package/runtime/atof/parse.md +12 -2
- package/runtime/atof/slow.gr +28 -35
- package/runtime/atof/slow.md +9 -1
- package/runtime/atof/table.gr +19 -18
- package/runtime/atof/table.md +10 -2
- package/runtime/atoi/parse.gr +153 -136
- package/runtime/atoi/parse.md +50 -1
- package/runtime/bigint.gr +410 -517
- package/runtime/bigint.md +71 -57
- package/runtime/compare.gr +176 -85
- package/runtime/compare.md +31 -1
- package/runtime/dataStructures.gr +144 -32
- package/runtime/dataStructures.md +267 -31
- package/runtime/debugPrint.gr +34 -15
- package/runtime/debugPrint.md +37 -5
- package/runtime/equal.gr +53 -52
- package/runtime/equal.md +30 -1
- package/runtime/exception.gr +38 -47
- package/runtime/exception.md +10 -8
- package/runtime/gc.gr +23 -152
- package/runtime/gc.md +13 -17
- package/runtime/malloc.gr +31 -31
- package/runtime/malloc.md +11 -3
- package/runtime/numberUtils.gr +191 -172
- package/runtime/numberUtils.md +17 -9
- package/runtime/numbers.gr +1695 -1021
- package/runtime/numbers.md +1098 -134
- package/runtime/string.gr +540 -242
- package/runtime/string.md +76 -6
- package/runtime/unsafe/constants.gr +30 -13
- package/runtime/unsafe/constants.md +80 -0
- package/runtime/unsafe/conv.gr +55 -28
- package/runtime/unsafe/conv.md +41 -9
- package/runtime/unsafe/memory.gr +10 -30
- package/runtime/unsafe/memory.md +15 -19
- package/runtime/unsafe/tags.gr +37 -21
- package/runtime/unsafe/tags.md +88 -8
- package/runtime/unsafe/wasmf32.gr +30 -36
- package/runtime/unsafe/wasmf32.md +64 -56
- package/runtime/unsafe/wasmf64.gr +30 -36
- package/runtime/unsafe/wasmf64.md +64 -56
- package/runtime/unsafe/wasmi32.gr +49 -66
- package/runtime/unsafe/wasmi32.md +102 -94
- package/runtime/unsafe/wasmi64.gr +52 -79
- package/runtime/unsafe/wasmi64.md +108 -100
- package/runtime/utils/printing.gr +13 -15
- package/runtime/utils/printing.md +11 -3
- package/runtime/wasi.gr +294 -295
- package/runtime/wasi.md +62 -42
- package/set.gr +574 -64
- package/set.md +634 -54
- package/stack.gr +181 -64
- package/stack.md +271 -42
- package/string.gr +453 -533
- package/string.md +241 -151
- package/uint16.gr +369 -0
- package/uint16.md +585 -0
- package/uint32.gr +470 -0
- package/uint32.md +737 -0
- package/uint64.gr +471 -0
- package/uint64.md +737 -0
- package/uint8.gr +369 -0
- package/uint8.md +585 -0
- package/uri.gr +1093 -0
- package/uri.md +477 -0
- package/{sys → wasi}/file.gr +914 -500
- package/{sys → wasi}/file.md +454 -50
- package/wasi/process.gr +292 -0
- package/{sys → wasi}/process.md +164 -6
- package/wasi/random.gr +77 -0
- package/wasi/random.md +80 -0
- package/{sys → wasi}/time.gr +15 -22
- package/{sys → wasi}/time.md +5 -5
- package/immutablearray.gr +0 -929
- package/immutablearray.md +0 -1038
- package/immutablemap.gr +0 -493
- package/immutablemap.md +0 -479
- package/immutablepriorityqueue.gr +0 -360
- package/immutablepriorityqueue.md +0 -291
- package/immutableset.gr +0 -498
- package/immutableset.md +0 -449
- package/runtime/debug.gr +0 -2
- package/runtime/debug.md +0 -6
- package/runtime/unsafe/errors.gr +0 -36
- package/runtime/unsafe/errors.md +0 -204
- package/sys/process.gr +0 -254
- package/sys/random.gr +0 -79
- package/sys/random.md +0 -66
package/{sys → wasi}/file.md
RENAMED
|
@@ -7,7 +7,7 @@ Utilities for accessing the filesystem & working with files.
|
|
|
7
7
|
Many of the functions in this module are not intended to be used directly, but rather for other libraries to be built on top of them.
|
|
8
8
|
|
|
9
9
|
```grain
|
|
10
|
-
|
|
10
|
+
from "wasi/file" include File
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## Types
|
|
@@ -34,6 +34,14 @@ enum LookupFlag {
|
|
|
34
34
|
|
|
35
35
|
Flags that determine how paths should be resolved when looking up a file or directory.
|
|
36
36
|
|
|
37
|
+
Variants:
|
|
38
|
+
|
|
39
|
+
```grain
|
|
40
|
+
SymlinkFollow
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Follow symlinks
|
|
44
|
+
|
|
37
45
|
### File.**OpenFlag**
|
|
38
46
|
|
|
39
47
|
```grain
|
|
@@ -47,6 +55,32 @@ enum OpenFlag {
|
|
|
47
55
|
|
|
48
56
|
Flags that determine how a file or directory should be opened.
|
|
49
57
|
|
|
58
|
+
Variants:
|
|
59
|
+
|
|
60
|
+
```grain
|
|
61
|
+
Create
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Create file if it does not exist.
|
|
65
|
+
|
|
66
|
+
```grain
|
|
67
|
+
Directory
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Fail if not a directory.
|
|
71
|
+
|
|
72
|
+
```grain
|
|
73
|
+
Exclusive
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Fail if file already exists.
|
|
77
|
+
|
|
78
|
+
```grain
|
|
79
|
+
Truncate
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Truncate file to size 0.
|
|
83
|
+
|
|
50
84
|
### File.**Rights**
|
|
51
85
|
|
|
52
86
|
```grain
|
|
@@ -86,6 +120,194 @@ enum Rights {
|
|
|
86
120
|
Flags that determine which rights a `FileDescriptor` should have
|
|
87
121
|
and which rights new `FileDescriptor`s should inherit from it.
|
|
88
122
|
|
|
123
|
+
Variants:
|
|
124
|
+
|
|
125
|
+
```grain
|
|
126
|
+
FdDatasync
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The right to invoke `fdDatasync`.
|
|
130
|
+
If `PathOpen` is set, includes the right to invoke
|
|
131
|
+
`pathOpen` with `FdFlag::Dsync`.
|
|
132
|
+
|
|
133
|
+
```grain
|
|
134
|
+
FdRead
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
The right to invoke `fdRead`.
|
|
138
|
+
If `Rights::FdSeek` is set, includes the right to invoke `fdPread`.
|
|
139
|
+
|
|
140
|
+
```grain
|
|
141
|
+
FdSeek
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
The right to invoke `fdSeek`. This flag implies `Rights::FdTell`.
|
|
145
|
+
|
|
146
|
+
```grain
|
|
147
|
+
FdSetFlags
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
The right to invoke `fdSetFlags`.
|
|
151
|
+
|
|
152
|
+
```grain
|
|
153
|
+
FdSync
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
The right to invoke `fdSync`.
|
|
157
|
+
If `PathOpen` is set, includes the right to invoke
|
|
158
|
+
`pathOpen` with `FdFlag::Rsync` and `FdFlag::Dsync`.
|
|
159
|
+
|
|
160
|
+
```grain
|
|
161
|
+
FdTell
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
The right to invoke `fdSeek` in such a way that the file offset
|
|
165
|
+
remains unaltered (i.e., `Whence::Current` with offset zero), or to
|
|
166
|
+
invoke `fdTell`.
|
|
167
|
+
|
|
168
|
+
```grain
|
|
169
|
+
FdWrite
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
The right to invoke `fdWrite`.
|
|
173
|
+
If `Rights::FdSeek` is set, includes the right to invoke `fdPwrite`.
|
|
174
|
+
|
|
175
|
+
```grain
|
|
176
|
+
FdAdvise
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
The right to invoke `fdAdvise`.
|
|
180
|
+
|
|
181
|
+
```grain
|
|
182
|
+
FdAllocate
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
The right to invoke `fdAllocate`.
|
|
186
|
+
|
|
187
|
+
```grain
|
|
188
|
+
PathCreateDirectory
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
The right to invoke `pathCreateDirectory`.
|
|
192
|
+
|
|
193
|
+
```grain
|
|
194
|
+
PathCreateFile
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
If `PathOpen` is set, the right to invoke `pathOpen` with `OpenFlag::Create`.
|
|
198
|
+
|
|
199
|
+
```grain
|
|
200
|
+
PathLinkSource
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
The right to invoke `pathLink` with the file descriptor as the
|
|
204
|
+
source directory.
|
|
205
|
+
|
|
206
|
+
```grain
|
|
207
|
+
PathLinkTarget
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
The right to invoke `pathLink` with the file descriptor as the
|
|
211
|
+
target directory.
|
|
212
|
+
|
|
213
|
+
```grain
|
|
214
|
+
PathOpen
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
The right to invoke `pathOpen`.
|
|
218
|
+
|
|
219
|
+
```grain
|
|
220
|
+
FdReaddir
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
The right to invoke `fdReaddir`.
|
|
224
|
+
|
|
225
|
+
```grain
|
|
226
|
+
PathReadlink
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
The right to invoke `pathReadlink`.
|
|
230
|
+
|
|
231
|
+
```grain
|
|
232
|
+
PathRenameSource
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
The right to invoke `pathRename` with the file descriptor as the source directory.
|
|
236
|
+
|
|
237
|
+
```grain
|
|
238
|
+
PathRenameTarget
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
The right to invoke `pathRename` with the file descriptor as the target directory.
|
|
242
|
+
|
|
243
|
+
```grain
|
|
244
|
+
PathFilestats
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
The right to invoke `pathFilestats`.
|
|
248
|
+
|
|
249
|
+
```grain
|
|
250
|
+
PathSetSize
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
The right to change a file's size (there's no `pathSetSize`).
|
|
254
|
+
If `PathOpen` is set, includes the right to invoke `pathOpen` with `OpenFlag::Truncate`.
|
|
255
|
+
|
|
256
|
+
```grain
|
|
257
|
+
PathSetTimes
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
The right to invoke `pathSetAccessTime`, `pathSetAccessTimeNow`, `pathSetModifiedTime`, or `pathSetModifiedTimeNow`.
|
|
261
|
+
|
|
262
|
+
```grain
|
|
263
|
+
FdFilestats
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
The right to invoke `fdFilestats`.
|
|
267
|
+
|
|
268
|
+
```grain
|
|
269
|
+
FdSetSize
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
The right to invoke `fdSetSize`.
|
|
273
|
+
|
|
274
|
+
```grain
|
|
275
|
+
FdSetTimes
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
The right to invoke `fdSetAccessTime`, `fdSetAccessTimeNow`, `fdSetModifiedTime`, or `fdSetModifiedTimeNow`.
|
|
279
|
+
|
|
280
|
+
```grain
|
|
281
|
+
PathSymlink
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
The right to invoke `pathSymlink`.
|
|
285
|
+
|
|
286
|
+
```grain
|
|
287
|
+
PathRemoveDirectory
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
The right to invoke `pathRemoveDirectory`.
|
|
291
|
+
|
|
292
|
+
```grain
|
|
293
|
+
PathUnlinkFile
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
The right to invoke `pathUnlinkFile`.
|
|
297
|
+
|
|
298
|
+
```grain
|
|
299
|
+
PollFdReadwrite
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
If `Rights::FdRead` is set, includes the right to invoke `pollOneoff` (not yet implemented) to subscribe to `EventType::FdRead`.
|
|
303
|
+
If `Rights::FdWrite` is set, includes the right to invoke `pollOneoff` (not yet implemented) to subscribe to `EventType::FdWrite`.
|
|
304
|
+
|
|
305
|
+
```grain
|
|
306
|
+
SockShutdown
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
The right to invoke `sockShutdown` (not yet implemented).
|
|
310
|
+
|
|
89
311
|
### File.**FdFlag**
|
|
90
312
|
|
|
91
313
|
```grain
|
|
@@ -100,6 +322,32 @@ enum FdFlag {
|
|
|
100
322
|
|
|
101
323
|
Flags that determine the mode(s) that a `FileDescriptor` operates in.
|
|
102
324
|
|
|
325
|
+
Variants:
|
|
326
|
+
|
|
327
|
+
```grain
|
|
328
|
+
Append
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
Append mode: Data written to the file is always appended to the file's end.
|
|
332
|
+
|
|
333
|
+
```grain
|
|
334
|
+
Dsync
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized.
|
|
338
|
+
|
|
339
|
+
```grain
|
|
340
|
+
Nonblock
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
Non-blocking mode.
|
|
344
|
+
|
|
345
|
+
```grain
|
|
346
|
+
Rsync
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
Synchronized read I/O operations.
|
|
350
|
+
|
|
103
351
|
### File.**Filetype**
|
|
104
352
|
|
|
105
353
|
```grain
|
|
@@ -117,6 +365,56 @@ enum Filetype {
|
|
|
117
365
|
|
|
118
366
|
The type of file a `FileDescriptor` refers to.
|
|
119
367
|
|
|
368
|
+
Variants:
|
|
369
|
+
|
|
370
|
+
```grain
|
|
371
|
+
Unknown
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
The type of the file descriptor or file is unknown or is different from any of the other types specified.
|
|
375
|
+
|
|
376
|
+
```grain
|
|
377
|
+
BlockDevice
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
The file descriptor or file refers to a block device inode.
|
|
381
|
+
|
|
382
|
+
```grain
|
|
383
|
+
CharacterDevice
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
The file descriptor or file refers to a character device inode.
|
|
387
|
+
|
|
388
|
+
```grain
|
|
389
|
+
Directory
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
The file descriptor or file refers to a directory inode.
|
|
393
|
+
|
|
394
|
+
```grain
|
|
395
|
+
RegularFile
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
The file descriptor or file refers to a regular file inode.
|
|
399
|
+
|
|
400
|
+
```grain
|
|
401
|
+
SocketDatagram
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
The file descriptor or file refers to a datagram socket.
|
|
405
|
+
|
|
406
|
+
```grain
|
|
407
|
+
SocketStream
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
The file descriptor or file refers to a byte-stream socket.
|
|
411
|
+
|
|
412
|
+
```grain
|
|
413
|
+
SymbolicLink
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
The file refers to a symbolic link inode.
|
|
417
|
+
|
|
120
418
|
### File.**Whence**
|
|
121
419
|
|
|
122
420
|
```grain
|
|
@@ -129,6 +427,26 @@ enum Whence {
|
|
|
129
427
|
|
|
130
428
|
Flags that determine where seeking should begin in a file.
|
|
131
429
|
|
|
430
|
+
Variants:
|
|
431
|
+
|
|
432
|
+
```grain
|
|
433
|
+
Set
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
Seek relative to start-of-file.
|
|
437
|
+
|
|
438
|
+
```grain
|
|
439
|
+
Current
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
Seek relative to current position.
|
|
443
|
+
|
|
444
|
+
```grain
|
|
445
|
+
End
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
Seek relative to end-of-file.
|
|
449
|
+
|
|
132
450
|
### File.**Stats**
|
|
133
451
|
|
|
134
452
|
```grain
|
|
@@ -171,6 +489,19 @@ record DirectoryEntry {
|
|
|
171
489
|
|
|
172
490
|
An entry in a directory.
|
|
173
491
|
|
|
492
|
+
### File.**Prestat**
|
|
493
|
+
|
|
494
|
+
```grain
|
|
495
|
+
enum Prestat {
|
|
496
|
+
Dir{
|
|
497
|
+
prefix: String,
|
|
498
|
+
fd: FileDescriptor,
|
|
499
|
+
},
|
|
500
|
+
}
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
Information about a preopened directory
|
|
504
|
+
|
|
174
505
|
## Values
|
|
175
506
|
|
|
176
507
|
Functions and constants included in the File module.
|
|
@@ -199,20 +530,14 @@ stderr : FileDescriptor
|
|
|
199
530
|
|
|
200
531
|
The `FileDescriptor` for `stderr`.
|
|
201
532
|
|
|
202
|
-
### File.**pwdfd**
|
|
203
|
-
|
|
204
|
-
```grain
|
|
205
|
-
pwdfd : FileDescriptor
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
The `FileDescriptor` for the current working directory of the process.
|
|
209
|
-
|
|
210
533
|
### File.**pathOpen**
|
|
211
534
|
|
|
212
535
|
```grain
|
|
213
536
|
pathOpen :
|
|
214
|
-
(FileDescriptor, List<LookupFlag>, String,
|
|
215
|
-
List<
|
|
537
|
+
(dirFd: FileDescriptor, dirFlags: List<LookupFlag>, path: String,
|
|
538
|
+
openFlags: List<OpenFlag>, rights: List<Rights>,
|
|
539
|
+
rightsInheriting: List<Rights>, flags: List<FdFlag>) =>
|
|
540
|
+
Result<FileDescriptor, Exception>
|
|
216
541
|
```
|
|
217
542
|
|
|
218
543
|
Open a file or directory.
|
|
@@ -238,7 +563,8 @@ Returns:
|
|
|
238
563
|
### File.**fdRead**
|
|
239
564
|
|
|
240
565
|
```grain
|
|
241
|
-
fdRead :
|
|
566
|
+
fdRead :
|
|
567
|
+
(fd: FileDescriptor, size: Number) => Result<(Bytes, Number), Exception>
|
|
242
568
|
```
|
|
243
569
|
|
|
244
570
|
Read from a file descriptor.
|
|
@@ -254,13 +580,14 @@ Returns:
|
|
|
254
580
|
|
|
255
581
|
|type|description|
|
|
256
582
|
|----|-----------|
|
|
257
|
-
|`Result<(
|
|
583
|
+
|`Result<(Bytes, Number), Exception>`|`Ok((contents, numBytes))` of bytes read and the number of bytes read if successful or `Err(exception)` otherwise|
|
|
258
584
|
|
|
259
585
|
### File.**fdPread**
|
|
260
586
|
|
|
261
587
|
```grain
|
|
262
588
|
fdPread :
|
|
263
|
-
(FileDescriptor, Int64,
|
|
589
|
+
(fd: FileDescriptor, offset: Int64, size: Number) =>
|
|
590
|
+
Result<(Bytes, Number), Exception>
|
|
264
591
|
```
|
|
265
592
|
|
|
266
593
|
Read from a file descriptor without updating the file descriptor's offset.
|
|
@@ -277,12 +604,37 @@ Returns:
|
|
|
277
604
|
|
|
278
605
|
|type|description|
|
|
279
606
|
|----|-----------|
|
|
280
|
-
|`Result<(
|
|
607
|
+
|`Result<(Bytes, Number), Exception>`|`Ok((contents, numBytes))` of bytes read and the number of bytes read if successful or `Err(exception)` otherwise|
|
|
608
|
+
|
|
609
|
+
### File.**fdPrestatGet**
|
|
610
|
+
|
|
611
|
+
<details disabled>
|
|
612
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
613
|
+
No other changes yet.
|
|
614
|
+
</details>
|
|
615
|
+
|
|
616
|
+
```grain
|
|
617
|
+
fdPrestatGet : (fd: FileDescriptor) => Result<Prestat, Exception>
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
Get information about a preopened directory.
|
|
621
|
+
|
|
622
|
+
Parameters:
|
|
623
|
+
|
|
624
|
+
|param|type|description|
|
|
625
|
+
|-----|----|-----------|
|
|
626
|
+
|`fd`|`FileDescriptor`|The file descriptor to check|
|
|
627
|
+
|
|
628
|
+
Returns:
|
|
629
|
+
|
|
630
|
+
|type|description|
|
|
631
|
+
|----|-----------|
|
|
632
|
+
|`Result<Prestat, Exception>`|`Ok(Dir{prefix, fd})` if successful or `Err(exception)` otherwise|
|
|
281
633
|
|
|
282
634
|
### File.**fdWrite**
|
|
283
635
|
|
|
284
636
|
```grain
|
|
285
|
-
fdWrite : (FileDescriptor,
|
|
637
|
+
fdWrite : (fd: FileDescriptor, data: Bytes) => Result<Number, Exception>
|
|
286
638
|
```
|
|
287
639
|
|
|
288
640
|
Write to a file descriptor.
|
|
@@ -292,7 +644,7 @@ Parameters:
|
|
|
292
644
|
|param|type|description|
|
|
293
645
|
|-----|----|-----------|
|
|
294
646
|
|`fd`|`FileDescriptor`|The file descriptor to which data will be written|
|
|
295
|
-
|`data`|`
|
|
647
|
+
|`data`|`Bytes`|The data to be written|
|
|
296
648
|
|
|
297
649
|
Returns:
|
|
298
650
|
|
|
@@ -303,7 +655,9 @@ Returns:
|
|
|
303
655
|
### File.**fdPwrite**
|
|
304
656
|
|
|
305
657
|
```grain
|
|
306
|
-
fdPwrite :
|
|
658
|
+
fdPwrite :
|
|
659
|
+
(fd: FileDescriptor, data: Bytes, offset: Int64) =>
|
|
660
|
+
Result<Number, Exception>
|
|
307
661
|
```
|
|
308
662
|
|
|
309
663
|
Write to a file descriptor without updating the file descriptor's offset.
|
|
@@ -313,7 +667,7 @@ Parameters:
|
|
|
313
667
|
|param|type|description|
|
|
314
668
|
|-----|----|-----------|
|
|
315
669
|
|`fd`|`FileDescriptor`|The file descriptor to which data will be written|
|
|
316
|
-
|`data`|`
|
|
670
|
+
|`data`|`Bytes`|The data to be written|
|
|
317
671
|
|`offset`|`Int64`|The position within the file to begin writing|
|
|
318
672
|
|
|
319
673
|
Returns:
|
|
@@ -325,7 +679,8 @@ Returns:
|
|
|
325
679
|
### File.**fdAllocate**
|
|
326
680
|
|
|
327
681
|
```grain
|
|
328
|
-
fdAllocate :
|
|
682
|
+
fdAllocate :
|
|
683
|
+
(fd: FileDescriptor, offset: Int64, size: Int64) => Result<Void, Exception>
|
|
329
684
|
```
|
|
330
685
|
|
|
331
686
|
Allocate space within a file.
|
|
@@ -347,7 +702,7 @@ Returns:
|
|
|
347
702
|
### File.**fdClose**
|
|
348
703
|
|
|
349
704
|
```grain
|
|
350
|
-
fdClose : FileDescriptor
|
|
705
|
+
fdClose : (fd: FileDescriptor) => Result<Void, Exception>
|
|
351
706
|
```
|
|
352
707
|
|
|
353
708
|
Close a file descriptor.
|
|
@@ -367,7 +722,7 @@ Returns:
|
|
|
367
722
|
### File.**fdDatasync**
|
|
368
723
|
|
|
369
724
|
```grain
|
|
370
|
-
fdDatasync : FileDescriptor
|
|
725
|
+
fdDatasync : (fd: FileDescriptor) => Result<Void, Exception>
|
|
371
726
|
```
|
|
372
727
|
|
|
373
728
|
Synchronize the data of a file to disk.
|
|
@@ -387,7 +742,7 @@ Returns:
|
|
|
387
742
|
### File.**fdSync**
|
|
388
743
|
|
|
389
744
|
```grain
|
|
390
|
-
fdSync : FileDescriptor
|
|
745
|
+
fdSync : (fd: FileDescriptor) => Result<Void, Exception>
|
|
391
746
|
```
|
|
392
747
|
|
|
393
748
|
Synchronize the data and metadata of a file to disk.
|
|
@@ -407,7 +762,7 @@ Returns:
|
|
|
407
762
|
### File.**fdStats**
|
|
408
763
|
|
|
409
764
|
```grain
|
|
410
|
-
fdStats : FileDescriptor
|
|
765
|
+
fdStats : (fd: FileDescriptor) => Result<Stats, Exception>
|
|
411
766
|
```
|
|
412
767
|
|
|
413
768
|
Retrieve information about a file descriptor.
|
|
@@ -427,7 +782,8 @@ Returns:
|
|
|
427
782
|
### File.**fdSetFlags**
|
|
428
783
|
|
|
429
784
|
```grain
|
|
430
|
-
fdSetFlags :
|
|
785
|
+
fdSetFlags :
|
|
786
|
+
(fd: FileDescriptor, flags: List<FdFlag>) => Result<Void, Exception>
|
|
431
787
|
```
|
|
432
788
|
|
|
433
789
|
Update the flags associated with a file descriptor.
|
|
@@ -449,7 +805,8 @@ Returns:
|
|
|
449
805
|
|
|
450
806
|
```grain
|
|
451
807
|
fdSetRights :
|
|
452
|
-
(FileDescriptor, List<Rights>, List<Rights>)
|
|
808
|
+
(fd: FileDescriptor, rights: List<Rights>, rightsInheriting: List<Rights>) =>
|
|
809
|
+
Result<Void, Exception>
|
|
453
810
|
```
|
|
454
811
|
|
|
455
812
|
Update the rights associated with a file descriptor.
|
|
@@ -471,7 +828,7 @@ Returns:
|
|
|
471
828
|
### File.**fdFilestats**
|
|
472
829
|
|
|
473
830
|
```grain
|
|
474
|
-
fdFilestats : FileDescriptor
|
|
831
|
+
fdFilestats : (fd: FileDescriptor) => Result<Filestats, Exception>
|
|
475
832
|
```
|
|
476
833
|
|
|
477
834
|
Retrieve information about a file.
|
|
@@ -491,7 +848,7 @@ Returns:
|
|
|
491
848
|
### File.**fdSetSize**
|
|
492
849
|
|
|
493
850
|
```grain
|
|
494
|
-
fdSetSize : (FileDescriptor, Int64)
|
|
851
|
+
fdSetSize : (fd: FileDescriptor, size: Int64) => Result<Void, Exception>
|
|
495
852
|
```
|
|
496
853
|
|
|
497
854
|
Set (truncate) the size of a file.
|
|
@@ -512,7 +869,8 @@ Returns:
|
|
|
512
869
|
### File.**fdSetAccessTime**
|
|
513
870
|
|
|
514
871
|
```grain
|
|
515
|
-
fdSetAccessTime :
|
|
872
|
+
fdSetAccessTime :
|
|
873
|
+
(fd: FileDescriptor, timestamp: Int64) => Result<Void, Exception>
|
|
516
874
|
```
|
|
517
875
|
|
|
518
876
|
Set the access (created) time of a file.
|
|
@@ -533,7 +891,7 @@ Returns:
|
|
|
533
891
|
### File.**fdSetAccessTimeNow**
|
|
534
892
|
|
|
535
893
|
```grain
|
|
536
|
-
fdSetAccessTimeNow : FileDescriptor
|
|
894
|
+
fdSetAccessTimeNow : (fd: FileDescriptor) => Result<Void, Exception>
|
|
537
895
|
```
|
|
538
896
|
|
|
539
897
|
Set the access (created) time of a file to the current time.
|
|
@@ -553,7 +911,8 @@ Returns:
|
|
|
553
911
|
### File.**fdSetModifiedTime**
|
|
554
912
|
|
|
555
913
|
```grain
|
|
556
|
-
fdSetModifiedTime :
|
|
914
|
+
fdSetModifiedTime :
|
|
915
|
+
(fd: FileDescriptor, timestamp: Int64) => Result<Void, Exception>
|
|
557
916
|
```
|
|
558
917
|
|
|
559
918
|
Set the modified time of a file.
|
|
@@ -574,7 +933,7 @@ Returns:
|
|
|
574
933
|
### File.**fdSetModifiedTimeNow**
|
|
575
934
|
|
|
576
935
|
```grain
|
|
577
|
-
fdSetModifiedTimeNow : FileDescriptor
|
|
936
|
+
fdSetModifiedTimeNow : (fd: FileDescriptor) => Result<Void, Exception>
|
|
578
937
|
```
|
|
579
938
|
|
|
580
939
|
Set the modified time of a file to the current time.
|
|
@@ -594,7 +953,7 @@ Returns:
|
|
|
594
953
|
### File.**fdReaddir**
|
|
595
954
|
|
|
596
955
|
```grain
|
|
597
|
-
fdReaddir : FileDescriptor
|
|
956
|
+
fdReaddir : (fd: FileDescriptor) => Result<Array<DirectoryEntry>, Exception>
|
|
598
957
|
```
|
|
599
958
|
|
|
600
959
|
Read the entires of a directory.
|
|
@@ -614,7 +973,8 @@ Returns:
|
|
|
614
973
|
### File.**fdRenumber**
|
|
615
974
|
|
|
616
975
|
```grain
|
|
617
|
-
fdRenumber :
|
|
976
|
+
fdRenumber :
|
|
977
|
+
(fromFd: FileDescriptor, toFd: FileDescriptor) => Result<Void, Exception>
|
|
618
978
|
```
|
|
619
979
|
|
|
620
980
|
Atomically replace a file descriptor by renumbering another file descriptor.
|
|
@@ -635,7 +995,9 @@ Returns:
|
|
|
635
995
|
### File.**fdSeek**
|
|
636
996
|
|
|
637
997
|
```grain
|
|
638
|
-
fdSeek :
|
|
998
|
+
fdSeek :
|
|
999
|
+
(fd: FileDescriptor, offset: Int64, whence: Whence) =>
|
|
1000
|
+
Result<Int64, Exception>
|
|
639
1001
|
```
|
|
640
1002
|
|
|
641
1003
|
Update a file descriptor's offset.
|
|
@@ -657,7 +1019,7 @@ Returns:
|
|
|
657
1019
|
### File.**fdTell**
|
|
658
1020
|
|
|
659
1021
|
```grain
|
|
660
|
-
fdTell : FileDescriptor
|
|
1022
|
+
fdTell : (fd: FileDescriptor) => Result<Int64, Exception>
|
|
661
1023
|
```
|
|
662
1024
|
|
|
663
1025
|
Read a file descriptor's offset.
|
|
@@ -677,7 +1039,8 @@ Returns:
|
|
|
677
1039
|
### File.**pathCreateDirectory**
|
|
678
1040
|
|
|
679
1041
|
```grain
|
|
680
|
-
pathCreateDirectory :
|
|
1042
|
+
pathCreateDirectory :
|
|
1043
|
+
(fd: FileDescriptor, path: String) => Result<Void, Exception>
|
|
681
1044
|
```
|
|
682
1045
|
|
|
683
1046
|
Create a directory.
|
|
@@ -699,7 +1062,8 @@ Returns:
|
|
|
699
1062
|
|
|
700
1063
|
```grain
|
|
701
1064
|
pathFilestats :
|
|
702
|
-
(FileDescriptor, List<LookupFlag>, String)
|
|
1065
|
+
(fd: FileDescriptor, dirFlags: List<LookupFlag>, path: String) =>
|
|
1066
|
+
Result<Filestats, Exception>
|
|
703
1067
|
```
|
|
704
1068
|
|
|
705
1069
|
Retrieve information about a file.
|
|
@@ -722,8 +1086,8 @@ Returns:
|
|
|
722
1086
|
|
|
723
1087
|
```grain
|
|
724
1088
|
pathSetAccessTime :
|
|
725
|
-
(FileDescriptor, List<LookupFlag>, String,
|
|
726
|
-
Result<Void, Exception>
|
|
1089
|
+
(fd: FileDescriptor, dirFlags: List<LookupFlag>, path: String,
|
|
1090
|
+
timestamp: Int64) => Result<Void, Exception>
|
|
727
1091
|
```
|
|
728
1092
|
|
|
729
1093
|
Set the access (created) time of a file.
|
|
@@ -747,7 +1111,8 @@ Returns:
|
|
|
747
1111
|
|
|
748
1112
|
```grain
|
|
749
1113
|
pathSetAccessTimeNow :
|
|
750
|
-
(FileDescriptor, List<LookupFlag>, String)
|
|
1114
|
+
(fd: FileDescriptor, dirFlags: List<LookupFlag>, path: String) =>
|
|
1115
|
+
Result<Void, Exception>
|
|
751
1116
|
```
|
|
752
1117
|
|
|
753
1118
|
Set the access (created) time of a file to the current time.
|
|
@@ -770,8 +1135,8 @@ Returns:
|
|
|
770
1135
|
|
|
771
1136
|
```grain
|
|
772
1137
|
pathSetModifiedTime :
|
|
773
|
-
(FileDescriptor, List<LookupFlag>, String,
|
|
774
|
-
Result<Void, Exception>
|
|
1138
|
+
(fd: FileDescriptor, dirFlags: List<LookupFlag>, path: String,
|
|
1139
|
+
timestamp: Int64) => Result<Void, Exception>
|
|
775
1140
|
```
|
|
776
1141
|
|
|
777
1142
|
Set the modified time of a file.
|
|
@@ -795,7 +1160,8 @@ Returns:
|
|
|
795
1160
|
|
|
796
1161
|
```grain
|
|
797
1162
|
pathSetModifiedTimeNow :
|
|
798
|
-
(FileDescriptor, List<LookupFlag>, String)
|
|
1163
|
+
(fd: FileDescriptor, dirFlags: List<LookupFlag>, path: String) =>
|
|
1164
|
+
Result<Void, Exception>
|
|
799
1165
|
```
|
|
800
1166
|
|
|
801
1167
|
Set the modified time of a file to the current time.
|
|
@@ -818,7 +1184,8 @@ Returns:
|
|
|
818
1184
|
|
|
819
1185
|
```grain
|
|
820
1186
|
pathLink :
|
|
821
|
-
(FileDescriptor, List<LookupFlag>,
|
|
1187
|
+
(sourceFd: FileDescriptor, dirFlags: List<LookupFlag>, sourcePath:
|
|
1188
|
+
String, targetFd: FileDescriptor, targetPath: String) =>
|
|
822
1189
|
Result<Void, Exception>
|
|
823
1190
|
```
|
|
824
1191
|
|
|
@@ -843,7 +1210,9 @@ Returns:
|
|
|
843
1210
|
### File.**pathSymlink**
|
|
844
1211
|
|
|
845
1212
|
```grain
|
|
846
|
-
pathSymlink :
|
|
1213
|
+
pathSymlink :
|
|
1214
|
+
(fd: FileDescriptor, sourcePath: String, targetPath: String) =>
|
|
1215
|
+
Result<Void, Exception>
|
|
847
1216
|
```
|
|
848
1217
|
|
|
849
1218
|
Create a symlink.
|
|
@@ -865,7 +1234,7 @@ Returns:
|
|
|
865
1234
|
### File.**pathUnlink**
|
|
866
1235
|
|
|
867
1236
|
```grain
|
|
868
|
-
pathUnlink : (FileDescriptor, String)
|
|
1237
|
+
pathUnlink : (fd: FileDescriptor, path: String) => Result<Void, Exception>
|
|
869
1238
|
```
|
|
870
1239
|
|
|
871
1240
|
Unlink a file.
|
|
@@ -887,7 +1256,8 @@ Returns:
|
|
|
887
1256
|
|
|
888
1257
|
```grain
|
|
889
1258
|
pathReadlink :
|
|
890
|
-
(FileDescriptor, String,
|
|
1259
|
+
(fd: FileDescriptor, path: String, size: Number) =>
|
|
1260
|
+
Result<(String, Number), Exception>
|
|
891
1261
|
```
|
|
892
1262
|
|
|
893
1263
|
Read the contents of a symbolic link.
|
|
@@ -909,7 +1279,8 @@ Returns:
|
|
|
909
1279
|
### File.**pathRemoveDirectory**
|
|
910
1280
|
|
|
911
1281
|
```grain
|
|
912
|
-
pathRemoveDirectory :
|
|
1282
|
+
pathRemoveDirectory :
|
|
1283
|
+
(fd: FileDescriptor, path: String) => Result<Void, Exception>
|
|
913
1284
|
```
|
|
914
1285
|
|
|
915
1286
|
Remove a directory.
|
|
@@ -931,7 +1302,8 @@ Returns:
|
|
|
931
1302
|
|
|
932
1303
|
```grain
|
|
933
1304
|
pathRename :
|
|
934
|
-
(FileDescriptor, String, FileDescriptor,
|
|
1305
|
+
(sourceFd: FileDescriptor, sourcePath: String, targetFd: FileDescriptor,
|
|
1306
|
+
targetPath: String) => Result<Void, Exception>
|
|
935
1307
|
```
|
|
936
1308
|
|
|
937
1309
|
Rename a file or directory.
|
|
@@ -951,3 +1323,35 @@ Returns:
|
|
|
951
1323
|
|----|-----------|
|
|
952
1324
|
|`Result<Void, Exception>`|`Ok(void)` if successful or `Err(exception)` otherwise|
|
|
953
1325
|
|
|
1326
|
+
### File.**open**
|
|
1327
|
+
|
|
1328
|
+
<details disabled>
|
|
1329
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
1330
|
+
No other changes yet.
|
|
1331
|
+
</details>
|
|
1332
|
+
|
|
1333
|
+
```grain
|
|
1334
|
+
open :
|
|
1335
|
+
(path: String, openFlags: List<OpenFlag>, rights: List<Rights>,
|
|
1336
|
+
rightsInheriting: List<Rights>, flags: List<FdFlag>) =>
|
|
1337
|
+
Result<FileDescriptor, Exception>
|
|
1338
|
+
```
|
|
1339
|
+
|
|
1340
|
+
Similar to `pathOpen`, but resolves the path relative to preopened directories.
|
|
1341
|
+
|
|
1342
|
+
Parameters:
|
|
1343
|
+
|
|
1344
|
+
|param|type|description|
|
|
1345
|
+
|-----|----|-----------|
|
|
1346
|
+
|`path`|`String`|The path to the file or directory|
|
|
1347
|
+
|`openFlags`|`List<OpenFlag>`|Flags that decide how the path will be opened|
|
|
1348
|
+
|`rights`|`List<Rights>`|The rights that dictate what may be done with the returned file descriptor|
|
|
1349
|
+
|`rightsInheriting`|`List<Rights>`|The rights that dictate what may be done with file descriptors derived from this file descriptor|
|
|
1350
|
+
|`flags`|`List<FdFlag>`|Flags which affect read/write operations on this file descriptor|
|
|
1351
|
+
|
|
1352
|
+
Returns:
|
|
1353
|
+
|
|
1354
|
+
|type|description|
|
|
1355
|
+
|----|-----------|
|
|
1356
|
+
|`Result<FileDescriptor, Exception>`|`Ok(fd)` of the opened file or directory if successful or `Err(exception)` otherwise|
|
|
1357
|
+
|