node/test/simple.js

25 lines
645 B
JavaScript
Raw Normal View History

2009-04-16 17:37:44 +08:00
var f = new File;
2009-04-18 00:54:29 +08:00
f.open("/tmp/world", "w+", function (status) {
if (status == 0) {
stdout.puts("file open");
2009-04-18 00:54:29 +08:00
f.write("hello world\n");
f.write("something else.\n", function () {
stdout.puts("written. ");
});
f.read(100, function (status, buf) {
2009-04-18 00:54:29 +08:00
if (buf)
stdout.puts("read: >>" + buf.encodeUtf8() + "<<");
});
} else {
stdout.puts("file open failed: " + status.toString());
}
2009-04-18 00:54:29 +08:00
f.close(function (status) {
stdout.puts("closed: " + status.toString());
File.rename("/tmp/world", "/tmp/hello", function (status) {
stdout.puts("rename: " + status.toString());
});
});
});