@@ -369,10 +369,13 @@ impl FromInner<libc::HANDLE> for File {
369
369
370
370
impl fmt:: Debug for File {
371
371
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 ( )
376
379
}
377
380
}
378
381
@@ -582,11 +585,7 @@ pub fn utimes(p: &Path, atime: u64, mtime: u64) -> io::Result<()> {
582
585
Ok ( ( ) )
583
586
}
584
587
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 > {
590
589
super :: fill_utf16_buf ( |buf, sz| unsafe {
591
590
c:: GetFinalPathNameByHandleW ( f. handle . raw ( ) , buf, sz,
592
591
libc:: VOLUME_NAME_DOS )
@@ -595,6 +594,13 @@ pub fn canonicalize(p: &Path) -> io::Result<PathBuf> {
595
594
} )
596
595
}
597
596
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
+
598
604
pub fn copy ( from : & Path , to : & Path ) -> io:: Result < u64 > {
599
605
unsafe extern "system" fn callback (
600
606
_TotalFileSize : libc:: LARGE_INTEGER ,
0 commit comments