@@ -492,7 +492,7 @@ pub fn run(mut krate: clean::Crate,
492492 }
493493 }
494494 }
495- try_err ! ( mkdir ( & dst) , & dst) ;
495+ try_err ! ( fs :: create_dir_all ( & dst) , & dst) ;
496496 krate = render_sources ( & dst, & mut scx, krate) ?;
497497 let cx = Context {
498498 current : Vec :: new ( ) ,
@@ -658,7 +658,7 @@ fn write_shared(cx: &Context,
658658 // Write out the shared files. Note that these are shared among all rustdoc
659659 // docs placed in the output directory, so this needs to be a synchronized
660660 // operation with respect to all other rustdocs running around.
661- try_err ! ( mkdir ( & cx. dst) , & cx. dst) ;
661+ try_err ! ( fs :: create_dir_all ( & cx. dst) , & cx. dst) ;
662662 let _lock = flock:: Lock :: panicking_new ( & cx. dst . join ( ".lock" ) , true , true , true ) ;
663663
664664 // Add all the static files. These may already exist, but we just
@@ -808,10 +808,8 @@ fn write_shared(cx: &Context,
808808fn render_sources ( dst : & Path , scx : & mut SharedContext ,
809809 krate : clean:: Crate ) -> Result < clean:: Crate , Error > {
810810 info ! ( "emitting source files" ) ;
811- let dst = dst. join ( "src" ) ;
812- try_err ! ( mkdir( & dst) , & dst) ;
813- let dst = dst. join ( & krate. name ) ;
814- try_err ! ( mkdir( & dst) , & dst) ;
811+ let dst = dst. join ( "src" ) . join ( & krate. name ) ;
812+ try_err ! ( fs:: create_dir_all( & dst) , & dst) ;
815813 let mut folder = SourceCollector {
816814 dst : dst,
817815 scx : scx,
@@ -825,19 +823,6 @@ fn write(dst: PathBuf, contents: &[u8]) -> Result<(), Error> {
825823 Ok ( try_err ! ( try_err!( File :: create( & dst) , & dst) . write_all( contents) , & dst) )
826824}
827825
828- /// Makes a directory on the filesystem, failing the thread if an error occurs
829- /// and skipping if the directory already exists.
830- ///
831- /// Note that this also handles races as rustdoc is likely to be run
832- /// concurrently against another invocation.
833- fn mkdir ( path : & Path ) -> io:: Result < ( ) > {
834- match fs:: create_dir ( path) {
835- Ok ( ( ) ) => Ok ( ( ) ) ,
836- Err ( ref e) if e. kind ( ) == io:: ErrorKind :: AlreadyExists => Ok ( ( ) ) ,
837- Err ( e) => Err ( e)
838- }
839- }
840-
841826/// Takes a path to a source file and cleans the path to it. This canonicalizes
842827/// things like ".." to components which preserve the "top down" hierarchy of a
843828/// static HTML tree. Each component in the cleaned path will be passed as an
@@ -951,7 +936,7 @@ impl<'a> SourceCollector<'a> {
951936 let mut href = String :: new ( ) ;
952937 clean_srcpath ( & self . scx . src_root , & p, false , |component| {
953938 cur. push ( component) ;
954- mkdir ( & cur) . unwrap ( ) ;
939+ fs :: create_dir_all ( & cur) . unwrap ( ) ;
955940 root_path. push_str ( "../" ) ;
956941 href. push_str ( component) ;
957942 href. push ( '/' ) ;
0 commit comments