Skip to content

Commit a1a2596

Browse files
committed
Add ioivec::read_whole_file/read_whole_file_str
1 parent 77be30f commit a1a2596

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/lib/ioivec.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,18 @@ fn seek_in_buf(offset: int, pos: uint, len: uint, whence: seek_style) ->
454454
if bpos < 0 { bpos = 0; } else if (bpos > blen) { bpos = blen; }
455455
ret bpos as uint;
456456
}
457+
458+
fn read_whole_file_str(file: &str) -> str {
459+
str::unsafe_from_bytes_ivec(read_whole_file(file))
460+
}
461+
462+
fn read_whole_file(file: &str) -> u8[] {
463+
// FIXME: There's a lot of copying here
464+
file_reader(file).read_whole_stream()
465+
}
466+
467+
468+
457469
//
458470
// Local Variables:
459471
// mode: rust

0 commit comments

Comments
 (0)