about summary refs log tree commit diff
path: root/src/libstd/tempfile.rs
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2012-08-24 15:28:43 -0700
committerGraydon Hoare <graydon@mozilla.com>2012-08-24 15:51:16 -0700
commitc284b8b1dc348ab8b9c82350dd1b4e53fac1225c (patch)
tree99de39b149969275f6f9ddebd7a9f555d91c5bff /src/libstd/tempfile.rs
parenta8f1bee4574b8427a052e2fad93a90839288584b (diff)
downloadrust-c284b8b1dc348ab8b9c82350dd1b4e53fac1225c.tar.gz
rust-c284b8b1dc348ab8b9c82350dd1b4e53fac1225c.zip
Start using core::path2::Path in a lot of places.
Diffstat (limited to 'src/libstd/tempfile.rs')
-rw-r--r--src/libstd/tempfile.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/libstd/tempfile.rs b/src/libstd/tempfile.rs
index a4e68c78bba..8aa798d4576 100644
--- a/src/libstd/tempfile.rs
+++ b/src/libstd/tempfile.rs
@@ -4,13 +4,14 @@ import core::option;
 import option::{none, some};
 import rand;
 
-fn mkdtemp(prefix: ~str, suffix: ~str) -> option<~str> {
+fn mkdtemp(tmpdir: &Path, suffix: &str) -> option<Path> {
     let r = rand::rng();
     let mut i = 0u;
     while (i < 1000u) {
-        let s = prefix + r.gen_str(16u) + suffix;
-        if os::make_dir(s, 0x1c0i32) {  // FIXME: u+rwx (#2349)
-            return some(s);
+        let p = tmpdir.push(r.gen_str(16u) +
+                            str::from_slice(suffix));
+        if os::make_dir(&p, 0x1c0i32) {  // FIXME: u+rwx (#2349)
+            return some(p);
         }
         i += 1u;
     }
@@ -19,11 +20,11 @@ fn mkdtemp(prefix: ~str, suffix: ~str) -> option<~str> {
 
 #[test]
 fn test_mkdtemp() {
-    let r = mkdtemp(~"./", ~"foobar");
+    let r = mkdtemp(&Path("."), "foobar");
     match r {
         some(p) => {
-            os::remove_dir(p);
-            assert(str::ends_with(p, ~"foobar"));
+            os::remove_dir(&p);
+            assert(str::ends_with(p.to_str(), "foobar"));
         }
         _ => assert(false)
     }