blob: ed27f97f76d1bc52dbc2169ba0ce1be249aa52ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
use "syswrap.use"
use "result.use"
pkg std =
const blat : (path : byte[:], buf : byte[:], perm : int64 -> bool)
const fblat : (f : fd, buf : byte[:] -> bool)
;;
const blat = {path, buf, perm
match openmode(path, Ocreat|Owronly, perm)
| `Ok fd: -> fblat(fd, buf)
| `Fail e: -> false
;;
}
const fblat = {fd, buf
var count
count = 0
while true
match write(fd, buf[count:])
| `Fail e: -> false
| `Ok n:
if n == 0
break
;;
count += n
;;
;;
-> count == buf.len
}
|