-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfs_append.echo
More file actions
54 lines (53 loc) · 934 Bytes
/
Copy pathfs_append.echo
File metadata and controls
54 lines (53 loc) · 934 Bytes
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
; fs.append + file.seek. Run: xo run examples/misc/fs_append.echo
/ std/io
/ std/str
/ std/bytes
/ std/fs
$ path = fs.join("/tmp", "echo_fs_append_ex.txt")
| fs.write(path, "ab") {
$ ok {}
! e {
io.print(e)
}
}
| fs.append(path) {
$ f {
| f.write("cd") {
$ ok {}
! e {
io.print(e)
}
}
f.close()
}
! e {
io.print(e)
}
}
| fs.open(path) {
$ f {
| f.seek(2) {
$ pos {
| f.read(10) {
$ b {
io.print(str.from_bytes(b))
}
! e {
io.print(e)
}
}
}
! e {
io.print(e)
}
}
f.close()
}
! e {
io.print(e)
}
}
| fs.remove(path) {
$ ok {}
! e {}
}