aboutsummaryrefslogtreecommitdiff
path: root/src/lib/io.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/io.rs')
-rw-r--r--src/lib/io.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/lib/io.rs b/src/lib/io.rs
index 4a3274ac..61f06795 100644
--- a/src/lib/io.rs
+++ b/src/lib/io.rs
@@ -41,6 +41,7 @@ type reader =
impure fn read_le_uint(uint size) -> uint;
impure fn read_le_int(uint size) -> int;
impure fn read_be_uint(uint size) -> uint;
+ impure fn read_whole_stream() -> vec[u8];
impure fn seek(int offset, seek_style whence);
impure fn tell() -> uint; // FIXME: eventually u64
@@ -170,6 +171,13 @@ state obj new_reader(buf_reader rdr) {
}
ret val;
}
+ impure fn read_whole_stream() -> vec[u8] {
+ let vec[u8] buf = vec();
+ while (!rdr.eof()) {
+ buf += rdr.read(2048u);
+ }
+ ret buf;
+ }
impure fn seek(int offset, seek_style whence) {
ret rdr.seek(offset, whence);
}