aboutsummaryrefslogtreecommitdiff
path: root/src/lib/_io.rs
diff options
context:
space:
mode:
authorRoy Frostig <[email protected]>2010-08-20 12:57:38 -0700
committerRoy Frostig <[email protected]>2010-08-20 12:57:38 -0700
commit2da4fecacd1b61e9e090e93c33394712fa7f066c (patch)
treea8cfa1e04cd0c39d91441a71d3a4bcba0ef8cba7 /src/lib/_io.rs
parentAllow every test to make a .tmp file that is cleaned up before execution. (diff)
downloadrust-2da4fecacd1b61e9e090e93c33394712fa7f066c.tar.xz
rust-2da4fecacd1b61e9e090e93c33394712fa7f066c.zip
Test the buffered reader and writer in _io.
Diffstat (limited to 'src/lib/_io.rs')
-rw-r--r--src/lib/_io.rs23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/lib/_io.rs b/src/lib/_io.rs
index 2fb225dd..0d968c5c 100644
--- a/src/lib/_io.rs
+++ b/src/lib/_io.rs
@@ -84,7 +84,18 @@ fn new_buf_reader(str path) -> buf_reader {
ret fd_buf_reader(fd, new_buf());
}
-type fileflag = tag(append(), create(), truncate());
+/**
+ * FIXME (issue #150): This should be
+ *
+ * type fileflag = tag(append(), create(), truncate());
+ *
+ * but then the tag value ctors are not found from crate-importers of std, so
+ * we manually simulate the enum below.
+ */
+type fileflag = uint;
+fn append() -> uint { ret 0u; }
+fn create() -> uint { ret 1u; }
+fn truncate() -> uint { ret 2u; }
fn new_buf_writer(str path, vec[fileflag] flags) -> buf_writer {
@@ -117,9 +128,13 @@ fn new_buf_writer(str path, vec[fileflag] flags) -> buf_writer {
for (fileflag f in flags) {
alt (f) {
- case (append()) { fflags |= os.libc_constants.O_APPEND(); }
- case (create()) { fflags |= os.libc_constants.O_CREAT(); }
- case (truncate()) { fflags |= os.libc_constants.O_TRUNC(); }
+ // FIXME (issue #150): cf comment above defn of fileflag type
+ //case (append()) { fflags |= os.libc_constants.O_APPEND(); }
+ //case (create()) { fflags |= os.libc_constants.O_CREAT(); }
+ //case (truncate()) { fflags |= os.libc_constants.O_TRUNC(); }
+ case (0u) { fflags |= os.libc_constants.O_APPEND(); }
+ case (1u) { fflags |= os.libc_constants.O_CREAT(); }
+ case (2u) { fflags |= os.libc_constants.O_TRUNC(); }
}
}