Skip to content

Commit 691ce23

Browse files
committed
Auto merge of #27150 - retep998:where-are-my-files, r=alexcrichton
cc #24570 r? @alexcrichton
2 parents f9f0e44 + 1e79917 commit 691ce23

File tree

1 file changed

+15
-9
lines changed
  • src/libstd/sys/windows

1 file changed

+15
-9
lines changed

src/libstd/sys/windows/fs.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,13 @@ impl FromInner<libc::HANDLE> for File {
369369

370370
impl 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+
598604
pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
599605
unsafe extern "system" fn callback(
600606
_TotalFileSize: libc::LARGE_INTEGER,

0 commit comments

Comments
 (0)