Skip to content

Commit 0a8c039

Browse files
committed
Merge pull request #4506 from thestinger/mkdtemp
clean up tempfile module and rm FIXME
2 parents fa4f4fa + 4688033 commit 0a8c039

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

src/libstd/tempfile.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -19,26 +19,18 @@ use core::str;
1919

2020
pub fn mkdtemp(tmpdir: &Path, suffix: &str) -> Option<Path> {
2121
let r = rand::Rng();
22-
let mut i = 0u;
23-
while (i < 1000u) {
24-
let p = tmpdir.push(r.gen_str(16u) +
25-
str::from_slice(suffix));
26-
if os::make_dir(&p, 0x1c0i32) { // FIXME: u+rwx (#2349)
22+
for 1000.times {
23+
let p = tmpdir.push(r.gen_str(16) + suffix);
24+
if os::make_dir(&p, 0x1c0) { // 700
2725
return Some(p);
2826
}
29-
i += 1u;
3027
}
31-
return None;
28+
None
3229
}
3330

3431
#[test]
3532
fn test_mkdtemp() {
36-
let r = mkdtemp(&Path("."), "foobar");
37-
match r {
38-
Some(ref p) => {
39-
os::remove_dir(p);
40-
assert(str::ends_with(p.to_str(), "foobar"));
41-
}
42-
_ => assert(false)
43-
}
33+
let p = mkdtemp(&Path("."), "foobar").unwrap();
34+
os::remove_dir(&p);
35+
assert str::ends_with(p.to_str(), "foobar");
4436
}

0 commit comments

Comments
 (0)