|
5 | 5 | ; the system level get-type is nondetermninistic therefore returns all willing participants
|
6 | 6 | (= (get-type $obj)
|
7 | 7 | (call-for! FileHandle ; call for returns the first argument
|
8 |
| - (@ (atomic $obj) ; stream might return an error if obj is not atomic |
9 |
| - (stream $obj)))) ; if obj is a stream we are calling it a filehandle since prolog streams already support this api |
| 8 | + (atomic $obj) ; stream might return an error if obj is not atomic |
| 9 | + (stream $obj))) ; if obj is a stream we are calling it a filehandle since prolog streams already support this api |
10 | 10 |
|
11 | 11 | (= (parse-mode $chars)
|
12 | 12 | (call-for! $mode
|
13 |
| - (@ |
14 | 13 | (or
|
15 | 14 | (and (memberchk r $chars) (memberchk w $chars) (= $mode update))
|
16 | 15 | (and (memberchk a $chars) (= $mode append))
|
17 | 16 | (and (memberchk w $chars) (= $mode write))
|
18 | 17 | (and (memberchk r $chars) (= $mode read))
|
19 |
| - (= $mode read))))) |
| 18 | + (= $mode read)))) |
20 | 19 |
|
21 | 20 | (= (handle-create-options $path $chars)
|
22 |
| - (call-unit! |
23 |
| - (@ (if-then (and (memberchk n $chars) (exists_file $path)) |
| 21 | + (call-unit |
| 22 | + (if-then (and (memberchk n $chars) (exists_file $path)) |
24 | 23 | (throw (error (file_exists_error $path))))
|
25 | 24 | (if-then (and (memberchk c $chars) (not (exists_file $path)))
|
26 | 25 | (setup_call_cleanup (open $path write $s) (close $s) true))
|
27 | 26 | (if-then (and (memberchk t $chars) (exists_file $path))
|
28 |
| - (setup_call_cleanup (open $path write $s) (close $s) true))))) |
| 27 | + (setup_call_cleanup (open $path write $s) (close $s) true)))) |
29 | 28 |
|
30 | 29 | (@doc file-open!
|
31 | 30 | (@desc "Function takes path to the file and open options (r, w, c, a, t) both in form of string, creates filehandle and
|
|
40 | 39 | ; tells the compiler to return only the first successful clause
|
41 | 40 | (iz file-open! Deterministic)
|
42 | 41 | (= (file-open! $fpath $opt)
|
43 |
| - (call-for! $stream (@ |
| 42 | + (call-for! $stream |
44 | 43 | (string_chars $opt $chars)
|
45 | 44 | (any_to_atom $fpath $path)
|
46 | 45 | (= $mode (parse-mode $chars))
|
47 | 46 | (handle-create-options $path $chars)
|
48 |
| - (open $path $mode $stream [ (type text) ])))) |
| 47 | + (open $path $mode $stream [ (type text) ]))) |
49 | 48 | (= (file-open-err! $path $opt)
|
50 | 49 | (call-for! $_err
|
51 | 50 | (format (string $msg)
|
|
61 | 60 | (@return "File's content"))
|
62 | 61 | (: file-read-to-string! (-> FileHandle String))
|
63 | 62 | (= (file-read-to-string! $stream)
|
64 |
| - (call-fn! read_string $stream $_ )) |
| 63 | + (call-fn read_string $stream $_ )) |
65 | 64 |
|
66 | 65 | (@doc file-write!
|
67 | 66 | (@desc "Function takes filehandle provided by file-open!, content to be written (string atom) and puts content into
|
|
72 | 71 | (@return "Unit atom"))
|
73 | 72 | (: file-write! (-> FileHandle String Unit))
|
74 | 73 | (= (file-write! $stream $content)
|
75 |
| - (call-unit! (, |
| 74 | + (call-unit |
76 | 75 | (write $stream $content)
|
77 |
| - (flush_output $stream)))) |
| 76 | + (flush_output $stream))) |
78 | 77 |
|
79 | 78 | (@doc file-seek!
|
80 | 79 | (@desc "Function takes filehandle provided by file-open! and desired cursor position (number) and sets cursor to
|
|
85 | 84 | (@return "Unit atom"))
|
86 | 85 | (: file-seek! (-> FileHandle Number Unit))
|
87 | 86 | (= (file-seek! $stream $offset)
|
88 |
| - (call-unit! |
89 |
| - (@ (seek $stream $offset bof $_)))) |
| 87 | + (call-unit |
| 88 | + (seek $stream $offset bof $_))) |
90 | 89 |
|
91 | 90 | (@doc file-read-exact!
|
92 | 91 | (@desc "Function takes filehandle provided by file-open! and desired number of bytes to read (number), reads content
|
|
119 | 118 | (@return "Unit atom"))
|
120 | 119 | (: file-close! (-> FileHandle Unit))
|
121 | 120 | (= (file-close! $stream)
|
122 |
| - (call-unit! |
| 121 | + (call-unit |
123 | 122 | (close $stream)))
|
124 | 123 |
|
125 | 124 | ; Load system libs (not required .. but more here for reference)
|
126 |
| -;!(call-unit! |
| 125 | +;!(call-unit |
127 | 126 | ; (use_module (library apply))
|
128 | 127 | ; (use_module (library filesex)))
|
129 | 128 |
|
|
0 commit comments