diff options
| author | bors <bors@rust-lang.org> | 2013-11-04 12:21:11 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-11-04 12:21:11 -0800 |
| commit | 658637baf45b41e4cff049440bc07f267d810218 (patch) | |
| tree | 019eee1761d43461ef06f1e5307b57b0b8b47019 /src/libsyntax/parse | |
| parent | 70e9b5ab3912da84a32557bc1a34db5fb2178927 (diff) | |
| parent | 3c3ed1499a9b9e23d4a2d2243a7b0b1c9015f34b (diff) | |
| download | rust-658637baf45b41e4cff049440bc07f267d810218.tar.gz rust-658637baf45b41e4cff049440bc07f267d810218.zip | |
auto merge of #10179 : alexcrichton/rust/rt-improvements, r=cmr
This fleshes out the io::file module a fair bit more, adding all of the functionality that I can think of that we would want. Some questions about the representation which I'm curious about: * I modified `FileStat` to be a little less platform-agnostic, but it's still fairly platform-specific. I don't want to hide information that we have, but I don't want to depend on this information being available. One possible route is to have an `extra` field which has all this os-dependent stuff which is clearly documented as it should be avoided. * Does it make sense for directory functions to be top-level functions instead of static methods? It seems silly to import `std::rt::io::file` and `std::rt::io::File` at the top of files that need to deal with directories and files.
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 003bc006ebe..fbe711b5efe 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -19,10 +19,8 @@ use parse::attr::parser_attr; use parse::lexer::reader; use parse::parser::Parser; -use std::path::Path; use std::rt::io; -use std::rt::io::Reader; -use std::rt::io::file::FileInfo; +use std::rt::io::File; use std::str; pub mod lexer; @@ -269,16 +267,13 @@ pub fn file_to_filemap(sess: @mut ParseSess, path: &Path, spanopt: Option<Span>) None => sess.span_diagnostic.handler().fatal(msg), } }; - let mut error = None; - let bytes = do io::io_error::cond.trap(|e| error = Some(e)).inside { - path.open_reader(io::Open).read_to_end() - }; - match error { - Some(e) => { + let bytes = match io::result(|| File::open(path).read_to_end()) { + Ok(bytes) => bytes, + Err(e) => { err(format!("couldn't read {}: {}", path.display(), e.desc)); + unreachable!() } - None => {} - } + }; match str::from_utf8_owned_opt(bytes) { Some(s) => { return string_to_filemap(sess, s.to_managed(), |
