aboutsummaryrefslogtreecommitdiff
path: root/src/lib/_io.rs
diff options
context:
space:
mode:
authorOr Brostovski <[email protected]>2010-08-07 16:43:08 +0300
committerOr Brostovski <[email protected]>2010-08-07 16:43:08 +0300
commit4467d7683dae87d6d4c55e446910f7a5b85abd13 (patch)
treee2578dbe8e2350eb4e82ae2941fc2efb7478253b /src/lib/_io.rs
parentAdded AST pretty printing for communication alt statement, closes issue 19. (diff)
parentAdd Or to the AUTHORS file. (diff)
downloadrust-4467d7683dae87d6d4c55e446910f7a5b85abd13.tar.xz
rust-4467d7683dae87d6d4c55e446910f7a5b85abd13.zip
Merge branch 'master' of git://github.com/graydon/rust
Conflicts: src/boot/fe/ast.ml
Diffstat (limited to 'src/lib/_io.rs')
-rw-r--r--src/lib/_io.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/lib/_io.rs b/src/lib/_io.rs
index 142f808a..93d06d41 100644
--- a/src/lib/_io.rs
+++ b/src/lib/_io.rs
@@ -1,3 +1,7 @@
+import std.os;
+import std._str;
+import std._vec;
+
type buf_reader = unsafe obj {
fn read() -> vec[u8];
};
@@ -107,3 +111,22 @@ fn new_buf_writer(str path, vec[fileflag] flags) -> buf_writer {
}
ret fd_buf_writer(fd);
}
+
+type writer =
+ unsafe obj {
+ fn write_str(str s);
+ fn write_int(int n);
+ fn write_uint(uint n);
+ };
+
+fn file_writer(str path,
+ vec[fileflag] flags)
+ -> writer
+{
+ unsafe obj fw(buf_writer out) {
+ fn write_str(str s) { out.write(_str.bytes(s)); }
+ fn write_int(int n) { out.write(_str.bytes(_int.to_str(n, 10u))); }
+ fn write_uint(uint n) { out.write(_str.bytes(_int.uto_str(n, 10u))); }
+ }
+ ret fw(new_buf_writer(path, flags));
+}