File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -528,10 +528,25 @@ pub fn mkdir_recursive(path: &Path, mode: FilePermission) -> IoResult<()> {
528528 if path. is_dir ( ) {
529529 return Ok ( ( ) )
530530 }
531- if path. filename ( ) . is_some ( ) {
532- try!( mkdir_recursive ( & path. dir_path ( ) , mode) ) ;
531+
532+ 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+ }
533547 }
534- mkdir ( path, mode)
548+
549+ Ok ( ( ) )
535550}
536551
537552/// Removes a directory at this path, after removing all its contents. Use
You can’t perform that action at this time.
0 commit comments