@@ -369,10 +369,13 @@ impl FromInner<libc::HANDLE> for File {
369369
370370impl fmt:: Debug for File {
371371 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
372- // FIXME(#24570): add more info here (e.g. path, mode)
373- f. debug_struct ( "File" )
374- . field ( "handle" , & self . handle . raw ( ) )
375- . finish ( )
372+ // FIXME(#24570): add more info here (e.g. mode)
373+ let mut b = f. debug_struct ( "File" ) ;
374+ b. field ( "handle" , & self . handle . raw ( ) ) ;
375+ if let Ok ( path) = get_path ( & self ) {
376+ b. field ( "path" , & path) ;
377+ }
378+ b. finish ( )
376379 }
377380}
378381
@@ -582,11 +585,7 @@ pub fn utimes(p: &Path, atime: u64, mtime: u64) -> io::Result<()> {
582585 Ok ( ( ) )
583586}
584587
585- pub fn canonicalize ( p : & Path ) -> io:: Result < PathBuf > {
586-
587- let mut opts = OpenOptions :: new ( ) ;
588- opts. read ( true ) ;
589- let f = try!( File :: open ( p, & opts) ) ;
588+ fn get_path ( f : & File ) -> io:: Result < PathBuf > {
590589 super :: fill_utf16_buf ( |buf, sz| unsafe {
591590 c:: GetFinalPathNameByHandleW ( f. handle . raw ( ) , buf, sz,
592591 libc:: VOLUME_NAME_DOS )
@@ -595,6 +594,13 @@ pub fn canonicalize(p: &Path) -> io::Result<PathBuf> {
595594 } )
596595}
597596
597+ pub fn canonicalize ( p : & Path ) -> io:: Result < PathBuf > {
598+ let mut opts = OpenOptions :: new ( ) ;
599+ opts. read ( true ) ;
600+ let f = try!( File :: open ( p, & opts) ) ;
601+ get_path ( & f)
602+ }
603+
598604pub fn copy ( from : & Path , to : & Path ) -> io:: Result < u64 > {
599605 unsafe extern "system" fn callback (
600606 _TotalFileSize : libc:: LARGE_INTEGER ,
0 commit comments