@@ -313,10 +313,10 @@ impl Gen {
313313 let dst = self . opts . out_dir . join ( artifact. destination ) ;
314314
315315 if src. is_file ( ) {
316- self . copy_file ( & src, & dst, true )
316+ self . copy_lib ( & src, & dst)
317317 . unwrap_or_else ( |err| panic ! ( "Failed to copy file {}: {err}" , src. display( ) ) ) ;
318318 } else if src. is_dir ( ) {
319- self . copy_dir ( & src, & dst, true )
319+ self . copy_lib_dir ( & src, & dst)
320320 . unwrap_or_else ( |err| panic ! ( "Failed to copy dir {}: {err}" , src. display( ) ) ) ;
321321 } else {
322322 panic ! (
@@ -357,24 +357,28 @@ impl Gen {
357357 }
358358 }
359359
360- fn copy_file ( & self , src : & Path , dst : & Path , is_library : bool ) -> io:: Result < ( ) > {
360+ fn copy_lib ( & self , src : & Path , dst : & Path ) -> io:: Result < ( ) > {
361361 if let Some ( parent) = dst. parent ( ) {
362362 fs:: create_dir_all ( parent) ?;
363363 }
364364
365- let dst = if is_library {
366- dst. parent ( )
367- . unwrap ( )
368- . join ( "lib" . to_owned ( ) + dst. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) )
369- } else {
370- dst. to_path_buf ( )
371- } ;
365+ let file_name = "lib" . to_string ( )
366+ + dst
367+ . file_name ( )
368+ . ok_or ( io:: Error :: new ( io:: ErrorKind :: InvalidFilename , "" ) ) ?
369+ . to_str ( )
370+ . ok_or ( io:: Error :: new ( io:: ErrorKind :: InvalidFilename , "" ) ) ?;
371+
372+ let dst = dst
373+ . parent ( )
374+ . unwrap_or ( & Path :: new ( "" ) )
375+ . join ( file_name. to_ascii_lowercase ( ) ) ;
372376
373377 fs:: copy ( src, dst) ?;
374378 Ok ( ( ) )
375379 }
376380
377- fn copy_dir ( & self , src : & Path , dst : & Path , is_library : bool ) -> io:: Result < ( ) > {
381+ fn copy_lib_dir ( & self , src : & Path , dst : & Path ) -> io:: Result < ( ) > {
378382 if !dst. exists ( ) {
379383 fs:: create_dir_all ( dst) ?;
380384 }
@@ -383,9 +387,9 @@ impl Gen {
383387 let path = entry. path ( ) ;
384388 let target = dst. join ( entry. file_name ( ) ) ;
385389 if path. is_dir ( ) {
386- self . copy_dir ( & path, & target, is_library ) ?;
390+ self . copy_lib_dir ( & path, & target) ?;
387391 } else {
388- self . copy_file ( & path, & target, is_library ) ?;
392+ self . copy_lib ( & path, & target) ?;
389393 }
390394 }
391395 Ok ( ( ) )
0 commit comments