Replace home-grown create_dir_all with std::fs::create_dir_all
authorAleksey Kladov <aleksey.kladov@gmail.com>
Tue, 3 Apr 2018 13:14:14 +0000 (16:14 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Tue, 3 Apr 2018 13:14:14 +0000 (16:14 +0300)
src/cargo/util/flock.rs
src/cargo/util/toml/mod.rs

index bba61fbf53ff880e4127ba5dbe2c0dd714de0b0b..c2929756a6142e666ffd7393ae1afdf75f13b9ab 100644 (file)
@@ -141,7 +141,7 @@ impl Filesystem {
     /// Handles errors where other Cargo processes are also attempting to
     /// concurrently create this directory.
     pub fn create_dir(&self) -> io::Result<()> {
-        create_dir_all(&self.root)
+        fs::create_dir_all(&self.root)
     }
 
     /// Returns an adaptor that can be used to print the path of this
@@ -211,7 +211,7 @@ impl Filesystem {
         let f = opts.open(&path)
             .or_else(|e| {
                 if e.kind() == io::ErrorKind::NotFound && state == State::Exclusive {
-                    create_dir_all(path.parent().unwrap())?;
+                    fs::create_dir_all(path.parent().unwrap())?;
                     opts.open(&path)
                 } else {
                     Err(e)
@@ -344,25 +344,3 @@ fn acquire(
         false
     }
 }
-
-fn create_dir_all(path: &Path) -> io::Result<()> {
-    match create_dir(path) {
-        Ok(()) => Ok(()),
-        Err(e) => {
-            if e.kind() == io::ErrorKind::NotFound {
-                if let Some(p) = path.parent() {
-                    return create_dir_all(p).and_then(|()| create_dir(path));
-                }
-            }
-            Err(e)
-        }
-    }
-}
-
-fn create_dir(path: &Path) -> io::Result<()> {
-    match fs::create_dir(path) {
-        Ok(()) => Ok(()),
-        Err(ref e) if e.kind() == io::ErrorKind::AlreadyExists => Ok(()),
-        Err(e) => Err(e),
-    }
-}
index 3aa4f58755086f34a578c0350e6b65b7e035c91e..651928efdb430ce9463cd10d7bbf168e07684245 100644 (file)
@@ -14,7 +14,7 @@ use url::Url;
 
 use core::{GitReference, PackageIdSpec, Profiles, SourceId, WorkspaceConfig, WorkspaceRootConfig};
 use core::{Dependency, Manifest, PackageId, Summary, Target};
-use core::{EitherManifest, Edition, Feature, Features, VirtualManifest};
+use core::{Edition, EitherManifest, Feature, Features, VirtualManifest};
 use core::dependency::{Kind, Platform};
 use core::manifest::{LibKind, Lto, ManifestMetadata, Profile};
 use sources::CRATES_IO;