Skip to content

Commit 697d710

Browse files
committed
fix: from FIXME(#24570) added more info
1 parent 58b4453 commit 697d710

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

library/std/src/sys/fs/windows.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,12 +1022,25 @@ impl FromRawHandle for File {
10221022

10231023
impl fmt::Debug for File {
10241024
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1025-
// FIXME(#24570): add more info here (e.g., mode)
10261025
let mut b = f.debug_struct("File");
10271026
b.field("handle", &self.handle.as_raw_handle());
10281027
if let Ok(path) = get_path(self) {
10291028
b.field("path", &path);
10301029
}
1030+
1031+
if let Ok(file_attr) = self.file_attr() {
1032+
b.field("read", &true);
1033+
if file_attr.perm().readonly() {
1034+
b.field("write", &false);
1035+
} else {
1036+
b.field("write", &true);
1037+
}
1038+
1039+
// Getting analogue of file mode (unix) using file attributes
1040+
// See https://learn.microsoft.com/ru-ru/windows/win32/fileio/file-attribute-constants
1041+
b.field("attrs", &file_attr.attributes);
1042+
}
1043+
10311044
b.finish()
10321045
}
10331046
}

0 commit comments

Comments
 (0)