File tree Expand file tree Collapse file tree 1 file changed +22
-6
lines changed Expand file tree Collapse file tree 1 file changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -110,12 +110,28 @@ impl Tool {
110110            cargo_output :  & CargoOutput , 
111111            out_dir :  Option < & Path > , 
112112        )  -> Result < ToolFamily ,  Error >  { 
113-             let  tmp = NamedTempfile :: new ( 
114-                 & out_dir
115-                     . map ( Cow :: Borrowed ) 
116-                     . unwrap_or_else ( || Cow :: Owned ( env:: temp_dir ( ) ) ) , 
117-                 "detect_compiler_family.c" , 
118-             ) ?; 
113+             let  out_dir = out_dir
114+                 . map ( Cow :: Borrowed ) 
115+                 . unwrap_or_else ( || Cow :: Owned ( env:: temp_dir ( ) ) ) ; 
116+ 
117+             // Ensure all the parent directories exist otherwise temp file creation 
118+             // will fail 
119+             std:: fs:: create_dir_all ( & out_dir) . map_err ( |err| Error  { 
120+                 kind :  ErrorKind :: IOError , 
121+                 message :  format ! ( "failed to create OUT_DIR '{}': {}" ,  out_dir. display( ) ,  err) 
122+                     . into ( ) , 
123+             } ) ?; 
124+ 
125+             let  tmp =
126+                 NamedTempfile :: new ( & out_dir,  "detect_compiler_family.c" ) . map_err ( |err| Error  { 
127+                     kind :  ErrorKind :: IOError , 
128+                     message :  format ! ( 
129+                         "failed to create detect_compiler_family.c temp file in '{}': {}" , 
130+                         out_dir. display( ) , 
131+                         err
132+                     ) 
133+                     . into ( ) , 
134+                 } ) ?; 
119135            tmp. file ( ) 
120136                . write_all ( include_bytes ! ( "detect_compiler_family.c" ) ) ?; 
121137
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments