about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorTim Chevalier <chevalier@alum.wellesley.edu>2013-05-02 13:09:28 -0700
committerTim Chevalier <chevalier@alum.wellesley.edu>2013-05-03 16:06:07 -0700
commit4d4cabff9ede49ae3642b05c4cfb023a0a9222b2 (patch)
tree18a2cb8d37c681056772201e2115f1b5bb61a7de /src/libstd
parentbfd3cd8171bee519093f570264e5a2b1dc17e9d8 (diff)
downloadrust-4d4cabff9ede49ae3642b05c4cfb023a0a9222b2.tar.gz
rust-4d4cabff9ede49ae3642b05c4cfb023a0a9222b2.zip
rustpkg: Implement install command
    The install command should work now, though it only installs
    in-place (anything else has to wait until I implement RUST_PATH).

Also including:
    core: Add remove_directory_recursive, change copy_file

    Make copy_file preserve permissions, and add a remove_directory_recursive
    function.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/tempfile.rs26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/libstd/tempfile.rs b/src/libstd/tempfile.rs
index 6da74834b1a..3d4e5bb8b79 100644
--- a/src/libstd/tempfile.rs
+++ b/src/libstd/tempfile.rs
@@ -27,7 +27,8 @@ pub fn mkdtemp(tmpdir: &Path, suffix: &str) -> Option<Path> {
 mod tests {
     use tempfile::mkdtemp;
     use tempfile;
-
+    use core::os;
+    
     #[test]
     fn test_mkdtemp() {
         let p = mkdtemp(&Path("."), "foobar").unwrap();
@@ -89,4 +90,27 @@ mod tests {
             assert!(os::path_is_dir(&path2.pop()));
         });
     }
+
+    // Ideally this would be in core, but needs mkdtemp
+    #[test]
+    pub fn test_rmdir_recursive_ok() {
+        use core::libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR};
+        use core::os;
+
+        let rwx = (S_IRUSR | S_IWUSR | S_IXUSR) as i32;
+
+        let tmpdir = mkdtemp(&os::tmpdir(), "test").expect("test_rmdir_recursive_ok: \
+                                            couldn't create temp dir");
+        let root = tmpdir.push("foo");
+
+        debug!("making %s", root.to_str());
+        assert!(os::make_dir(&root, rwx));
+        assert!(os::make_dir(&root.push("foo"), rwx));
+        assert!(os::make_dir(&root.push("foo").push("bar"), rwx));
+        assert!(os::make_dir(&root.push("foo").push("bar").push("blat"), rwx));
+        assert!(os::remove_dir_recursive(&root));
+        assert!(!os::path_exists(&root));
+        assert!(!os::path_exists(&root.push("bar")));
+        assert!(!os::path_exists(&root.push("bar").push("blat")));
+    }
 }