| |
| /pliant/language/stream/light.pli |
| |
| 1 |
module "/pliant/language/compiler/internals.pli" | |
| 2 |
module "/pliant/language/basic/unsafe.pli" | |
| 3 |
module "/pliant/language/misc/hooks.pli" | |
| 4 |
| |
| 5 |
| |
| 6 |
function file_open_ name mode f -> handle | |
| 7 |
arg Str name ; arg Int mode ; arg Function f ; arg Int handle | |
| 8 |
indirect | |
| 9 |
| |
| 10 |
function file_open name mode -> handle | |
| 11 |
arg Str name ; arg Int mode ; arg Int handle | |
| 12 |
(var Function f) executable := pliant_file_open_hook | |
| 13 |
handle := file_open_ name mode f | |
| 14 |
| |
| 15 |
| |
| 16 |
function file_read_ handle buffer size f -> red | |
| 17 |
arg Int handle ; arg Address buffer ; arg Int size ; arg Function f ; arg Int red | |
| 18 |
indirect | |
| 19 |
| |
| 20 |
function file_read handle buffer size -> red | |
| 21 |
arg Int handle ; arg Address buffer ; arg Int size ; arg Int red | |
| 22 |
(var Function f) executable := pliant_file_read_hook | |
| 23 |
red := file_read_ handle buffer size f | |
| 24 |
| |
| 25 |
| |
| 26 |
function file_write_ handle buffer size f -> written | |
| 27 |
arg Int handle ; arg Address buffer ; arg Int size ; arg Function f ; arg Int written | |
| 28 |
indirect | |
| 29 |
| |
| 30 |
function file_write handle buffer size -> written | |
| 31 |
arg Int handle ; arg Address buffer ; arg Int size ; arg Int written | |
| 32 |
(var Function f) executable := pliant_file_write_hook | |
| 33 |
written := file_write_ handle buffer size f | |
| 34 |
| |
| 35 |
| |
| 36 |
function file_close_ handle f | |
| 37 |
arg Int handle ; arg Function f | |
| 38 |
indirect | |
| 39 |
| |
| 40 |
function file_close handle | |
| 41 |
arg Int handle | |
| 42 |
(var Function f) executable := pliant_file_close_hook | |
| 43 |
file_close_ handle f | |
| 44 |
| |
| 45 |
| |
| 46 |
function file_readline handle line -> available | |
| 47 |
arg Int handle ; arg_w Str line ; arg CBool available | |
| 48 |
line := "" ; var Str buf := " " ; available := false | |
| 49 |
while (file_read handle buf:characters 1)>0 | |
| 50 |
available := true | |
| 51 |
if buf="[lf]" | |
| 52 |
return | |
| 53 |
eif buf<>"[cr]" | |
| 54 |
line := line+buf | |
| 55 |
| |
| 56 |
| |
| 57 |
export file_open file_close file_read file_write file_readline | |
| |