Skip to content

Commit 9bd7134

Browse files
committed
Auto merge of #5285 - matklad:create-all-the-dirs, r=alexcrichton
Replace home-grown create_dir_all with std::fs::create_dir_all The old one is just the historical artifact, right?
2 parents 18ec7db + 5d0ce40 commit 9bd7134

File tree

1 file changed

+2
-24
lines changed

1 file changed

+2
-24
lines changed

src/cargo/util/flock.rs

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl Filesystem {
141141
/// Handles errors where other Cargo processes are also attempting to
142142
/// concurrently create this directory.
143143
pub fn create_dir(&self) -> io::Result<()> {
144-
create_dir_all(&self.root)
144+
fs::create_dir_all(&self.root)
145145
}
146146

147147
/// Returns an adaptor that can be used to print the path of this
@@ -211,7 +211,7 @@ impl Filesystem {
211211
let f = opts.open(&path)
212212
.or_else(|e| {
213213
if e.kind() == io::ErrorKind::NotFound && state == State::Exclusive {
214-
create_dir_all(path.parent().unwrap())?;
214+
fs::create_dir_all(path.parent().unwrap())?;
215215
opts.open(&path)
216216
} else {
217217
Err(e)
@@ -344,25 +344,3 @@ fn acquire(
344344
false
345345
}
346346
}
347-
348-
fn create_dir_all(path: &Path) -> io::Result<()> {
349-
match create_dir(path) {
350-
Ok(()) => Ok(()),
351-
Err(e) => {
352-
if e.kind() == io::ErrorKind::NotFound {
353-
if let Some(p) = path.parent() {
354-
return create_dir_all(p).and_then(|()| create_dir(path));
355-
}
356-
}
357-
Err(e)
358-
}
359-
}
360-
}
361-
362-
fn create_dir(path: &Path) -> io::Result<()> {
363-
match fs::create_dir(path) {
364-
Ok(()) => Ok(()),
365-
Err(ref e) if e.kind() == io::ErrorKind::AlreadyExists => Ok(()),
366-
Err(e) => Err(e),
367-
}
368-
}

0 commit comments

Comments
 (0)