From a1a25969a072a33f68fba16a2a3859a7d96809c2 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 1 Aug 2011 15:53:14 -0700 Subject: [PATCH] Add ioivec::read_whole_file/read_whole_file_str --- src/lib/ioivec.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lib/ioivec.rs b/src/lib/ioivec.rs index cae0c27787c..728a1d0e3d2 100644 --- a/src/lib/ioivec.rs +++ b/src/lib/ioivec.rs @@ -454,6 +454,18 @@ fn seek_in_buf(offset: int, pos: uint, len: uint, whence: seek_style) -> if bpos < 0 { bpos = 0; } else if (bpos > blen) { bpos = blen; } ret bpos as uint; } + +fn read_whole_file_str(file: &str) -> str { + str::unsafe_from_bytes_ivec(read_whole_file(file)) +} + +fn read_whole_file(file: &str) -> u8[] { + // FIXME: There's a lot of copying here + file_reader(file).read_whole_stream() +} + + + // // Local Variables: // mode: rust