2009-04-16 11:37:44 +02:00
|
|
|
var f = new File;
|
|
|
|
|
2009-04-16 21:05:26 +02:00
|
|
|
f.open("/tmp/world", "r+", function (status) {
|
2009-04-16 13:20:35 +02:00
|
|
|
if (status == 0) {
|
2009-04-16 13:58:10 +02:00
|
|
|
stdout.puts("file open");
|
2009-04-16 21:05:26 +02:00
|
|
|
f.write("hello world\n")
|
|
|
|
f.write("something else.\n", function () {
|
|
|
|
stdout.puts("written. ");
|
|
|
|
});
|
|
|
|
f.read(100, function (status, buf) {
|
|
|
|
stdout.puts("read: >>" + buf.encodeUtf8() + "<<");
|
2009-04-16 13:20:35 +02:00
|
|
|
});
|
|
|
|
} else {
|
2009-04-16 13:58:10 +02:00
|
|
|
stdout.puts("file open failed: " + status.toString());
|
2009-04-16 13:20:35 +02:00
|
|
|
}
|
2009-04-16 21:05:26 +02:00
|
|
|
|
|
|
|
f.close(function () { stdout.puts("closed.") });
|
2009-04-16 13:20:35 +02:00
|
|
|
});
|