We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 62f1d68 commit 0fcd5d5Copy full SHA for 0fcd5d5
src/libstd/io/fs.rs
@@ -528,10 +528,25 @@ pub fn mkdir_recursive(path: &Path, mode: FilePermission) -> IoResult<()> {
528
if path.is_dir() {
529
return Ok(())
530
}
531
- if path.filename().is_some() {
532
- try!(mkdir_recursive(&path.dir_path(), mode));
+
+ let mut comps = path.components();
533
+ let mut curpath = path.root_path().unwrap_or(Path::new("."));
534
535
+ for c in comps {
536
+ curpath.push(c);
537
538
+ match mkdir(&curpath, mode) {
539
+ Err(mkdir_err) => {
540
+ // already exists ?
541
+ if try!(stat(&curpath)).kind != io::TypeDirectory {
542
+ return Err(mkdir_err);
543
+ }
544
545
+ Ok(()) => ()
546
547
- mkdir(path, mode)
548
549
+ Ok(())
550
551
552
/// Removes a directory at this path, after removing all its contents. Use
0 commit comments