about summary refs log tree commit diff
path: root/src/librustpkg
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-11-04 12:21:11 -0800
committerbors <bors@rust-lang.org>2013-11-04 12:21:11 -0800
commit658637baf45b41e4cff049440bc07f267d810218 (patch)
tree019eee1761d43461ef06f1e5307b57b0b8b47019 /src/librustpkg
parent70e9b5ab3912da84a32557bc1a34db5fb2178927 (diff)
parent3c3ed1499a9b9e23d4a2d2243a7b0b1c9015f34b (diff)
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/librustpkg')
-rw-r--r--src/librustpkg/api.rs6
-rw-r--r--src/librustpkg/context.rs3
-rw-r--r--src/librustpkg/installed_packages.rs8
-rw-r--r--src/librustpkg/lib.rs31
-rw-r--r--src/librustpkg/package_id.rs1
-rw-r--r--src/librustpkg/package_source.rs22
-rw-r--r--src/librustpkg/path_util.rs59
-rw-r--r--src/librustpkg/source_control.rs22
-rw-r--r--src/librustpkg/tests.rs232
-rw-r--r--src/librustpkg/testsuite/pass/src/c-dependencies/foo.rs2
-rw-r--r--src/librustpkg/testsuite/pass/src/c-dependencies/pkg.rs2
-rw-r--r--src/librustpkg/testsuite/pass/src/fancy-lib/pkg.rs8
-rw-r--r--src/librustpkg/util.rs27
-rw-r--r--src/librustpkg/version.rs4
-rw-r--r--src/librustpkg/workcache_support.rs26
-rw-r--r--src/librustpkg/workspace.rs2
16 files changed, 208 insertions, 247 deletions
diff --git a/src/librustpkg/api.rs b/src/librustpkg/api.rs
index c67b6f52c7e..c0ffd66d22e 100644
--- a/src/librustpkg/api.rs
+++ b/src/librustpkg/api.rs
@@ -21,7 +21,7 @@ pub use path_util::default_workspace;
 
 pub use source_control::{safe_git_clone, git_clone_url};
 
-use std::{os, run};
+use std::run;
 use extra::arc::{Arc,RWArc};
 use extra::workcache;
 use extra::workcache::{Database, Logger, FreshnessMap};
@@ -57,12 +57,12 @@ pub fn new_default_context(c: workcache::Context, p: Path) -> BuildContext {
 
 fn file_is_fresh(path: &str, in_hash: &str) -> bool {
     let path = Path::new(path);
-    os::path_exists(&path) && in_hash == digest_file_with_date(&path)
+    path.exists() && in_hash == digest_file_with_date(&path)
 }
 
 fn binary_is_fresh(path: &str, in_hash: &str) -> bool {
     let path = Path::new(path);
-    os::path_exists(&path) && in_hash == digest_only_date(&path)
+    path.exists() && in_hash == digest_only_date(&path)
 }
 
 pub fn new_workcache_context(p: &Path) -> workcache::Context {
diff --git a/src/librustpkg/context.rs b/src/librustpkg/context.rs
index 77fe2ae8f70..0ae08731546 100644
--- a/src/librustpkg/context.rs
+++ b/src/librustpkg/context.rs
@@ -14,7 +14,6 @@ use extra::workcache;
 use rustc::driver::session::{OptLevel, No};
 
 use std::hashmap::HashSet;
-use std::os;
 
 #[deriving(Clone)]
 pub struct Context {
@@ -176,7 +175,7 @@ pub fn in_target(sysroot: &Path) -> bool {
     debug!("Checking whether {} is in target", sysroot.display());
     let mut p = sysroot.dir_path();
     p.set_filename("rustc");
-    os::path_is_dir(&p)
+    p.is_dir()
 }
 
 impl RustcFlags {
diff --git a/src/librustpkg/installed_packages.rs b/src/librustpkg/installed_packages.rs
index 767a31ed785..576d5abe8bd 100644
--- a/src/librustpkg/installed_packages.rs
+++ b/src/librustpkg/installed_packages.rs
@@ -13,11 +13,13 @@
 use rustc::metadata::filesearch::rust_path;
 use path_util::*;
 use std::os;
+use std::rt::io;
+use std::rt::io::fs;
 
 pub fn list_installed_packages(f: &fn(&PkgId) -> bool) -> bool  {
     let workspaces = rust_path();
     for p in workspaces.iter() {
-        let binfiles = os::list_dir(&p.join("bin"));
+        let binfiles = do io::ignore_io_error { fs::readdir(&p.join("bin")) };
         for exec in binfiles.iter() {
             // FIXME (#9639): This needs to handle non-utf8 paths
             match exec.filestem_str() {
@@ -29,7 +31,7 @@ pub fn list_installed_packages(f: &fn(&PkgId) -> bool) -> bool  {
                 }
             }
         }
-        let libfiles = os::list_dir(&p.join("lib"));
+        let libfiles = do io::ignore_io_error { fs::readdir(&p.join("lib")) };
         for lib in libfiles.iter() {
             debug!("Full name: {}", lib.display());
             match has_library(lib) {
@@ -53,7 +55,7 @@ pub fn list_installed_packages(f: &fn(&PkgId) -> bool) -> bool  {
 }
 
 pub fn has_library(p: &Path) -> Option<~str> {
-    let files = os::list_dir(p);
+    let files = do io::ignore_io_error { fs::readdir(p) };
     for path in files.iter() {
         if path.extension_str() == Some(os::consts::DLL_EXTENSION) {
             let stuff : &str = path.filestem_str().expect("has_library: weird path");
diff --git a/src/librustpkg/lib.rs b/src/librustpkg/lib.rs
index 80f1dc2fe93..b493d562b8b 100644
--- a/src/librustpkg/lib.rs
+++ b/src/librustpkg/lib.rs
@@ -26,6 +26,8 @@ extern mod syntax;
 
 use std::{os, result, run, str, task};
 use std::hashmap::HashSet;
+use std::rt::io;
+use std::rt::io::fs;
 pub use std::path::Path;
 
 use extra::workcache;
@@ -36,7 +38,7 @@ use extra::{getopts};
 use syntax::{ast, diagnostic};
 use messages::{error, warn, note};
 use path_util::{build_pkg_id_in_workspace, built_test_in_workspace};
-use path_util::{U_RWX, in_rust_path};
+use path_util::in_rust_path;
 use path_util::{built_executable_in_workspace, built_library_in_workspace, default_workspace};
 use path_util::{target_executable_in_workspace, target_library_in_workspace, dir_has_crate_file};
 use source_control::{CheckedOutSources, is_git_dir, make_read_only};
@@ -513,7 +515,7 @@ impl CtxMethods for BuildContext {
                     // We expect that p is relative to the package source's start directory,
                     // so check that assumption
                     debug!("JustOne: p = {}", p.display());
-                    assert!(os::path_exists(&pkg_src.start_dir.join(p)));
+                    assert!(pkg_src.start_dir.join(p).exists());
                     if is_lib(p) {
                         PkgSrc::push_crate(&mut pkg_src.libs, 0, p);
                     } else if is_main(p) {
@@ -541,8 +543,8 @@ impl CtxMethods for BuildContext {
         let dir = build_pkg_id_in_workspace(id, workspace);
         note(format!("Cleaning package {} (removing directory {})",
                         id.to_str(), dir.display()));
-        if os::path_exists(&dir) {
-            os::remove_dir_recursive(&dir);
+        if dir.exists() {
+            fs::rmdir_recursive(&dir);
             note(format!("Removed directory {}", dir.display()));
         }
 
@@ -600,7 +602,6 @@ impl CtxMethods for BuildContext {
                         build_inputs: &[Path],
                         target_workspace: &Path,
                         id: &PkgId) -> ~[~str] {
-        use conditions::copy_failed::cond;
 
         debug!("install_no_build: assuming {} comes from {} with target {}",
                id.to_str(), build_workspace.display(), target_workspace.display());
@@ -659,10 +660,8 @@ impl CtxMethods for BuildContext {
 
                 for exec in subex.iter() {
                     debug!("Copying: {} -> {}", exec.display(), sub_target_ex.display());
-                    if !(os::mkdir_recursive(&sub_target_ex.dir_path(), U_RWX) &&
-                         os::copy_file(exec, &sub_target_ex)) {
-                        cond.raise(((*exec).clone(), sub_target_ex.clone()));
-                    }
+                    fs::mkdir_recursive(&sub_target_ex.dir_path(), io::UserRWX);
+                    fs::copy(exec, &sub_target_ex);
                     // FIXME (#9639): This needs to handle non-utf8 paths
                     exe_thing.discover_output("binary",
                         sub_target_ex.as_str().unwrap(),
@@ -674,10 +673,8 @@ impl CtxMethods for BuildContext {
                         .clone().expect(format!("I built {} but apparently \
                                              didn't install it!", lib.display()));
                     target_lib.set_filename(lib.filename().expect("weird target lib"));
-                    if !(os::mkdir_recursive(&target_lib.dir_path(), U_RWX) &&
-                         os::copy_file(lib, &target_lib)) {
-                        cond.raise(((*lib).clone(), target_lib.clone()));
-                    }
+                    fs::mkdir_recursive(&target_lib.dir_path(), io::UserRWX);
+                    fs::copy(lib, &target_lib);
                     debug!("3. discovering output {}", target_lib.display());
                     exe_thing.discover_output("binary",
                                               target_lib.as_str().unwrap(),
@@ -712,10 +709,10 @@ impl CtxMethods for BuildContext {
     }
 
     fn init(&self) {
-        os::mkdir_recursive(&Path::new("src"),   U_RWX);
-        os::mkdir_recursive(&Path::new("lib"),   U_RWX);
-        os::mkdir_recursive(&Path::new("bin"),   U_RWX);
-        os::mkdir_recursive(&Path::new("build"), U_RWX);
+        fs::mkdir_recursive(&Path::new("src"), io::UserRWX);
+        fs::mkdir_recursive(&Path::new("bin"), io::UserRWX);
+        fs::mkdir_recursive(&Path::new("lib"), io::UserRWX);
+        fs::mkdir_recursive(&Path::new("build"), io::UserRWX);
     }
 
     fn uninstall(&self, _id: &str, _vers: Option<~str>)  {
diff --git a/src/librustpkg/package_id.rs b/src/librustpkg/package_id.rs
index 0fc614d7f3c..0da343a27bf 100644
--- a/src/librustpkg/package_id.rs
+++ b/src/librustpkg/package_id.rs
@@ -10,7 +10,6 @@
 
 use version::{try_getting_version, try_getting_local_version,
               Version, NoVersion, split_version};
-use std::rt::io::Writer;
 use std::hash::Streaming;
 use std::hash;
 
diff --git a/src/librustpkg/package_source.rs b/src/librustpkg/package_source.rs
index 797ea3372cc..3023f3ed60c 100644
--- a/src/librustpkg/package_source.rs
+++ b/src/librustpkg/package_source.rs
@@ -12,7 +12,8 @@ extern mod extra;
 
 use target::*;
 use package_id::PkgId;
-use std::path::Path;
+use std::rt::io;
+use std::rt::io::fs;
 use std::os;
 use context::*;
 use crate::Crate;
@@ -117,7 +118,7 @@ impl PkgSrc {
 
         debug!("Checking dirs: {:?}", to_try.map(|p| p.display().to_str()).connect(":"));
 
-        let path = to_try.iter().find(|&d| os::path_exists(d));
+        let path = to_try.iter().find(|&d| d.exists());
 
         // See the comments on the definition of PkgSrc
         let mut build_in_destination = use_rust_path_hack;
@@ -132,7 +133,7 @@ impl PkgSrc {
                     let package_id = PkgId::new(prefix.as_str().unwrap());
                     let path = build_dir.join(&package_id.path);
                     debug!("in loop: checking if {} is a directory", path.display());
-                    if os::path_is_dir(&path) {
+                    if path.is_dir() {
                         let ps = PkgSrc::new(source_workspace,
                                              destination_workspace,
                                              use_rust_path_hack,
@@ -237,7 +238,7 @@ impl PkgSrc {
 
         debug!("For package id {}, returning {}", id.to_str(), dir.display());
 
-        if !os::path_is_dir(&dir) {
+        if !dir.is_dir() {
             cond.raise((id.clone(), ~"supplied path for package dir is a \
                                         non-directory"));
         }
@@ -267,7 +268,7 @@ impl PkgSrc {
         debug!("Checking whether {} (path = {}) exists locally. Cwd = {}, does it? {:?}",
                 pkgid.to_str(), pkgid.path.display(),
                 cwd.display(),
-                os::path_exists(&pkgid.path));
+                pkgid.path.exists());
 
         match safe_git_clone(&pkgid.path, &pkgid.version, local) {
             CheckedOutSources => {
@@ -300,7 +301,7 @@ impl PkgSrc {
                 // Move clone_target to local.
                 // First, create all ancestor directories.
                 let moved = make_dir_rwx_recursive(&local.dir_path())
-                    && os::rename_file(&clone_target, local);
+                    && io::result(|| fs::rename(&clone_target, local)).is_ok();
                 if moved { Some(local.clone()) }
                     else { None }
             }
@@ -312,7 +313,7 @@ impl PkgSrc {
     pub fn package_script_option(&self) -> Option<Path> {
         let maybe_path = self.start_dir.join("pkg.rs");
         debug!("package_script_option: checking whether {} exists", maybe_path.display());
-        if os::path_exists(&maybe_path) {
+        if maybe_path.exists() {
             Some(maybe_path)
         } else {
             None
@@ -349,7 +350,7 @@ impl PkgSrc {
 
         let prefix = self.start_dir.component_iter().len();
         debug!("Matching against {}", self.id.short_name);
-        do os::walk_dir(&self.start_dir) |pth| {
+        for pth in fs::walk_dir(&self.start_dir) {
             let maybe_known_crate_set = match pth.filename_str() {
                 Some(filename) if filter(filename) => match filename {
                     "lib.rs" => Some(&mut self.libs),
@@ -362,11 +363,10 @@ impl PkgSrc {
             };
 
             match maybe_known_crate_set {
-                Some(crate_set) => PkgSrc::push_crate(crate_set, prefix, pth),
+                Some(crate_set) => PkgSrc::push_crate(crate_set, prefix, &pth),
                 None => ()
             }
-            true
-        };
+        }
 
         let crate_sets = [&self.libs, &self.mains, &self.tests, &self.benchs];
         if crate_sets.iter().all(|crate_set| crate_set.is_empty()) {
diff --git a/src/librustpkg/path_util.rs b/src/librustpkg/path_util.rs
index a48ef23115c..949efacaa11 100644
--- a/src/librustpkg/path_util.rs
+++ b/src/librustpkg/path_util.rs
@@ -18,8 +18,9 @@ use rustc::driver::driver::host_triple;
 
 use std::libc;
 use std::libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR};
-use std::os::mkdir_recursive;
 use std::os;
+use std::rt::io;
+use std::rt::io::fs;
 use messages::*;
 
 pub fn default_workspace() -> Path {
@@ -28,8 +29,8 @@ pub fn default_workspace() -> Path {
         fail!("Empty RUST_PATH");
     }
     let result = p[0];
-    if !os::path_is_dir(&result) {
-        os::mkdir_recursive(&result, U_RWX);
+    if !result.is_dir() {
+        fs::mkdir_recursive(&result, io::UserRWX);
     }
     result
 }
@@ -43,9 +44,13 @@ pub static U_RWX: i32 = (S_IRUSR | S_IWUSR | S_IXUSR) as i32;
 /// Creates a directory that is readable, writeable,
 /// and executable by the user. Returns true iff creation
 /// succeeded.
-pub fn make_dir_rwx(p: &Path) -> bool { os::make_dir(p, U_RWX) }
+pub fn make_dir_rwx(p: &Path) -> bool {
+    io::result(|| fs::mkdir(p, io::UserRWX)).is_ok()
+}
 
-pub fn make_dir_rwx_recursive(p: &Path) -> bool { os::mkdir_recursive(p, U_RWX) }
+pub fn make_dir_rwx_recursive(p: &Path) -> bool {
+    io::result(|| fs::mkdir_recursive(p, io::UserRWX)).is_ok()
+}
 
 // n.b. The next three functions ignore the package version right
 // now. Should fix that.
@@ -59,16 +64,17 @@ pub fn workspace_contains_package_id(pkgid: &PkgId, workspace: &Path) -> bool {
 pub fn workspace_contains_package_id_(pkgid: &PkgId, workspace: &Path,
 // Returns the directory it was actually found in
              workspace_to_src_dir: &fn(&Path) -> Path) -> Option<Path> {
-    if !os::path_is_dir(workspace) {
+    if !workspace.is_dir() {
         return None;
     }
 
     let src_dir = workspace_to_src_dir(workspace);
+    if !src_dir.is_dir() { return None }
 
     let mut found = None;
-    do os::walk_dir(&src_dir) |p| {
-        if os::path_is_dir(p) {
-            if *p == src_dir.join(&pkgid.path) || {
+    for p in fs::walk_dir(&src_dir) {
+        if p.is_dir() {
+            if p == src_dir.join(&pkgid.path) || {
                 let pf = p.filename_str();
                 do pf.iter().any |&g| {
                     match split_version_general(g, '-') {
@@ -83,9 +89,8 @@ pub fn workspace_contains_package_id_(pkgid: &PkgId, workspace: &Path,
                 found = Some(p.clone());
             }
 
-        };
-        true
-    };
+        }
+    }
 
     if found.is_some() {
         debug!("Found {} in {}", pkgid.to_str(), workspace.display());
@@ -125,7 +130,7 @@ pub fn built_executable_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option<
     result = mk_output_path(Main, Build, pkgid, result);
     debug!("built_executable_in_workspace: checking whether {} exists",
            result.display());
-    if os::path_exists(&result) {
+    if result.exists() {
         Some(result)
     }
     else {
@@ -152,7 +157,7 @@ fn output_in_workspace(pkgid: &PkgId, workspace: &Path, what: OutputType) -> Opt
     result = mk_output_path(what, Build, pkgid, result);
     debug!("output_in_workspace: checking whether {} exists",
            result.display());
-    if os::path_exists(&result) {
+    if result.exists() {
         Some(result)
     }
     else {
@@ -210,7 +215,7 @@ pub fn system_library(sysroot: &Path, lib_name: &str) -> Option<Path> {
 
 fn library_in(short_name: &str, version: &Version, dir_to_search: &Path) -> Option<Path> {
     debug!("Listing directory {}", dir_to_search.display());
-    let dir_contents = os::list_dir(dir_to_search);
+    let dir_contents = do io::ignore_io_error { fs::readdir(dir_to_search) };
     debug!("dir has {:?} entries", dir_contents.len());
 
     let lib_prefix = format!("{}{}", os::consts::DLL_PREFIX, short_name);
@@ -294,7 +299,7 @@ pub fn target_executable_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path {
 /// As a side effect, creates the lib-dir if it doesn't exist
 pub fn target_library_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path {
     use conditions::bad_path::cond;
-    if !os::path_is_dir(workspace) {
+    if !workspace.is_dir() {
         cond.raise(((*workspace).clone(),
                     format!("Workspace supplied to target_library_in_workspace \
                              is not a directory! {}", workspace.display())));
@@ -333,7 +338,7 @@ fn target_file_in_workspace(pkgid: &PkgId, workspace: &Path,
                 (Install, Lib)  => target_lib_dir(workspace),
                 (Install, _)    => target_bin_dir(workspace)
     };
-    if !os::path_exists(&result) && !mkdir_recursive(&result, U_RWX) {
+    if io::result(|| fs::mkdir_recursive(&result, io::UserRWX)).is_err() {
         cond.raise((result.clone(), format!("target_file_in_workspace couldn't \
             create the {} dir (pkgid={}, workspace={}, what={:?}, where={:?}",
             subdir, pkgid.to_str(), workspace.display(), what, where)));
@@ -344,18 +349,12 @@ fn target_file_in_workspace(pkgid: &PkgId, workspace: &Path,
 /// Return the directory for <pkgid>'s build artifacts in <workspace>.
 /// Creates it if it doesn't exist.
 pub fn build_pkg_id_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path {
-    use conditions::bad_path::cond;
-
     let mut result = target_build_dir(workspace);
     result.push(&pkgid.path);
     debug!("Creating build dir {} for package id {}", result.display(),
            pkgid.to_str());
-    if os::path_exists(&result) || os::mkdir_recursive(&result, U_RWX) {
-        result
-    }
-    else {
-        cond.raise((result, format!("Could not create directory for package {}", pkgid.to_str())))
-    }
+    fs::mkdir_recursive(&result, io::UserRWX);
+    return result;
 }
 
 /// Return the output file for a given directory name,
@@ -398,13 +397,13 @@ pub fn mk_output_path(what: OutputType, where: Target,
 pub fn uninstall_package_from(workspace: &Path, pkgid: &PkgId) {
     let mut did_something = false;
     let installed_bin = target_executable_in_workspace(pkgid, workspace);
-    if os::path_exists(&installed_bin) {
-        os::remove_file(&installed_bin);
+    if installed_bin.exists() {
+        fs::unlink(&installed_bin);
         did_something = true;
     }
     let installed_lib = target_library_in_workspace(pkgid, workspace);
-    if os::path_exists(&installed_lib) {
-        os::remove_file(&installed_lib);
+    if installed_lib.exists() {
+        fs::unlink(&installed_lib);
         did_something = true;
     }
     if !did_something {
@@ -421,7 +420,7 @@ pub fn dir_has_crate_file(dir: &Path) -> bool {
 
 fn dir_has_file(dir: &Path, file: &str) -> bool {
     assert!(dir.is_absolute());
-    os::path_exists(&dir.join(file))
+    dir.join(file).exists()
 }
 
 pub fn find_dir_using_rust_path_hack(p: &PkgId) -> Option<Path> {
diff --git a/src/librustpkg/source_control.rs b/src/librustpkg/source_control.rs
index c3e4205dfc9..bcda3168bd8 100644
--- a/src/librustpkg/source_control.rs
+++ b/src/librustpkg/source_control.rs
@@ -10,8 +10,9 @@
 
 // Utils for working with version control repositories. Just git right now.
 
-use std::{os, run, str};
+use std::{run, str};
 use std::run::{ProcessOutput, ProcessOptions, Process};
+use std::rt::io::fs;
 use extra::tempfile::TempDir;
 use version::*;
 use path_util::chmod_read_only;
@@ -22,14 +23,14 @@ use path_util::chmod_read_only;
 /// directory (that the callee may use, for example, to check out remote sources into).
 /// Returns `CheckedOutSources` if the clone succeeded.
 pub fn safe_git_clone(source: &Path, v: &Version, target: &Path) -> CloneResult {
-    if os::path_exists(source) {
+    if source.exists() {
         debug!("{} exists locally! Cloning it into {}",
                 source.display(), target.display());
         // Ok to use target here; we know it will succeed
-        assert!(os::path_is_dir(source));
+        assert!(source.is_dir());
         assert!(is_git_dir(source));
 
-        if !os::path_exists(target) {
+        if !target.exists() {
             debug!("Running: git clone {} {}", source.display(), target.display());
             // FIXME (#9639): This needs to handle non-utf8 paths
             let outp = run::process_output("git", [~"clone",
@@ -95,12 +96,11 @@ pub enum CloneResult {
 
 pub fn make_read_only(target: &Path) {
     // Now, make all the files in the target dir read-only
-    do os::walk_dir(target) |p| {
-        if !os::path_is_dir(p) {
-            assert!(chmod_read_only(p));
-        };
-        true
-    };
+    for p in fs::walk_dir(target) {
+        if !p.is_dir() {
+            assert!(chmod_read_only(&p));
+        }
+    }
 }
 
 /// Source can be either a URL or a local file path.
@@ -138,5 +138,5 @@ fn process_output_in_cwd(prog: &str, args: &[~str], cwd: &Path) -> ProcessOutput
 }
 
 pub fn is_git_dir(p: &Path) -> bool {
-    os::path_is_dir(&p.join(".git"))
+    p.join(".git").is_dir()
 }
diff --git a/src/librustpkg/tests.rs b/src/librustpkg/tests.rs
index 072c165cd96..6555fb88c90 100644
--- a/src/librustpkg/tests.rs
+++ b/src/librustpkg/tests.rs
@@ -13,8 +13,8 @@
 use context::{BuildContext, Context, RustcFlags};
 use std::{os, run, str, task};
 use std::rt::io;
-use std::rt::io::Writer;
-use std::rt::io::file::FileInfo;
+use std::rt::io::fs;
+use std::rt::io::File;
 use extra::arc::Arc;
 use extra::arc::RWArc;
 use extra::tempfile::TempDir;
@@ -27,7 +27,7 @@ use installed_packages::list_installed_packages;
 use package_id::{PkgId};
 use version::{ExactRevision, NoVersion, Version, Tagged};
 use path_util::{target_executable_in_workspace, target_test_in_workspace,
-               target_bench_in_workspace, make_dir_rwx, U_RWX,
+               target_bench_in_workspace, make_dir_rwx,
                library_in_workspace, installed_library_in_workspace,
                built_bench_in_workspace, built_test_in_workspace,
                built_library_in_workspace, built_executable_in_workspace, target_build_dir,
@@ -84,7 +84,7 @@ fn git_repo_pkg_with_tag(a_tag: ~str) -> PkgId {
 }
 
 fn writeFile(file_path: &Path, contents: &str) {
-    let mut out = file_path.open_writer(io::CreateOrTruncate);
+    let mut out = File::create(file_path);
     out.write(contents.as_bytes());
     out.write(['\n' as u8]);
 }
@@ -92,7 +92,7 @@ fn writeFile(file_path: &Path, contents: &str) {
 fn mk_emptier_workspace(tag: &str) -> TempDir {
     let workspace = TempDir::new(tag).expect("couldn't create temp dir");
     let package_dir = workspace.path().join("src");
-    assert!(os::mkdir_recursive(&package_dir, U_RWX));
+    fs::mkdir_recursive(&package_dir, io::UserRWX);
     workspace
 }
 
@@ -107,7 +107,7 @@ fn mk_workspace(workspace: &Path, short_name: &Path, version: &Version) -> Path
     // FIXME (#9639): This needs to handle non-utf8 paths
     let package_dir = workspace.join_many([~"src", format!("{}-{}",
                                            short_name.as_str().unwrap(), version.to_str())]);
-    assert!(os::mkdir_recursive(&package_dir, U_RWX));
+    fs::mkdir_recursive(&package_dir, io::UserRWX);
     package_dir
 }
 
@@ -120,12 +120,12 @@ fn mk_temp_workspace(short_name: &Path, version: &Version) -> (TempDir, Path) {
                                                               version.to_str())]);
 
     debug!("Created {} and does it exist? {:?}", package_dir.display(),
-          os::path_is_dir(&package_dir));
+           package_dir.is_dir());
     // Create main, lib, test, and bench files
     debug!("mk_workspace: creating {}", package_dir.display());
-    assert!(os::mkdir_recursive(&package_dir, U_RWX));
+    fs::mkdir_recursive(&package_dir, io::UserRWX);
     debug!("Created {} and does it exist? {:?}", package_dir.display(),
-          os::path_is_dir(&package_dir));
+           package_dir.is_dir());
     // Create main, lib, test, and bench files
 
     writeFile(&package_dir.join("main.rs"),
@@ -162,7 +162,7 @@ fn init_git_repo(p: &Path) -> TempDir {
     let tmp = TempDir::new("git_local").expect("couldn't create temp dir");
     let work_dir = tmp.path().join(p);
     let work_dir_for_opts = work_dir.clone();
-    assert!(os::mkdir_recursive(&work_dir, U_RWX));
+    fs::mkdir_recursive(&work_dir, io::UserRWX);
     debug!("Running: git init in {}", work_dir.display());
     run_git([~"init"], None, &work_dir_for_opts,
         format!("Couldn't initialize git repository in {}", work_dir.display()));
@@ -197,27 +197,13 @@ fn add_git_tag(repo: &Path, tag: ~str) {
 }
 
 fn is_rwx(p: &Path) -> bool {
-    use std::libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR};
-
-    match p.get_mode() {
-        None => return false,
-        Some(m) =>
-            ((m & S_IRUSR as uint) == S_IRUSR as uint
-            && (m & S_IWUSR as uint) == S_IWUSR as uint
-            && (m & S_IXUSR as uint) == S_IXUSR as uint)
-    }
+    if !p.exists() { return false }
+    p.stat().perm & io::UserRWX == io::UserRWX
 }
 
 fn is_read_only(p: &Path) -> bool {
-    use std::libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR};
-
-    match p.get_mode() {
-        None => return false,
-        Some(m) =>
-            ((m & S_IRUSR as uint) == S_IRUSR as uint
-            && (m & S_IWUSR as uint) == 0 as uint
-            && (m & S_IXUSR as uint) == 0 as uint)
-    }
+    if !p.exists() { return false }
+    p.stat().perm & io::UserRWX == io::UserRead
 }
 
 fn test_sysroot() -> Path {
@@ -289,7 +275,7 @@ fn command_line_test_with_env(args: &[~str], cwd: &Path, env: Option<~[(~str, ~s
         None        => ~""
     };
     debug!("{} cd {}; {} {}", env_str, cwd.display(), cmd, args.connect(" "));
-    assert!(os::path_is_dir(&*cwd));
+    assert!(cwd.is_dir());
     let cwd = (*cwd).clone();
     let mut prog = run::Process::new(cmd, args, run::ProcessOptions {
         env: env.map(|e| e + os::env()),
@@ -325,9 +311,9 @@ fn create_local_package_in(pkgid: &PkgId, pkgdir: &Path) -> Path {
     let package_dir = pkgdir.join_many([~"src", pkgid.to_str()]);
 
     // Create main, lib, test, and bench files
-    assert!(os::mkdir_recursive(&package_dir, U_RWX));
+    fs::mkdir_recursive(&package_dir, io::UserRWX);
     debug!("Created {} and does it exist? {:?}", package_dir.display(),
-          os::path_is_dir(&package_dir));
+           package_dir.is_dir());
     // Create main, lib, test, and bench files
 
     writeFile(&package_dir.join("main.rs"),
@@ -378,7 +364,7 @@ fn lib_exists(repo: &Path, pkg_path: &Path, _v: Version) -> bool { // ??? versio
     debug!("assert_lib_exists: checking whether {:?} exists", lib);
     lib.is_some() && {
         let libname = lib.get_ref();
-        os::path_exists(libname) && is_rwx(libname)
+        libname.exists() && is_rwx(libname)
     }
 }
 
@@ -389,21 +375,21 @@ fn assert_executable_exists(repo: &Path, short_name: &str) {
 fn executable_exists(repo: &Path, short_name: &str) -> bool {
     debug!("executable_exists: repo = {}, short_name = {}", repo.display(), short_name);
     let exec = target_executable_in_workspace(&PkgId::new(short_name), repo);
-    os::path_exists(&exec) && is_rwx(&exec)
+    exec.exists() && is_rwx(&exec)
 }
 
 fn test_executable_exists(repo: &Path, short_name: &str) -> bool {
     debug!("test_executable_exists: repo = {}, short_name = {}", repo.display(), short_name);
     let exec = built_test_in_workspace(&PkgId::new(short_name), repo);
     do exec.map_default(false) |exec| {
-        os::path_exists(&exec) && is_rwx(&exec)
+        exec.exists() && is_rwx(&exec)
     }
 }
 
 fn remove_executable_file(p: &PkgId, workspace: &Path) {
     let exec = target_executable_in_workspace(&PkgId::new(p.short_name), workspace);
-    if os::path_exists(&exec) {
-        assert!(os::remove_file(&exec));
+    if exec.exists() {
+        fs::unlink(&exec);
     }
 }
 
@@ -417,14 +403,14 @@ fn built_executable_exists(repo: &Path, short_name: &str) -> bool {
     let exec = built_executable_in_workspace(&PkgId::new(short_name), repo);
     exec.is_some() && {
        let execname = exec.get_ref();
-       os::path_exists(execname) && is_rwx(execname)
+       execname.exists() && is_rwx(execname)
     }
 }
 
 fn remove_built_executable_file(p: &PkgId, workspace: &Path) {
     let exec = built_executable_in_workspace(&PkgId::new(p.short_name), workspace);
     match exec {
-        Some(r) => assert!(os::remove_file(&r)),
+        Some(r) => fs::unlink(&r),
         None    => ()
     }
 }
@@ -446,8 +432,9 @@ fn llvm_bitcode_file_exists(repo: &Path, short_name: &str) -> bool {
 }
 
 fn file_exists(repo: &Path, short_name: &str, extension: &str) -> bool {
-    os::path_exists(&target_build_dir(repo).join_many([short_name.to_owned(),
-                                     format!("{}.{}", short_name, extension)]))
+    target_build_dir(repo).join_many([short_name.to_owned(),
+                                     format!("{}.{}", short_name, extension)])
+                          .exists()
 }
 
 fn assert_built_library_exists(repo: &Path, short_name: &str) {
@@ -459,7 +446,7 @@ fn built_library_exists(repo: &Path, short_name: &str) -> bool {
     let lib = built_library_in_workspace(&PkgId::new(short_name), repo);
     lib.is_some() && {
         let libname = lib.get_ref();
-        os::path_exists(libname) && is_rwx(libname)
+        libname.exists() && is_rwx(libname)
     }
 }
 
@@ -508,7 +495,7 @@ fn output_file_name(workspace: &Path, short_name: ~str) -> Path {
 fn touch_source_file(workspace: &Path, pkgid: &PkgId) {
     use conditions::bad_path::cond;
     let pkg_src_dir = workspace.join_many([~"src", pkgid.to_str()]);
-    let contents = os::list_dir_path(&pkg_src_dir);
+    let contents = fs::readdir(&pkg_src_dir);
     for p in contents.iter() {
         if p.extension_str() == Some("rs") {
             // should be able to do this w/o a process
@@ -527,7 +514,7 @@ fn touch_source_file(workspace: &Path, pkgid: &PkgId) {
 fn touch_source_file(workspace: &Path, pkgid: &PkgId) {
     use conditions::bad_path::cond;
     let pkg_src_dir = workspace.join_many([~"src", pkgid.to_str()]);
-    let contents = os::list_dir_path(&pkg_src_dir);
+    let contents = fs::readdir(&pkg_src_dir);
     for p in contents.iter() {
         if p.extension_str() == Some("rs") {
             // should be able to do this w/o a process
@@ -548,7 +535,7 @@ fn frob_source_file(workspace: &Path, pkgid: &PkgId, filename: &str) {
     let mut maybe_p = None;
     let maybe_file = pkg_src_dir.join(filename);
     debug!("Trying to frob {} -- {}", pkg_src_dir.display(), filename);
-    if os::path_exists(&maybe_file) {
+    if maybe_file.exists() {
         maybe_p = Some(maybe_file);
     }
     debug!("Frobbed? {:?}", maybe_p);
@@ -557,7 +544,7 @@ fn frob_source_file(workspace: &Path, pkgid: &PkgId, filename: &str) {
             do io::io_error::cond.trap(|e| {
                 cond.raise((p.clone(), format!("Bad path: {}", e.desc)));
             }).inside {
-                let mut w = p.open_writer(io::Append);
+                let mut w = File::open_mode(p, io::Append, io::Write);
                 w.write(bytes!("/* hi */\n"));
             }
         }
@@ -570,13 +557,14 @@ fn frob_source_file(workspace: &Path, pkgid: &PkgId, filename: &str) {
 fn test_make_dir_rwx() {
     let temp = &os::tmpdir();
     let dir = temp.join("quux");
-    assert!(!os::path_exists(&dir) ||
-            os::remove_dir_recursive(&dir));
+    if dir.exists() {
+        fs::rmdir_recursive(&dir);
+    }
     debug!("Trying to make {}", dir.display());
     assert!(make_dir_rwx(&dir));
-    assert!(os::path_is_dir(&dir));
+    assert!(dir.is_dir());
     assert!(is_rwx(&dir));
-    assert!(os::remove_dir_recursive(&dir));
+    fs::rmdir_recursive(&dir);
 }
 
 // n.b. I ignored the next two tests for now because something funny happens on linux
@@ -603,19 +591,19 @@ fn test_install_valid() {
     // Check that all files exist
     let exec = target_executable_in_workspace(&temp_pkg_id, temp_workspace);
     debug!("exec = {}", exec.display());
-    assert!(os::path_exists(&exec));
+    assert!(exec.exists());
     assert!(is_rwx(&exec));
 
     let lib = installed_library_in_workspace(&temp_pkg_id.path, temp_workspace);
     debug!("lib = {:?}", lib);
-    assert!(lib.as_ref().map_default(false, |l| os::path_exists(l)));
+    assert!(lib.as_ref().map_default(false, |l| l.exists()));
     assert!(lib.as_ref().map_default(false, |l| is_rwx(l)));
 
     // And that the test and bench executables aren't installed
-    assert!(!os::path_exists(&target_test_in_workspace(&temp_pkg_id, temp_workspace)));
+    assert!(!target_test_in_workspace(&temp_pkg_id, temp_workspace).exists());
     let bench = target_bench_in_workspace(&temp_pkg_id, temp_workspace);
     debug!("bench = {}", bench.display());
-    assert!(!os::path_exists(&bench));
+    assert!(!bench.exists());
 
     // Make sure the db isn't dirty, so that it doesn't try to save()
     // asynchronously after the temporary directory that it wants to save
@@ -655,19 +643,19 @@ fn test_install_valid_external() {
     // Check that all files exist
     let exec = target_executable_in_workspace(&temp_pkg_id, temp_workspace);
     debug!("exec = {}", exec.display());
-    assert!(os::path_exists(&exec));
+    assert!(exec.exists());
     assert!(is_rwx(&exec));
 
     let lib = installed_library_in_workspace(&temp_pkg_id.path, temp_workspace);
     debug!("lib = {:?}", lib);
-    assert!(lib.as_ref().map_default(false, |l| os::path_exists(l)));
+    assert!(lib.as_ref().map_default(false, |l| l.exists()));
     assert!(lib.as_ref().map_default(false, |l| is_rwx(l)));
 
     // And that the test and bench executables aren't installed
-    assert!(!os::path_exists(&target_test_in_workspace(&temp_pkg_id, temp_workspace)));
+    assert!(!target_test_in_workspace(&temp_pkg_id, temp_workspace).exists());
     let bench = target_bench_in_workspace(&temp_pkg_id, temp_workspace);
     debug!("bench = {}", bench.display());
-    assert!(!os::path_exists(&bench));
+    assert!(!bench.exists());
 
 }
 
@@ -711,7 +699,7 @@ fn test_install_git() {
     debug!("Checking for files in {}", ws.display());
     let exec = target_executable_in_workspace(&temp_pkg_id, &ws);
     debug!("exec = {}", exec.display());
-    assert!(os::path_exists(&exec));
+    assert!(exec.exists());
     assert!(is_rwx(&exec));
     let _built_lib =
         built_library_in_workspace(&temp_pkg_id,
@@ -719,17 +707,17 @@ fn test_install_git() {
     assert_lib_exists(&ws, &temp_pkg_id.path, temp_pkg_id.version.clone());
     let built_test = built_test_in_workspace(&temp_pkg_id,
                          &ws).expect("test_install_git: built test should exist");
-    assert!(os::path_exists(&built_test));
+    assert!(built_test.exists());
     let built_bench = built_bench_in_workspace(&temp_pkg_id,
                           &ws).expect("test_install_git: built bench should exist");
-    assert!(os::path_exists(&built_bench));
+    assert!(built_bench.exists());
     // And that the test and bench executables aren't installed
     let test = target_test_in_workspace(&temp_pkg_id, &ws);
-    assert!(!os::path_exists(&test));
+    assert!(!test.exists());
     debug!("test = {}", test.display());
     let bench = target_bench_in_workspace(&temp_pkg_id, &ws);
     debug!("bench = {}", bench.display());
-    assert!(!os::path_exists(&bench));
+    assert!(!bench.exists());
 }
 
 #[test]
@@ -783,6 +771,7 @@ fn test_package_version() {
     let repo = repo.path();
     let repo_subdir = repo.join_many(["mockgithub.com", "catamorphism", "test_pkg_version"]);
     debug!("Writing files in: {}", repo_subdir.display());
+    fs::mkdir_recursive(&repo_subdir, io::UserRWX);
     writeFile(&repo_subdir.join("main.rs"),
               "fn main() { let _x = (); }");
     writeFile(&repo_subdir.join("lib.rs"),
@@ -853,9 +842,9 @@ fn test_package_request_version() {
     let mut dir = target_build_dir(&repo.join(".rust"));
     dir.push(&Path::new("src/mockgithub.com/catamorphism/test_pkg_version-0.3"));
     debug!("dir = {}", dir.display());
-    assert!(os::path_is_dir(&dir));
-    assert!(os::path_exists(&dir.join("version-0.3-file.txt")));
-    assert!(!os::path_exists(&dir.join("version-0.4-file.txt")));
+    assert!(dir.is_dir());
+    assert!(dir.join("version-0.3-file.txt").exists());
+    assert!(!dir.join("version-0.4-file.txt").exists());
 }
 
 #[test]
@@ -904,16 +893,13 @@ fn package_script_with_default_build() {
     let source = Path::new(file!()).dir_path().join_many(
         [~"testsuite", ~"pass", ~"src", ~"fancy-lib", ~"pkg.rs"]);
     debug!("package_script_with_default_build: {}", source.display());
-    if !os::copy_file(&source,
-                      &dir.join_many(["src", "fancy-lib-0.1", "pkg.rs"])) {
-        fail!("Couldn't copy file");
-    }
+    fs::copy(&source, &dir.join_many(["src", "fancy-lib-0.1", "pkg.rs"]));
     command_line_test([~"install", ~"fancy-lib"], dir);
     assert_lib_exists(dir, &Path::new("fancy-lib"), NoVersion);
-    assert!(os::path_exists(&target_build_dir(dir).join_many([~"fancy-lib", ~"generated.rs"])));
+    assert!(target_build_dir(dir).join_many([~"fancy-lib", ~"generated.rs"]).exists());
     let generated_path = target_build_dir(dir).join_many([~"fancy-lib", ~"generated.rs"]);
     debug!("generated path = {}", generated_path.display());
-    assert!(os::path_exists(&generated_path));
+    assert!(generated_path.exists());
 }
 
 #[test]
@@ -921,7 +907,7 @@ fn rustpkg_build_no_arg() {
     let tmp = TempDir::new("rustpkg_build_no_arg").expect("rustpkg_build_no_arg failed");
     let tmp = tmp.path().join(".rust");
     let package_dir = tmp.join_many(["src", "foo"]);
-    assert!(os::mkdir_recursive(&package_dir, U_RWX));
+    fs::mkdir_recursive(&package_dir, io::UserRWX);
 
     writeFile(&package_dir.join("main.rs"),
               "fn main() { let _x = (); }");
@@ -935,7 +921,7 @@ fn rustpkg_install_no_arg() {
     let tmp = TempDir::new("rustpkg_install_no_arg").expect("rustpkg_install_no_arg failed");
     let tmp = tmp.path().join(".rust");
     let package_dir = tmp.join_many(["src", "foo"]);
-    assert!(os::mkdir_recursive(&package_dir, U_RWX));
+    fs::mkdir_recursive(&package_dir, io::UserRWX);
     writeFile(&package_dir.join("lib.rs"),
               "fn main() { let _x = (); }");
     debug!("install_no_arg: dir = {}", package_dir.display());
@@ -948,7 +934,7 @@ fn rustpkg_clean_no_arg() {
     let tmp = TempDir::new("rustpkg_clean_no_arg").expect("rustpkg_clean_no_arg failed");
     let tmp = tmp.path().join(".rust");
     let package_dir = tmp.join_many(["src", "foo"]);
-    assert!(os::mkdir_recursive(&package_dir, U_RWX));
+    fs::mkdir_recursive(&package_dir, io::UserRWX);
 
     writeFile(&package_dir.join("main.rs"),
               "fn main() { let _x = (); }");
@@ -957,7 +943,7 @@ fn rustpkg_clean_no_arg() {
     assert_built_executable_exists(&tmp, "foo");
     command_line_test([~"clean"], &package_dir);
     let res = built_executable_in_workspace(&PkgId::new("foo"), &tmp);
-    assert!(!res.as_ref().map_default(false, |m| { os::path_exists(m) }));
+    assert!(!res.as_ref().map_default(false, |m| m.exists()));
 }
 
 #[test]
@@ -983,9 +969,9 @@ fn rust_path_test() {
 fn rust_path_contents() {
     let dir = TempDir::new("rust_path").expect("rust_path_contents failed");
     let abc = &dir.path().join_many(["A", "B", "C"]);
-    assert!(os::mkdir_recursive(&abc.join(".rust"), U_RWX));
-    assert!(os::mkdir_recursive(&abc.with_filename(".rust"), U_RWX));
-    assert!(os::mkdir_recursive(&abc.dir_path().with_filename(".rust"), U_RWX));
+    fs::mkdir_recursive(&abc.join(".rust"), io::UserRWX);
+    fs::mkdir_recursive(&abc.with_filename(".rust"), io::UserRWX);
+    fs::mkdir_recursive(&abc.dir_path().with_filename(".rust"), io::UserRWX);
     assert!(os::change_dir(abc));
 
     let p = rust_path();
@@ -1225,8 +1211,8 @@ fn test_non_numeric_tag() {
                                            temp_pkg_id.path.as_str().unwrap())], repo);
     let file1 = repo.join_many(["mockgithub.com", "catamorphism", "test-pkg", "testbranch_only"]);
     let file2 = repo.join_many(["mockgithub.com", "catamorphism", "test-pkg", "master_only"]);
-    assert!(os::path_exists(&file1));
-    assert!(!os::path_exists(&file2));
+    assert!(file1.exists());
+    assert!(!file2.exists());
 }
 
 #[test]
@@ -1237,11 +1223,11 @@ fn test_extern_mod() {
     let lib_depend_dir = TempDir::new("foo").expect("test_extern_mod");
     let lib_depend_dir = lib_depend_dir.path();
     let aux_dir = lib_depend_dir.join_many(["src", "mockgithub.com", "catamorphism", "test_pkg"]);
-    assert!(os::mkdir_recursive(&aux_dir, U_RWX));
+    fs::mkdir_recursive(&aux_dir, io::UserRWX);
     let aux_pkg_file = aux_dir.join("lib.rs");
 
     writeFile(&aux_pkg_file, "pub mod bar { pub fn assert_true() {  assert!(true); } }\n");
-    assert!(os::path_exists(&aux_pkg_file));
+    assert!(aux_pkg_file.exists());
 
     writeFile(&main_file,
               "extern mod test = \"mockgithub.com/catamorphism/test_pkg\";\nuse test::bar;\
@@ -1275,7 +1261,7 @@ fn test_extern_mod() {
               str::from_utf8(outp.output),
               str::from_utf8(outp.error));
     }
-    assert!(os::path_exists(&exec_file) && is_executable(&exec_file));
+    assert!(exec_file.exists() && is_executable(&exec_file));
 }
 
 #[test]
@@ -1286,11 +1272,11 @@ fn test_extern_mod_simpler() {
     let lib_depend_dir = TempDir::new("foo").expect("test_extern_mod_simpler");
     let lib_depend_dir = lib_depend_dir.path();
     let aux_dir = lib_depend_dir.join_many(["src", "rust-awesomeness"]);
-    assert!(os::mkdir_recursive(&aux_dir, U_RWX));
+    fs::mkdir_recursive(&aux_dir, io::UserRWX);
     let aux_pkg_file = aux_dir.join("lib.rs");
 
     writeFile(&aux_pkg_file, "pub mod bar { pub fn assert_true() {  assert!(true); } }\n");
-    assert!(os::path_exists(&aux_pkg_file));
+    assert!(aux_pkg_file.exists());
 
     writeFile(&main_file,
               "extern mod test = \"rust-awesomeness\";\nuse test::bar;\
@@ -1330,7 +1316,7 @@ fn test_extern_mod_simpler() {
               str::from_utf8(outp.output),
               str::from_utf8(outp.error));
     }
-    assert!(os::path_exists(&exec_file) && is_executable(&exec_file));
+    assert!(exec_file.exists() && is_executable(&exec_file));
 }
 
 #[test]
@@ -1342,8 +1328,8 @@ fn test_import_rustpkg() {
               "extern mod rustpkg; fn main() {}");
     command_line_test([~"build", ~"foo"], workspace);
     debug!("workspace = {}", workspace.display());
-    assert!(os::path_exists(&target_build_dir(workspace).join("foo").join(format!("pkg{}",
-        os::EXE_SUFFIX))));
+    assert!(target_build_dir(workspace).join("foo").join(format!("pkg{}",
+        os::EXE_SUFFIX)).exists());
 }
 
 #[test]
@@ -1355,8 +1341,8 @@ fn test_macro_pkg_script() {
               "extern mod rustpkg; fn main() { debug!(\"Hi\"); }");
     command_line_test([~"build", ~"foo"], workspace);
     debug!("workspace = {}", workspace.display());
-    assert!(os::path_exists(&target_build_dir(workspace).join("foo").join(format!("pkg{}",
-        os::EXE_SUFFIX))));
+    assert!(target_build_dir(workspace).join("foo").join(format!("pkg{}",
+        os::EXE_SUFFIX)).exists());
 }
 
 #[test]
@@ -1436,7 +1422,7 @@ fn rust_path_hack_cwd() {
    // Same as rust_path_hack_test, but the CWD is the dir to build out of
    let cwd = TempDir::new("foo").expect("rust_path_hack_cwd");
    let cwd = cwd.path().join("foo");
-   assert!(os::mkdir_recursive(&cwd, U_RWX));
+   fs::mkdir_recursive(&cwd, io::UserRWX);
    writeFile(&cwd.join("lib.rs"), "pub fn f() { }");
 
    let dest_workspace = mk_empty_workspace(&Path::new("bar"), &NoVersion, "dest_workspace");
@@ -1456,7 +1442,7 @@ fn rust_path_hack_multi_path() {
    // Same as rust_path_hack_test, but with a more complex package ID
    let cwd = TempDir::new("pkg_files").expect("rust_path_hack_cwd");
    let subdir = cwd.path().join_many(["foo", "bar", "quux"]);
-   assert!(os::mkdir_recursive(&subdir, U_RWX));
+   fs::mkdir_recursive(&subdir, io::UserRWX);
    writeFile(&subdir.join("lib.rs"), "pub fn f() { }");
    let name = ~"foo/bar/quux";
 
@@ -1870,21 +1856,22 @@ fn pkgid_pointing_to_subdir() {
     // rustpkg should recognize that and treat the part after some_repo/ as a subdir
     let workspace = TempDir::new("parent_repo").expect("Couldn't create temp dir");
     let workspace = workspace.path();
-    assert!(os::mkdir_recursive(&workspace.join_many(["src", "mockgithub.com",
-                                                      "mozilla", "some_repo"]), U_RWX));
+    fs::mkdir_recursive(&workspace.join_many(["src", "mockgithub.com",
+                                                "mozilla", "some_repo"]),
+                          io::UserRWX);
 
     let foo_dir = workspace.join_many(["src", "mockgithub.com", "mozilla", "some_repo",
                                        "extras", "foo"]);
     let bar_dir = workspace.join_many(["src", "mockgithub.com", "mozilla", "some_repo",
                                        "extras", "bar"]);
-    assert!(os::mkdir_recursive(&foo_dir, U_RWX));
-    assert!(os::mkdir_recursive(&bar_dir, U_RWX));
+    fs::mkdir_recursive(&foo_dir, io::UserRWX);
+    fs::mkdir_recursive(&bar_dir, io::UserRWX);
     writeFile(&foo_dir.join("lib.rs"), "pub fn f() {}");
     writeFile(&bar_dir.join("lib.rs"), "pub fn g() {}");
 
     debug!("Creating a file in {}", workspace.display());
     let testpkg_dir = workspace.join_many(["src", "testpkg-0.1"]);
-    assert!(os::mkdir_recursive(&testpkg_dir, U_RWX));
+    fs::mkdir_recursive(&testpkg_dir, io::UserRWX);
 
     writeFile(&testpkg_dir.join("main.rs"),
               "extern mod foo = \"mockgithub.com/mozilla/some_repo/extras/foo\";\n
@@ -1957,9 +1944,9 @@ fn test_target_specific_build_dir() {
                        ~"build",
                        ~"foo"],
                       workspace);
-    assert!(os::path_is_dir(&target_build_dir(workspace)));
+    assert!(target_build_dir(workspace).is_dir());
     assert!(built_executable_exists(workspace, "foo"));
-    assert!(os::list_dir(&workspace.join("build")).len() == 1);
+    assert!(fs::readdir(&workspace.join("build")).len() == 1);
 }
 
 #[test]
@@ -1973,10 +1960,10 @@ fn test_target_specific_install_dir() {
                        ~"install",
                        ~"foo"],
                       workspace);
-    assert!(os::path_is_dir(&workspace.join_many([~"lib", host_triple()])));
+    assert!(workspace.join_many([~"lib", host_triple()]).is_dir());
     assert_lib_exists(workspace, &Path::new("foo"), NoVersion);
-    assert!(os::list_dir(&workspace.join("lib")).len() == 1);
-    assert!(os::path_is_dir(&workspace.join("bin")));
+    assert!(fs::readdir(&workspace.join("lib")).len() == 1);
+    assert!(workspace.join("bin").is_dir());
     assert_executable_exists(workspace, "foo");
 }
 
@@ -1988,7 +1975,7 @@ fn test_dependencies_terminate() {
     let workspace = workspace.path();
     let b_dir = workspace.join_many(["src", "b-0.1"]);
     let b_subdir = b_dir.join("test");
-    assert!(os::mkdir_recursive(&b_subdir, U_RWX));
+    fs::mkdir_recursive(&b_subdir, io::UserRWX);
     writeFile(&b_subdir.join("test.rs"),
               "extern mod b; use b::f; #[test] fn g() { f() }");
     command_line_test([~"install", ~"b"], workspace);
@@ -2176,19 +2163,19 @@ fn test_installed_read_only() {
     debug!("Checking for files in {}", ws.display());
     let exec = target_executable_in_workspace(&temp_pkg_id, &ws);
     debug!("exec = {}", exec.display());
-    assert!(os::path_exists(&exec));
+    assert!(exec.exists());
     assert!(is_rwx(&exec));
     let built_lib =
         built_library_in_workspace(&temp_pkg_id,
                                    &ws).expect("test_install_git: built lib should exist");
-    assert!(os::path_exists(&built_lib));
+    assert!(built_lib.exists());
     assert!(is_rwx(&built_lib));
 
     // Make sure sources are (a) under "build" and (b) read-only
     let src1 = target_build_dir(&ws).join_many([~"src", temp_pkg_id.to_str(), ~"main.rs"]);
     let src2 = target_build_dir(&ws).join_many([~"src", temp_pkg_id.to_str(), ~"lib.rs"]);
-    assert!(os::path_exists(&src1));
-    assert!(os::path_exists(&src2));
+    assert!(src1.exists());
+    assert!(src2.exists());
     assert!(is_read_only(&src1));
     assert!(is_read_only(&src2));
 }
@@ -2201,7 +2188,7 @@ fn test_installed_local_changes() {
     debug!("repo = {}", repo.display());
     let repo_subdir = repo.join_many(["mockgithub.com", "catamorphism", "test-pkg"]);
     debug!("repo_subdir = {}", repo_subdir.display());
-    assert!(os::mkdir_recursive(&repo.join_many([".rust", "src"]), U_RWX));
+    fs::mkdir_recursive(&repo.join_many([".rust", "src"]), io::UserRWX);
 
     writeFile(&repo_subdir.join("main.rs"),
               "fn main() { let _x = (); }");
@@ -2284,7 +2271,7 @@ fn find_sources_in_cwd() {
     let temp_dir = TempDir::new("sources").expect("find_sources_in_cwd failed");
     let temp_dir = temp_dir.path();
     let source_dir = temp_dir.join("foo");
-    os::mkdir_recursive(&source_dir, U_RWX);
+    fs::mkdir_recursive(&source_dir, io::UserRWX);
     writeFile(&source_dir.join("main.rs"),
               "fn main() { let _x = (); }");
     command_line_test([~"install", ~"foo"], &source_dir);
@@ -2307,16 +2294,13 @@ fn test_c_dependency_ok() {
     debug!("dir = {}", dir.display());
     let source = Path::new(file!()).dir_path().join_many(
         [~"testsuite", ~"pass", ~"src", ~"c-dependencies", ~"pkg.rs"]);
-    if !os::copy_file(&source,
-                      &dir.join_many([~"src", ~"cdep-0.1", ~"pkg.rs"])) {
-        fail!("Couldn't copy file");
-    }
+    fs::copy(&source, &dir.join_many([~"src", ~"cdep-0.1", ~"pkg.rs"]));
     command_line_test([~"build", ~"cdep"], dir);
     assert_executable_exists(dir, "cdep");
     let out_dir = target_build_dir(dir).join("cdep");
     let c_library_path = out_dir.join(platform_library_name("foo"));
     debug!("c library path: {}", c_library_path.display());
-    assert!(os::path_exists(&c_library_path));
+    assert!(c_library_path.exists());
 }
 
 #[test]
@@ -2331,16 +2315,13 @@ fn test_c_dependency_no_rebuilding() {
     debug!("dir = {}", dir.display());
     let source = Path::new(file!()).dir_path().join_many(
         [~"testsuite", ~"pass", ~"src", ~"c-dependencies", ~"pkg.rs"]);
-    if !os::copy_file(&source,
-                      &dir.join_many([~"src", ~"cdep-0.1", ~"pkg.rs"])) {
-        fail!("Couldn't copy file");
-    }
+    fs::copy(&source, &dir.join_many([~"src", ~"cdep-0.1", ~"pkg.rs"]));
     command_line_test([~"build", ~"cdep"], dir);
     assert_executable_exists(dir, "cdep");
     let out_dir = target_build_dir(dir).join("cdep");
     let c_library_path = out_dir.join(platform_library_name("foo"));
     debug!("c library path: {}", c_library_path.display());
-    assert!(os::path_exists(&c_library_path));
+    assert!(c_library_path.exists());
 
     // Now, make it read-only so rebuilding will fail
     assert!(chmod_read_only(&c_library_path));
@@ -2367,15 +2348,13 @@ fn test_c_dependency_yes_rebuilding() {
         [~"testsuite", ~"pass", ~"src", ~"c-dependencies", ~"pkg.rs"]);
     let target = dir.join_many([~"src", ~"cdep-0.1", ~"pkg.rs"]);
     debug!("Copying {} -> {}", source.display(), target.display());
-    if !os::copy_file(&source, &target) {
-        fail!("Couldn't copy file");
-    }
+    fs::copy(&source, &target);
     command_line_test([~"build", ~"cdep"], dir);
     assert_executable_exists(dir, "cdep");
     let out_dir = target_build_dir(dir).join("cdep");
     let c_library_path = out_dir.join(platform_library_name("foo"));
     debug!("c library path: {}", c_library_path.display());
-    assert!(os::path_exists(&c_library_path));
+    assert!(c_library_path.exists());
 
     // Now, make the Rust library read-only so rebuilding will fail
     match built_library_in_workspace(&PkgId::new("cdep"), dir) {
@@ -2393,10 +2372,5 @@ fn test_c_dependency_yes_rebuilding() {
 
 /// Returns true if p exists and is executable
 fn is_executable(p: &Path) -> bool {
-    use std::libc::consts::os::posix88::{S_IXUSR};
-
-    match p.get_mode() {
-        None => false,
-        Some(mode) => mode & S_IXUSR as uint == S_IXUSR as uint
-    }
+    p.exists() && p.stat().perm & io::UserExecute == io::UserExecute
 }
diff --git a/src/librustpkg/testsuite/pass/src/c-dependencies/foo.rs b/src/librustpkg/testsuite/pass/src/c-dependencies/foo.rs
index 542a6af402d..3b233c9f6a8 100644
--- a/src/librustpkg/testsuite/pass/src/c-dependencies/foo.rs
+++ b/src/librustpkg/testsuite/pass/src/c-dependencies/foo.rs
@@ -9,4 +9,4 @@
 // except according to those terms.
 
 pub fn do_nothing() {
-}
\ No newline at end of file
+}
diff --git a/src/librustpkg/testsuite/pass/src/c-dependencies/pkg.rs b/src/librustpkg/testsuite/pass/src/c-dependencies/pkg.rs
index 016635339a9..f5d6317e7a6 100644
--- a/src/librustpkg/testsuite/pass/src/c-dependencies/pkg.rs
+++ b/src/librustpkg/testsuite/pass/src/c-dependencies/pkg.rs
@@ -31,7 +31,7 @@ pub fn main() {
 
     let sysroot_arg = args[1].clone();
     let sysroot = Path::new(sysroot_arg);
-    if !os::path_exists(&sysroot) {
+    if !sysroot.exists() {
         fail!("Package script requires a sysroot that exists; {} doesn't", sysroot.display());
     }
 
diff --git a/src/librustpkg/testsuite/pass/src/fancy-lib/pkg.rs b/src/librustpkg/testsuite/pass/src/fancy-lib/pkg.rs
index f82c585b1d1..1c3bf897bec 100644
--- a/src/librustpkg/testsuite/pass/src/fancy-lib/pkg.rs
+++ b/src/librustpkg/testsuite/pass/src/fancy-lib/pkg.rs
@@ -12,9 +12,7 @@ extern mod rustpkg;
 extern mod rustc;
 
 use std::os;
-use std::rt::io;
-use std::rt::io::Writer;
-use std::rt::io::file::FileInfo;
+use std::rt::io::File;
 use rustpkg::api;
 use rustpkg::version::NoVersion;
 
@@ -30,7 +28,7 @@ pub fn main() {
 
     let sysroot_arg = args[1].clone();
     let sysroot = Path::new(sysroot_arg);
-    if !os::path_exists(&sysroot) {
+    if !sysroot.exists() {
         debug!("Failing, sysroot");
         fail!("Package script requires a sysroot that exists;{} doesn't", sysroot.display());
     }
@@ -45,7 +43,7 @@ pub fn main() {
     let out_path = os::self_exe_path().expect("Couldn't get self_exe path");
 
     debug!("Writing file");
-    let mut file = out_path.join("generated.rs").open_writer(io::Create);
+    let mut file = File::create(&out_path.join("generated.rs"));
     file.write("pub fn wheeeee() { let xs = [1, 2, 3]; \
                 for _ in xs.iter() { assert!(true); } }".as_bytes());
 
diff --git a/src/librustpkg/util.rs b/src/librustpkg/util.rs
index 9d835dcc20b..ec7771c2ab5 100644
--- a/src/librustpkg/util.rs
+++ b/src/librustpkg/util.rs
@@ -10,6 +10,8 @@
 
 use std::libc;
 use std::os;
+use std::rt::io;
+use std::rt::io::fs;
 use extra::workcache;
 use rustc::driver::{driver, session};
 use extra::getopts::groups::getopts;
@@ -32,7 +34,6 @@ use path_util::{default_workspace, built_library_in_workspace};
 pub use target::{OutputType, Main, Lib, Bench, Test, JustOne, lib_name_of, lib_crate_filename};
 pub use target::{Target, Build, Install};
 use extra::treemap::TreeMap;
-use path_util::U_RWX;
 pub use target::{lib_name_of, lib_crate_filename, WhatToBuild, MaybeCustom, Inferred};
 use workcache_support::{digest_file_with_date, digest_only_date};
 
@@ -184,7 +185,7 @@ pub fn compile_input(context: &BuildContext,
     let mut out_dir = target_build_dir(workspace);
     out_dir.push(&pkg_id.path);
     // Make the output directory if it doesn't exist already
-    assert!(os::mkdir_recursive(&out_dir, U_RWX));
+    fs::mkdir_recursive(&out_dir, io::UserRWX);
 
     let binary = os::args()[0].to_managed();
 
@@ -256,11 +257,11 @@ pub fn compile_input(context: &BuildContext,
     // Make sure all the library directories actually exist, since the linker will complain
     // otherwise
     for p in addl_lib_search_paths.iter() {
-        if os::path_exists(p) {
-            assert!(os::path_is_dir(p));
+        if p.exists() {
+            assert!(p.is_dir())
         }
         else {
-            assert!(os::mkdir_recursive(p, U_RWX));
+            fs::mkdir_recursive(p, io::UserRWX);
         }
     }
 
@@ -324,7 +325,7 @@ pub fn compile_input(context: &BuildContext,
     };
     for p in discovered_output.iter() {
         debug!("About to discover output {}", p.display());
-        if os::path_exists(p) {
+        if p.exists() {
             debug!("4. discovering output {}", p.display());
             // FIXME (#9639): This needs to handle non-utf8 paths
             exec.discover_output("binary", p.as_str().unwrap(), digest_only_date(p));
@@ -629,10 +630,16 @@ fn debug_flags() -> ~[~str] { ~[] }
 
 /// Returns the last-modified date as an Option
 pub fn datestamp(p: &Path) -> Option<libc::time_t> {
-    debug!("Scrutinizing datestamp for {} - does it exist? {:?}", p.display(), os::path_exists(p));
-    let out = p.stat().map(|stat| stat.modified);
-    debug!("Date = {:?}", out);
-    out.map(|t| { t as libc::time_t })
+    debug!("Scrutinizing datestamp for {} - does it exist? {:?}", p.display(),
+           p.exists());
+    match io::result(|| p.stat()) {
+        Ok(s) => {
+            let out = s.modified;
+            debug!("Date = {:?}", out);
+            Some(out as libc::time_t)
+        }
+        Err(*) => None,
+    }
 }
 
 pub type DepMap = TreeMap<~str, ~[(~str, ~str)]>;
diff --git a/src/librustpkg/version.rs b/src/librustpkg/version.rs
index 6ca19562724..eff16cb9996 100644
--- a/src/librustpkg/version.rs
+++ b/src/librustpkg/version.rs
@@ -14,7 +14,7 @@
 extern mod std;
 
 use extra::semver;
-use std::{char, os, result, run, str};
+use std::{char, result, run, str};
 use extra::tempfile::TempDir;
 use path_util::rust_path;
 
@@ -100,7 +100,7 @@ pub fn try_getting_local_version(local_path: &Path) -> Option<Version> {
     for rp in rustpath.iter() {
         let local_path = rp.join(local_path);
         let git_dir = local_path.join(".git");
-        if !os::path_is_dir(&git_dir) {
+        if !git_dir.is_dir() {
             continue;
         }
         // FIXME (#9639): This needs to handle non-utf8 paths
diff --git a/src/librustpkg/workcache_support.rs b/src/librustpkg/workcache_support.rs
index 2e4894b854d..d8b35f2c033 100644
--- a/src/librustpkg/workcache_support.rs
+++ b/src/librustpkg/workcache_support.rs
@@ -9,32 +9,23 @@
 // except according to those terms.
 
 use std::rt::io;
-use std::rt::io::Reader;
-use std::rt::io::file::FileInfo;
+use std::rt::io::File;
 use extra::workcache;
 use sha1::{Digest, Sha1};
 
 /// Hashes the file contents along with the last-modified time
 pub fn digest_file_with_date(path: &Path) -> ~str {
     use conditions::bad_path::cond;
-    use cond1 = conditions::bad_stat::cond;
 
-    let mut err = None;
-    let bytes = do io::io_error::cond.trap(|e| err = Some(e)).inside {
-        path.open_reader(io::Open).read_to_end()
-    };
-    match err {
-        None => {
+    match io::result(|| File::open(path).read_to_end()) {
+        Ok(bytes) => {
             let mut sha = Sha1::new();
             sha.input(bytes);
-            let st = match path.stat() {
-                Some(st) => st,
-                None => cond1.raise((path.clone(), format!("Couldn't get file access time")))
-            };
+            let st = path.stat();
             sha.input_str(st.modified.to_str());
             sha.result_str()
         }
-        Some(e) => {
+        Err(e) => {
             cond.raise((path.clone(), format!("Couldn't read file: {}", e.desc)));
             ~""
         }
@@ -43,13 +34,8 @@ pub fn digest_file_with_date(path: &Path) -> ~str {
 
 /// Hashes only the last-modified time
 pub fn digest_only_date(path: &Path) -> ~str {
-    use cond = conditions::bad_stat::cond;
-
     let mut sha = Sha1::new();
-    let st = match path.stat() {
-                Some(st) => st,
-                None => cond.raise((path.clone(), format!("Couldn't get file access time")))
-    };
+    let st = path.stat();
     sha.input_str(st.modified.to_str());
     sha.result_str()
 }
diff --git a/src/librustpkg/workspace.rs b/src/librustpkg/workspace.rs
index a3550037246..e65f3ce5bb6 100644
--- a/src/librustpkg/workspace.rs
+++ b/src/librustpkg/workspace.rs
@@ -52,7 +52,7 @@ pub fn pkg_parent_workspaces(cx: &Context, pkgid: &PkgId) -> ~[Path] {
 }
 
 pub fn is_workspace(p: &Path) -> bool {
-    os::path_is_dir(&p.join("src"))
+    p.join("src").is_dir()
 }
 
 /// Construct a workspace and package-ID name based on the current directory.