Start using core::path2::Path in a lot of places.
This commit is contained in:
parent
a8f1bee457
commit
c284b8b1dc
43 changed files with 1139 additions and 1115 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ fn run_tests_console(opts: test_opts,
|
|||
}
|
||||
|
||||
let log_out = match opts.logfile {
|
||||
some(path) => match io::file_writer(path,
|
||||
some(path) => match io::file_writer(&Path(path),
|
||||
~[io::Create, io::Truncate]) {
|
||||
result::ok(w) => some(w),
|
||||
result::err(s) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue