Usage
var x = new(File, $S("test.bin"), $S("wb"));
char* data = "hello";
swrite(x, data, strlen(data));
sclose(x);
Formatted Printing
var x = $(File, NULL);
sopen(x, $S("test.txt"), $S("w"));
print_to(x, 0, "%$ is %$ ", $S("Dan"), $I(23));
print_to(x, 0, "%$ is %$ ", $S("Chess"), $I(24));
sclose(x);
Automatic Closing
with(f in new(File, $S("test.txt"), $S("r"))) {
var k = new(String); resize(k, 100);
var v = new(Int, $I(0));
foreach (i in range($I(2))) {
scan_from(f, 0, "%$ is %$ ", k, v);
show(k); show(v);
}
}
Operating System File
The File
type is a wrapper of the native C FILE
type representing a file in the operating system.
struct File {
FILE* file;
};
$
alloc
dealloc
assign
cast
cmp
eq
neq
gt
lt
ge
le
copy
hash
hash_data
size
swap
name
brief
description
definition
format_to
format_from
new
del
construct
destruct
with
start
stop
join
running
sopen
sclose
sseek
stell
sflush
seof
sread
swrite