From 94c90e79e1681cf2ff1b1ef0a641f203ccbd2b9c Mon Sep 17 00:00:00 2001 From: Oliver Middleton Date: Mon, 7 Aug 2017 16:04:46 +0100 Subject: [PATCH] rustbuild: Replace create_dir_racy with create_dir_all `create_dir_all` has since been fixed so no need for `create_dir_racy`. --- src/build_helper/lib.rs | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/src/build_helper/lib.rs b/src/build_helper/lib.rs index 7011261ab6c16..8b4c7f2ac3177 100644 --- a/src/build_helper/lib.rs +++ b/src/build_helper/lib.rs @@ -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}; @@ -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 { @@ -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), - } -}