summaryrefslogtreecommitdiff
path: root/lib/std/writeall.myr
blob: 9e5ea0925c6aeb675db2f96ef5e9e91d187d0d8b (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
use "errno"
use "result"
use "option"
use "syswrap"
use "types"

pkg std =
	const writeall : (fd : fd, src : byte[:] -> (size, option(errno)))
;;

const writeall = {fd, src
	var sz

	sz = src.len
	while src.len != 0
		match std.write(fd, src)
		| `Ok n:
			src = src[n:]
		| `Fail e:
			-> (sz - src.len, `Some e)
		;;
	;;
	-> (sz, `None)
}