diff --git a/mk/tests.mk b/mk/tests.mk
index eabb5f535e61d..a24791d76af97 100644
--- a/mk/tests.mk
+++ b/mk/tests.mk
@@ -517,8 +517,8 @@ CTEST_BUILD_BASE_rpass = run-pass
CTEST_MODE_rpass = run-pass
CTEST_RUNTOOL_rpass = $(CTEST_RUNTOOL)
-CTEST_SRC_BASE_rpass-full = run-pass-full
-CTEST_BUILD_BASE_rpass-full = run-pass-full
+CTEST_SRC_BASE_rpass-full = run-pass-fulldeps
+CTEST_BUILD_BASE_rpass-full = run-pass-fulldeps
CTEST_MODE_rpass-full = run-pass
CTEST_RUNTOOL_rpass-full = $(CTEST_RUNTOOL)
@@ -673,7 +673,7 @@ PRETTY_DEPS_pretty-rfail = $(RFAIL_TESTS)
PRETTY_DEPS_pretty-bench = $(BENCH_TESTS)
PRETTY_DEPS_pretty-pretty = $(PRETTY_TESTS)
PRETTY_DIRNAME_pretty-rpass = run-pass
-PRETTY_DIRNAME_pretty-rpass-full = run-pass-full
+PRETTY_DIRNAME_pretty-rpass-full = run-pass-fulldeps
PRETTY_DIRNAME_pretty-rfail = run-fail
PRETTY_DIRNAME_pretty-bench = bench
PRETTY_DIRNAME_pretty-pretty = pretty
diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs
index 7f5a72e8a2c8c..f4bd668690eef 100644
--- a/src/compiletest/compiletest.rs
+++ b/src/compiletest/compiletest.rs
@@ -17,6 +17,7 @@ extern mod extra;
use std::os;
use std::rt;
+use std::rt::io::fs;
use extra::getopts;
use extra::getopts::groups::{optopt, optflag, reqopt};
@@ -247,7 +248,7 @@ pub fn make_tests(config: &config) -> ~[test::TestDescAndFn] {
debug!("making tests from {}",
config.src_base.display());
let mut tests = ~[];
- let dirs = os::list_dir_path(&config.src_base);
+ let dirs = fs::readdir(&config.src_base);
for file in dirs.iter() {
let file = file.clone();
debug!("inspecting file {}", file.display());
diff --git a/src/compiletest/errors.rs b/src/compiletest/errors.rs
index 0c94ec8ab8a83..8bfef9da805f2 100644
--- a/src/compiletest/errors.rs
+++ b/src/compiletest/errors.rs
@@ -8,16 +8,16 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::rt::io::buffered::BufferedReader;
+use std::rt::io::File;
+
pub struct ExpectedError { line: uint, kind: ~str, msg: ~str }
// Load any test directives embedded in the file
pub fn load_errors(testfile: &Path) -> ~[ExpectedError] {
- use std::rt::io::Open;
- use std::rt::io::file::FileInfo;
- use std::rt::io::buffered::BufferedReader;
let mut error_patterns = ~[];
- let mut rdr = BufferedReader::new(testfile.open_reader(Open).unwrap());
+ let mut rdr = BufferedReader::new(File::open(testfile).unwrap());
let mut line_num = 1u;
loop {
let ln = match rdr.read_line() {
diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs
index 368c96ffe8542..5571e159ee31d 100644
--- a/src/compiletest/header.rs
+++ b/src/compiletest/header.rs
@@ -103,11 +103,10 @@ pub fn is_test_ignored(config: &config, testfile: &Path) -> bool {
}
fn iter_header(testfile: &Path, it: &fn(&str) -> bool) -> bool {
- use std::rt::io::Open;
- use std::rt::io::file::FileInfo;
use std::rt::io::buffered::BufferedReader;
+ use std::rt::io::File;
- let mut rdr = BufferedReader::new(testfile.open_reader(Open).unwrap());
+ let mut rdr = BufferedReader::new(File::open(testfile).unwrap());
loop {
let ln = match rdr.read_line() {
Some(ln) => ln, None => break
diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs
index 13c4c7948b803..1b3e34ad81934 100644
--- a/src/compiletest/runtest.rs
+++ b/src/compiletest/runtest.rs
@@ -20,44 +20,18 @@ use procsrv;
use util;
use util::logv;
-use std::cell::Cell;
use std::rt::io;
-use std::rt::io::Writer;
-use std::rt::io::Reader;
-use std::rt::io::file::FileInfo;
+use std::rt::io::fs;
+use std::rt::io::File;
use std::os;
use std::str;
-use std::task::{spawn_sched, SingleThreaded};
use std::vec;
-use std::unstable::running_on_valgrind;
use extra::test::MetricMap;
pub fn run(config: config, testfile: ~str) {
- let config = Cell::new(config);
- let testfile = Cell::new(testfile);
- // FIXME #6436: Creating another thread to run the test because this
- // is going to call waitpid. The new scheduler has some strange
- // interaction between the blocking tasks and 'friend' schedulers
- // that destroys parallelism if we let normal schedulers block.
- // It should be possible to remove this spawn once std::run is
- // rewritten to be non-blocking.
- //
- // We do _not_ create another thread if we're running on V because
- // it serializes all threads anyways.
- if running_on_valgrind() {
- let config = config.take();
- let testfile = testfile.take();
- let mut _mm = MetricMap::new();
- run_metrics(config, testfile, &mut _mm);
- } else {
- do spawn_sched(SingleThreaded) {
- let config = config.take();
- let testfile = testfile.take();
- let mut _mm = MetricMap::new();
- run_metrics(config, testfile, &mut _mm);
- }
- }
+ let mut _mm = MetricMap::new();
+ run_metrics(config, testfile, &mut _mm);
}
pub fn run_metrics(config: config, testfile: ~str, mm: &mut MetricMap) {
@@ -173,7 +147,7 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
let rounds =
match props.pp_exact { Some(_) => 1, None => 2 };
- let src = testfile.open_reader(io::Open).read_to_end();
+ let src = File::open(testfile).read_to_end();
let src = str::from_utf8_owned(src);
let mut srcs = ~[src];
@@ -195,7 +169,7 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
let mut expected = match props.pp_exact {
Some(ref file) => {
let filepath = testfile.dir_path().join(file);
- let s = filepath.open_reader(io::Open).read_to_end();
+ let s = File::open(&filepath).read_to_end();
str::from_utf8_owned(s)
}
None => { srcs[srcs.len() - 2u].clone() }
@@ -651,10 +625,8 @@ fn compose_and_run_compiler(
}
fn ensure_dir(path: &Path) {
- if os::path_is_dir(path) { return; }
- if !os::make_dir(path, 0x1c0i32) {
- fail!("can't make dir {}", path.display());
- }
+ if path.is_dir() { return; }
+ fs::mkdir(path, io::UserRWX);
}
fn compose_and_run(config: &config, testfile: &Path,
@@ -768,7 +740,7 @@ fn dump_output(config: &config, testfile: &Path, out: &str, err: &str) {
fn dump_output_file(config: &config, testfile: &Path,
out: &str, extension: &str) {
let outfile = make_out_name(config, testfile, extension);
- outfile.open_writer(io::CreateOrTruncate).write(out.as_bytes());
+ File::create(&outfile).write(out.as_bytes());
}
fn make_out_name(config: &config, testfile: &Path, extension: &str) -> Path {
@@ -924,7 +896,7 @@ fn _dummy_exec_compiled_test(config: &config, props: &TestProps,
fn _arm_push_aux_shared_library(config: &config, testfile: &Path) {
let tdir = aux_output_dir_name(config, testfile);
- let dirs = os::list_dir_path(&tdir);
+ let dirs = fs::readdir(&tdir);
for file in dirs.iter() {
if file.extension_str() == Some("so") {
// FIXME (#9639): This needs to handle non-utf8 paths
@@ -1019,7 +991,7 @@ fn disassemble_extract(config: &config, _props: &TestProps,
fn count_extracted_lines(p: &Path) -> uint {
- let x = p.with_extension("ll").open_reader(io::Open).read_to_end();
+ let x = File::open(&p.with_extension("ll")).read_to_end();
let x = str::from_utf8_owned(x);
x.line_iter().len()
}
diff --git a/src/etc/libc.c b/src/etc/libc.c
index e341f495eebb9..d86ed510361cc 100644
--- a/src/etc/libc.c
+++ b/src/etc/libc.c
@@ -143,6 +143,7 @@ void posix88_consts() {
put_const(S_IFBLK, int);
put_const(S_IFDIR, int);
put_const(S_IFREG, int);
+ put_const(S_IFLNK, int);
put_const(S_IFMT, int);
put_const(S_IEXEC, int);
diff --git a/src/libextra/glob.rs b/src/libextra/glob.rs
index 5297b48b0e156..1edef5ddbe1b4 100644
--- a/src/libextra/glob.rs
+++ b/src/libextra/glob.rs
@@ -24,6 +24,8 @@
*/
use std::{os, path};
+use std::rt::io;
+use std::rt::io::fs;
use std::path::is_sep;
use sort;
@@ -146,9 +148,14 @@ impl Iterator for GlobIterator {
}
fn list_dir_sorted(path: &Path) -> ~[Path] {
- let mut children = os::list_dir_path(path);
- sort::quick_sort(children, |p1, p2| p2.filename().unwrap() <= p1.filename().unwrap());
- children
+ match io::result(|| fs::readdir(path)) {
+ Ok(children) => {
+ let mut children = children;
+ sort::quick_sort(children, |p1, p2| p2.filename() <= p1.filename());
+ children
+ }
+ Err(*) => ~[]
+ }
}
/**
diff --git a/src/libextra/tempfile.rs b/src/libextra/tempfile.rs
index d8fa130916a46..fbd65cab98ca7 100644
--- a/src/libextra/tempfile.rs
+++ b/src/libextra/tempfile.rs
@@ -14,6 +14,8 @@
use std::os;
use std::rand::Rng;
use std::rand;
+use std::rt::io;
+use std::rt::io::fs;
/// A wrapper for a path to temporary directory implementing automatic
/// scope-pased deletion.
@@ -36,8 +38,9 @@ impl TempDir {
let mut r = rand::rng();
for _ in range(0u, 1000) {
let p = tmpdir.join(r.gen_ascii_str(16) + suffix);
- if os::make_dir(&p, 0x1c0) { // 700
- return Some(TempDir { path: Some(p) });
+ match io::result(|| fs::mkdir(&p, io::UserRWX)) {
+ Err(*) => {}
+ Ok(()) => return Some(TempDir { path: Some(p) })
}
}
None
@@ -69,7 +72,9 @@ impl TempDir {
impl Drop for TempDir {
fn drop(&mut self) {
for path in self.path.iter() {
- os::remove_dir_recursive(path);
+ if path.exists() {
+ fs::rmdir_recursive(path);
+ }
}
}
}
diff --git a/src/libextra/terminfo/parser/compiled.rs b/src/libextra/terminfo/parser/compiled.rs
index b530c1b6334ed..04b30e5ef7474 100644
--- a/src/libextra/terminfo/parser/compiled.rs
+++ b/src/libextra/terminfo/parser/compiled.rs
@@ -329,6 +329,6 @@ mod test {
#[ignore(reason = "no ncurses on buildbots, needs a bundled terminfo file to test against")]
fn test_parse() {
// FIXME #6870: Distribute a compiled file in src/tests and test there
- // parse(io::file_reader(&p("/usr/share/terminfo/r/rxvt-256color")).unwrap(), false);
+ // parse(io::fs_reader(&p("/usr/share/terminfo/r/rxvt-256color")).unwrap(), false);
}
}
diff --git a/src/libextra/terminfo/searcher.rs b/src/libextra/terminfo/searcher.rs
index 8dff53f14a159..09ceae66bb12d 100644
--- a/src/libextra/terminfo/searcher.rs
+++ b/src/libextra/terminfo/searcher.rs
@@ -14,7 +14,7 @@
use std::{os, str};
use std::os::getenv;
use std::rt::io;
-use std::rt::io::file::FileInfo;
+use std::rt::io::File;
/// Return path to database entry for `term`
pub fn get_dbpath_for_term(term: &str) -> Option<~Path> {
@@ -56,16 +56,16 @@ pub fn get_dbpath_for_term(term: &str) -> Option<~Path> {
// Look for the terminal in all of the search directories
for p in dirs_to_search.iter() {
- if os::path_exists(p) {
+ if p.exists() {
let f = str::from_char(first_char);
let newp = p.join_many([f.as_slice(), term]);
- if os::path_exists(&newp) {
+ if newp.exists() {
return Some(~newp);
}
// on some installations the dir is named after the hex of the char (e.g. OS X)
let f = format!("{:x}", first_char as uint);
let newp = p.join_many([f.as_slice(), term]);
- if os::path_exists(&newp) {
+ if newp.exists() {
return Some(~newp);
}
}
@@ -76,7 +76,7 @@ pub fn get_dbpath_for_term(term: &str) -> Option<~Path> {
/// Return open file for `term`
pub fn open(term: &str) -> Result<@mut io::Reader, ~str> {
match get_dbpath_for_term(term) {
- Some(x) => Ok(@mut x.open_reader(io::Open).unwrap() as @mut io::Reader),
+ Some(x) => Ok(@mut File::open(x) as @mut io::Reader),
None => Err(format!("could not find terminfo entry for {}", term))
}
}
diff --git a/src/libextra/test.rs b/src/libextra/test.rs
index f262e6c60fb35..4cdb3841acf9b 100644
--- a/src/libextra/test.rs
+++ b/src/libextra/test.rs
@@ -31,7 +31,7 @@ use treemap::TreeMap;
use std::clone::Clone;
use std::comm::{stream, SharedChan, GenericPort, GenericChan};
use std::rt::io;
-use std::rt::io::file::FileInfo;
+use std::rt::io::File;
use std::task;
use std::to_str::ToStr;
use std::f64;
@@ -353,10 +353,7 @@ struct ConsoleTestState {
impl ConsoleTestState {
pub fn new(opts: &TestOpts) -> ConsoleTestState {
let log_out = match opts.logfile {
- Some(ref path) => {
- let out = path.open_writer(io::CreateOrTruncate);
- Some(@mut out as @mut io::Writer)
- },
+ Some(ref path) => Some(@mut File::create(path) as @mut io::Writer),
None => None
};
let out = @mut io::stdio::stdout() as @mut io::Writer;
@@ -938,16 +935,15 @@ impl MetricMap {
/// Load MetricDiff from a file.
pub fn load(p: &Path) -> MetricMap {
- assert!(os::path_exists(p));
- let f = @mut p.open_reader(io::Open) as @mut io::Reader;
+ assert!(p.exists());
+ let f = @mut File::open(p) as @mut io::Reader;
let mut decoder = json::Decoder(json::from_reader(f).unwrap());
MetricMap(Decodable::decode(&mut decoder))
}
/// Write MetricDiff to a file.
pub fn save(&self, p: &Path) {
- let f = @mut p.open_writer(io::CreateOrTruncate);
- self.to_json().to_pretty_writer(f as @mut io::Writer);
+ self.to_json().to_pretty_writer(@mut File::create(p) as @mut io::Writer);
}
/// Compare against another MetricMap. Optionally compare all
@@ -1032,7 +1028,7 @@ impl MetricMap {
/// `MetricChange`s are `Regression`. Returns the diff as well
/// as a boolean indicating whether the ratchet succeeded.
pub fn ratchet(&self, p: &Path, pct: Option) -> (MetricDiff, bool) {
- let old = if os::path_exists(p) {
+ let old = if p.exists() {
MetricMap::load(p)
} else {
MetricMap::new()
diff --git a/src/libextra/uuid.rs b/src/libextra/uuid.rs
index b94b74a696cc2..54ce349a0b484 100644
--- a/src/libextra/uuid.rs
+++ b/src/libextra/uuid.rs
@@ -792,7 +792,6 @@ mod test {
#[test]
fn test_serialize_round_trip() {
- use std;
use ebml;
use serialize::{Encodable, Decodable};
diff --git a/src/libextra/workcache.rs b/src/libextra/workcache.rs
index 507962c0b1a2a..eed37a426be2d 100644
--- a/src/libextra/workcache.rs
+++ b/src/libextra/workcache.rs
@@ -17,13 +17,10 @@ use arc::{Arc,RWArc};
use treemap::TreeMap;
use std::cell::Cell;
use std::comm::{PortOne, oneshot};
-use std::{os, str, task};
+use std::{str, task};
use std::rt::io;
-use std::rt::io::Writer;
-use std::rt::io::Reader;
-use std::rt::io::Decorator;
+use std::rt::io::{File, Decorator};
use std::rt::io::mem::MemWriter;
-use std::rt::io::file::FileInfo;
/**
*
@@ -145,7 +142,7 @@ impl Database {
db_cache: TreeMap::new(),
db_dirty: false
};
- if os::path_exists(&rslt.db_filename) {
+ if rslt.db_filename.exists() {
rslt.load();
}
rslt
@@ -178,19 +175,19 @@ impl Database {
// FIXME #4330: This should have &mut self and should set self.db_dirty to false.
fn save(&self) {
- let f = @mut self.db_filename.open_writer(io::CreateOrTruncate);
+ let f = @mut File::create(&self.db_filename);
self.db_cache.to_json().to_pretty_writer(f as @mut io::Writer);
}
fn load(&mut self) {
assert!(!self.db_dirty);
- assert!(os::path_exists(&self.db_filename));
- let f = self.db_filename.open_reader(io::Open);
- match f {
- None => fail!("Couldn't load workcache database {}",
- self.db_filename.display()),
- Some(r) =>
- match json::from_reader(@mut r as @mut io::Reader) {
+ assert!(self.db_filename.exists());
+ match io::result(|| File::open(&self.db_filename)) {
+ Err(e) => fail!("Couldn't load workcache database {}: {}",
+ self.db_filename.display(),
+ e.desc),
+ Ok(r) =>
+ match json::from_reader(@mut r.unwrap() as @mut io::Reader) {
Err(e) => fail!("Couldn't parse workcache database (from file {}): {}",
self.db_filename.display(), e.to_str()),
Ok(r) => {
@@ -482,23 +479,21 @@ impl<'self, T:Send +
#[test]
fn test() {
use std::{os, run};
- use std::rt::io::Reader;
+ use std::rt::io::fs;
use std::str::from_utf8_owned;
// Create a path to a new file 'filename' in the directory in which
// this test is running.
fn make_path(filename: ~str) -> Path {
let pth = os::self_exe_path().expect("workcache::test failed").with_filename(filename);
- if os::path_exists(&pth) {
- os::remove_file(&pth);
+ if pth.exists() {
+ fs::unlink(&pth);
}
return pth;
}
let pth = make_path(~"foo.c");
- {
- pth.open_writer(io::Create).write(bytes!("int main() { return 0; }"));
- }
+ File::create(&pth).write(bytes!("int main() { return 0; }"));
let db_path = make_path(~"db.json");
@@ -511,7 +506,7 @@ fn test() {
let subcx = cx.clone();
let pth = pth.clone();
- let file_content = from_utf8_owned(pth.open_reader(io::Open).read_to_end());
+ let file_content = from_utf8_owned(File::open(&pth).read_to_end());
// FIXME (#9639): This needs to handle non-utf8 paths
prep.declare_input("file", pth.as_str().unwrap(), file_content);
diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs
index 815ec943c4962..5b0f424360b1e 100644
--- a/src/librustc/back/link.rs
+++ b/src/librustc/back/link.rs
@@ -27,12 +27,11 @@ use std::char;
use std::hash::Streaming;
use std::hash;
use std::os::consts::{macos, freebsd, linux, android, win32};
-use std::os;
use std::ptr;
-use std::rt::io::Writer;
use std::run;
use std::str;
use std::vec;
+use std::rt::io::fs;
use syntax::ast;
use syntax::ast_map::{path, path_mod, path_name, path_pretty_name};
use syntax::attr;
@@ -951,20 +950,17 @@ pub fn link_binary(sess: Session,
// Remove the temporary object file if we aren't saving temps
if !sess.opts.save_temps {
- if ! os::remove_file(obj_filename) {
- sess.warn(format!("failed to delete object file `{}`",
- obj_filename.display()));
- }
+ fs::unlink(obj_filename);
}
}
fn is_writeable(p: &Path) -> bool {
- use std::libc::consts::os::posix88::S_IWUSR;
+ use std::rt::io;
- !os::path_exists(p) ||
- (match p.get_mode() {
- None => false,
- Some(m) => m & S_IWUSR as uint == S_IWUSR as uint
+ !p.exists() ||
+ (match io::result(|| p.stat()) {
+ Err(*) => false,
+ Ok(m) => m.perm & io::UserWrite == io::UserWrite
})
}
diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs
index fb593b56e15f5..744e192095bb2 100644
--- a/src/librustc/driver/driver.rs
+++ b/src/librustc/driver/driver.rs
@@ -27,6 +27,7 @@ use util::ppaux;
use std::hashmap::{HashMap,HashSet};
use std::rt::io;
+use std::rt::io::fs;
use std::rt::io::mem::MemReader;
use std::os;
use std::vec;
@@ -369,7 +370,7 @@ pub fn phase_5_run_llvm_passes(sess: Session,
// Remove assembly source unless --save-temps was specified
if !sess.opts.save_temps {
- os::remove_file(&asm_filename);
+ fs::unlink(&asm_filename);
}
} else {
time(sess.time_passes(), "LLVM passes", (), |_|
diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs
index 94dfc006076f9..c9bd5eff4a771 100644
--- a/src/librustc/metadata/filesearch.rs
+++ b/src/librustc/metadata/filesearch.rs
@@ -11,6 +11,8 @@
use std::option;
use std::os;
+use std::rt::io;
+use std::rt::io::fs;
use std::hashmap::HashSet;
pub enum FileMatch { FileMatches, FileDoesntMatch }
@@ -117,22 +119,26 @@ pub fn mk_filesearch(maybe_sysroot: &Option<@Path>,
pub fn search(filesearch: @FileSearch, pick: pick) {
do filesearch.for_each_lib_search_path() |lib_search_path| {
debug!("searching {}", lib_search_path.display());
- let r = os::list_dir_path(lib_search_path);
- let mut rslt = FileDoesntMatch;
- for path in r.iter() {
- debug!("testing {}", path.display());
- let maybe_picked = pick(path);
- match maybe_picked {
- FileMatches => {
- debug!("picked {}", path.display());
- rslt = FileMatches;
- }
- FileDoesntMatch => {
- debug!("rejected {}", path.display());
+ match io::result(|| fs::readdir(lib_search_path)) {
+ Ok(files) => {
+ let mut rslt = FileDoesntMatch;
+ for path in files.iter() {
+ debug!("testing {}", path.display());
+ let maybe_picked = pick(path);
+ match maybe_picked {
+ FileMatches => {
+ debug!("picked {}", path.display());
+ rslt = FileMatches;
+ }
+ FileDoesntMatch => {
+ debug!("rejected {}", path.display());
+ }
+ }
}
+ rslt
}
+ Err(*) => FileDoesntMatch,
}
- rslt
};
}
@@ -210,7 +216,7 @@ pub fn rust_path() -> ~[Path] {
break
}
cwd.set_filename(".rust");
- if !env_rust_path.contains(&cwd) && os::path_exists(&cwd) {
+ if !env_rust_path.contains(&cwd) && cwd.exists() {
env_rust_path.push(cwd.clone());
}
cwd.pop();
@@ -218,7 +224,7 @@ pub fn rust_path() -> ~[Path] {
let h = os::homedir();
for h in h.iter() {
let p = h.join(".rust");
- if !env_rust_path.contains(&p) && os::path_exists(&p) {
+ if !env_rust_path.contains(&p) && p.exists() {
env_rust_path.push(p);
}
}
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 7bfe0910252be..0efc52bbe4a67 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -40,10 +40,9 @@ use std::fmt;
use std::hashmap::{HashMap, HashSet};
use std::local_data;
use std::rt::io::buffered::BufferedWriter;
-use std::rt::io::file::{FileInfo, DirectoryInfo};
-use std::rt::io::file;
use std::rt::io;
-use std::rt::io::Reader;
+use std::rt::io::fs;
+use std::rt::io::File;
use std::os;
use std::str;
use std::task;
@@ -265,8 +264,8 @@ pub fn run(mut crate: clean::Crate, dst: Path) {
// Publish the search index
{
dst.push("search-index.js");
- let mut w = BufferedWriter::new(dst.open_writer(io::CreateOrTruncate));
- let w = &mut w as &mut io::Writer;
+ let mut w = BufferedWriter::new(File::create(&dst).unwrap());
+ let w = &mut w as &mut Writer;
write!(w, "var searchIndex = [");
for (i, item) in cache.search_index.iter().enumerate() {
if i > 0 { write!(w, ","); }
@@ -315,8 +314,7 @@ pub fn run(mut crate: clean::Crate, dst: Path) {
/// Writes the entire contents of a string to a destination, not attempting to
/// catch any errors.
fn write(dst: Path, contents: &str) {
- let mut w = dst.open_writer(io::CreateOrTruncate);
- w.write(contents.as_bytes());
+ File::create(&dst).write(contents.as_bytes());
}
/// Makes a directory on the filesystem, failing the task if an error occurs and
@@ -328,7 +326,7 @@ fn mkdir(path: &Path) {
fail!()
}).inside {
if !path.is_dir() {
- file::mkdir(path);
+ fs::mkdir(path, io::UserRWX);
}
}
}
@@ -419,16 +417,13 @@ impl<'self> SourceCollector<'self> {
let mut contents = ~[];
{
let mut buf = [0, ..1024];
- let r = do io::io_error::cond.trap(|_| {}).inside {
- p.open_reader(io::Open)
- };
// If we couldn't open this file, then just returns because it
// probably means that it's some standard library macro thing and we
// can't have the source to it anyway.
- let mut r = match r {
- Some(r) => r,
+ let mut r = match io::result(|| File::open(&p)) {
+ Ok(r) => r,
// eew macro hacks
- None => return filename == ""
+ Err(*) => return filename == ""
};
// read everything
@@ -451,8 +446,7 @@ impl<'self> SourceCollector<'self> {
}
cur.push(p.filename().expect("source has no filename") + bytes!(".html"));
- let w = cur.open_writer(io::CreateOrTruncate);
- let mut w = BufferedWriter::new(w);
+ let mut w = BufferedWriter::new(File::create(&cur).unwrap());
let title = cur.filename_display().with_str(|s| format!("{} -- source", s));
let page = layout::Page {
@@ -460,7 +454,7 @@ impl<'self> SourceCollector<'self> {
ty: "source",
root_path: root_path,
};
- layout::render(&mut w as &mut io::Writer, &self.cx.layout,
+ layout::render(&mut w as &mut Writer, &self.cx.layout,
&page, &(""), &Source(contents.as_slice()));
w.flush();
return true;
@@ -774,7 +768,7 @@ impl Context {
///
/// The rendering driver uses this closure to queue up more work.
fn item(&mut self, item: clean::Item, f: &fn(&mut Context, clean::Item)) {
- fn render(w: io::file::FileWriter, cx: &mut Context, it: &clean::Item,
+ fn render(w: io::File, cx: &mut Context, it: &clean::Item,
pushname: bool) {
// A little unfortunate that this is done like this, but it sure
// does make formatting *a lot* nicer.
@@ -796,7 +790,7 @@ impl Context {
// of the pain by using a buffered writer instead of invoking the
// write sycall all the time.
let mut writer = BufferedWriter::new(w);
- layout::render(&mut writer as &mut io::Writer, &cx.layout, &page,
+ layout::render(&mut writer as &mut Writer, &cx.layout, &page,
&Sidebar{ cx: cx, item: it },
&Item{ cx: cx, item: it });
writer.flush();
@@ -811,8 +805,7 @@ impl Context {
do self.recurse(name) |this| {
let item = item.take();
let dst = this.dst.join("index.html");
- let writer = dst.open_writer(io::CreateOrTruncate);
- render(writer.unwrap(), this, &item, false);
+ render(File::create(&dst).unwrap(), this, &item, false);
let m = match item.inner {
clean::ModuleItem(m) => m,
@@ -829,8 +822,7 @@ impl Context {
// pages dedicated to them.
_ if item.name.is_some() => {
let dst = self.dst.join(item_path(&item));
- let writer = dst.open_writer(io::CreateOrTruncate);
- render(writer.unwrap(), self, &item, true);
+ render(File::create(&dst).unwrap(), self, &item, true);
}
_ => {}
@@ -967,7 +959,7 @@ fn shorter<'a>(s: Option<&'a str>) -> &'a str {
}
}
-fn document(w: &mut io::Writer, item: &clean::Item) {
+fn document(w: &mut Writer, item: &clean::Item) {
match item.doc_value() {
Some(s) => {
write!(w, "{}
", Markdown(s));
@@ -976,7 +968,7 @@ fn document(w: &mut io::Writer, item: &clean::Item) {
}
}
-fn item_module(w: &mut io::Writer, cx: &Context,
+fn item_module(w: &mut Writer, cx: &Context,
item: &clean::Item, items: &[clean::Item]) {
document(w, item);
debug!("{:?}", items);
@@ -1123,7 +1115,7 @@ fn item_module(w: &mut io::Writer, cx: &Context,
write!(w, "");
}
-fn item_function(w: &mut io::Writer, it: &clean::Item, f: &clean::Function) {
+fn item_function(w: &mut Writer, it: &clean::Item, f: &clean::Function) {
write!(w, "{vis}{purity}fn {name}{generics}{decl}
",
vis = VisSpace(it.visibility),
purity = PuritySpace(f.purity),
@@ -1133,7 +1125,7 @@ fn item_function(w: &mut io::Writer, it: &clean::Item, f: &clean::Function) {
document(w, it);
}
-fn item_trait(w: &mut io::Writer, it: &clean::Item, t: &clean::Trait) {
+fn item_trait(w: &mut Writer, it: &clean::Item, t: &clean::Trait) {
let mut parents = ~"";
if t.parents.len() > 0 {
parents.push_str(": ");
@@ -1176,7 +1168,7 @@ fn item_trait(w: &mut io::Writer, it: &clean::Item, t: &clean::Trait) {
// Trait documentation
document(w, it);
- fn meth(w: &mut io::Writer, m: &clean::TraitMethod) {
+ fn meth(w: &mut Writer, m: &clean::TraitMethod) {
write!(w, "",
shortty(m.item()),
*m.item().name.get_ref());
@@ -1234,8 +1226,8 @@ fn item_trait(w: &mut io::Writer, it: &clean::Item, t: &clean::Trait) {
}
}
-fn render_method(w: &mut io::Writer, meth: &clean::Item, withlink: bool) {
- fn fun(w: &mut io::Writer, it: &clean::Item, purity: ast::purity,
+fn render_method(w: &mut Writer, meth: &clean::Item, withlink: bool) {
+ fn fun(w: &mut Writer, it: &clean::Item, purity: ast::purity,
g: &clean::Generics, selfty: &clean::SelfTy, d: &clean::FnDecl,
withlink: bool) {
write!(w, "{}fn {withlink, select,
@@ -1264,7 +1256,7 @@ fn render_method(w: &mut io::Writer, meth: &clean::Item, withlink: bool) {
}
}
-fn item_struct(w: &mut io::Writer, it: &clean::Item, s: &clean::Struct) {
+fn item_struct(w: &mut Writer, it: &clean::Item, s: &clean::Struct) {
write!(w, "");
render_struct(w, it, Some(&s.generics), s.struct_type, s.fields,
s.fields_stripped, "", true);
@@ -1288,7 +1280,7 @@ fn item_struct(w: &mut io::Writer, it: &clean::Item, s: &clean::Struct) {
render_methods(w, it);
}
-fn item_enum(w: &mut io::Writer, it: &clean::Item, e: &clean::Enum) {
+fn item_enum(w: &mut Writer, it: &clean::Item, e: &clean::Enum) {
write!(w, "{}enum {}{}",
VisSpace(it.visibility),
it.name.get_ref().as_slice(),
@@ -1365,7 +1357,7 @@ fn item_enum(w: &mut io::Writer, it: &clean::Item, e: &clean::Enum) {
render_methods(w, it);
}
-fn render_struct(w: &mut io::Writer, it: &clean::Item,
+fn render_struct(w: &mut Writer, it: &clean::Item,
g: Option<&clean::Generics>,
ty: doctree::StructType,
fields: &[clean::Item],
@@ -1418,7 +1410,7 @@ fn render_struct(w: &mut io::Writer, it: &clean::Item,
}
}
-fn render_methods(w: &mut io::Writer, it: &clean::Item) {
+fn render_methods(w: &mut Writer, it: &clean::Item) {
do local_data::get(cache_key) |cache| {
let cache = cache.unwrap();
do cache.read |c| {
@@ -1453,7 +1445,7 @@ fn render_methods(w: &mut io::Writer, it: &clean::Item) {
}
}
-fn render_impl(w: &mut io::Writer, i: &clean::Impl, dox: &Option<~str>) {
+fn render_impl(w: &mut Writer, i: &clean::Impl, dox: &Option<~str>) {
write!(w, "impl{} ", i.generics);
let trait_id = match i.trait_ {
Some(ref ty) => {
@@ -1474,7 +1466,7 @@ fn render_impl(w: &mut io::Writer, i: &clean::Impl, dox: &Option<~str>) {
None => {}
}
- fn docmeth(w: &mut io::Writer, item: &clean::Item) -> bool {
+ fn docmeth(w: &mut Writer, item: &clean::Item) -> bool {
write!(w, "",
*item.name.get_ref());
render_method(w, item, false);
@@ -1552,7 +1544,7 @@ fn render_impl(w: &mut io::Writer, i: &clean::Impl, dox: &Option<~str>) {
write!(w, "");
}
-fn item_typedef(w: &mut io::Writer, it: &clean::Item, t: &clean::Typedef) {
+fn item_typedef(w: &mut Writer, it: &clean::Item, t: &clean::Typedef) {
write!(w, "type {}{} = {};
",
it.name.get_ref().as_slice(),
t.generics,
@@ -1574,7 +1566,7 @@ impl<'self> fmt::Default for Sidebar<'self> {
}
write!(fmt.buf, "
");
- fn block(w: &mut io::Writer, short: &str, longty: &str,
+ fn block(w: &mut Writer, short: &str, longty: &str,
cur: &clean::Item, cx: &Context) {
let items = match cx.sidebar.find_equiv(&short) {
Some(items) => items.as_slice(),
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs
index 770d535c6ea9e..c69fd9879ce2f 100644
--- a/src/librustdoc/lib.rs
+++ b/src/librustdoc/lib.rs
@@ -25,9 +25,8 @@ extern mod extra;
use std::cell::Cell;
use std::local_data;
-use std::rt::io::Writer;
-use std::rt::io::file::FileInfo;
use std::rt::io;
+use std::rt::io::File;
use std::rt::io::mem::MemWriter;
use std::rt::io::Decorator;
use std::str;
@@ -260,7 +259,7 @@ fn rust_input(cratefile: &str, matches: &getopts::Matches) -> Output {
/// This input format purely deserializes the json output file. No passes are
/// run over the deserialized output.
fn json_input(input: &str) -> Result