File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -402,6 +402,19 @@ pub fn create_dir(path: &str, mode: AccessPermission) -> io::Result<()> {
402402 } )
403403}
404404
405+ /// Creates a directory and creates all missing parent directories as well.
406+ fn create_dir_recursive ( path : & str , mode : AccessPermission ) -> io:: Result < ( ) > {
407+ trace ! ( "create_dir_recursive: {path}" ) ;
408+ create_dir ( path, mode) . or_else ( |errno| {
409+ if errno != Errno :: Badf {
410+ return Err ( errno) ;
411+ }
412+ let parent_path = & path[ 0 ..path. rfind ( '/' ) . unwrap ( ) ] ;
413+ create_dir_recursive ( parent_path, mode) ?;
414+ create_dir ( path, mode)
415+ } )
416+ }
417+
405418/// Returns an vector with all the entries within a directory.
406419pub fn readdir ( name : & str ) -> io:: Result < Vec < DirectoryEntry > > {
407420 debug ! ( "Read directory {name}" ) ;
You can’t perform that action at this time.
0 commit comments