Skip to content

Commit

Permalink
rustbuild: Replace create_dir_racy with create_dir_all
Browse files Browse the repository at this point in the history
`create_dir_all` has since been fixed so no need for `create_dir_racy`.
  • Loading branch information
ollie27 committed Aug 7, 2017
1 parent 9593637 commit 94c90e7
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions src/build_helper/lib.rs
Expand Up @@ -13,7 +13,6 @@
extern crate filetime;

use std::fs::File;
use std::io;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use std::{fs, env};
Expand Down Expand Up @@ -211,7 +210,7 @@ pub fn native_lib_boilerplate(src_name: &str,

let out_dir = env::var_os("RUSTBUILD_NATIVE_DIR").unwrap_or(env::var_os("OUT_DIR").unwrap());
let out_dir = PathBuf::from(out_dir).join(out_name);
t!(create_dir_racy(&out_dir));
t!(fs::create_dir_all(&out_dir));
if link_name.contains('=') {
println!("cargo:rustc-link-lib={}", link_name);
} else {
Expand Down Expand Up @@ -260,21 +259,3 @@ fn fail(s: &str) -> ! {
println!("\n\n{}\n\n", s);
std::process::exit(1);
}

fn create_dir_racy(path: &Path) -> io::Result<()> {
match fs::create_dir(path) {
Ok(()) => return Ok(()),
Err(ref e) if e.kind() == io::ErrorKind::AlreadyExists => return Ok(()),
Err(ref e) if e.kind() == io::ErrorKind::NotFound => {}
Err(e) => return Err(e),
}
match path.parent() {
Some(p) => try!(create_dir_racy(p)),
None => return Err(io::Error::new(io::ErrorKind::Other, "failed to create whole tree")),
}
match fs::create_dir(path) {
Ok(()) => Ok(()),
Err(ref e) if e.kind() == io::ErrorKind::AlreadyExists => Ok(()),
Err(e) => Err(e),
}
}

0 comments on commit 94c90e7

Please sign in to comment.