From 68ab2c1f478fd78ca0503c18c6fd65a4f876e8aa Mon Sep 17 00:00:00 2001 From: WrldEngine Date: Mon, 27 Oct 2025 02:43:08 +0500 Subject: [PATCH 1/3] fix: from implementation of debug for file, added more info --- library/std/src/sys/fs/windows.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/library/std/src/sys/fs/windows.rs b/library/std/src/sys/fs/windows.rs index f2d325da35c7d..e60c70fcb4406 100644 --- a/library/std/src/sys/fs/windows.rs +++ b/library/std/src/sys/fs/windows.rs @@ -1022,12 +1022,25 @@ impl FromRawHandle for File { impl fmt::Debug for File { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - // FIXME(#24570): add more info here (e.g., mode) let mut b = f.debug_struct("File"); b.field("handle", &self.handle.as_raw_handle()); if let Ok(path) = get_path(self) { b.field("path", &path); } + + if let Ok(file_attr) = self.file_attr() { + b.field("read", &true); + if file_attr.perm().readonly() { + b.field("write", &false); + } else { + b.field("write", &true); + } + + // Getting analogue of file mode (unix) using file attributes + // See https://learn.microsoft.com/ru-ru/windows/win32/fileio/file-attribute-constants + b.field("attrs", &file_attr.attributes); + } + b.finish() } } From 98a7209d21aa6ffc301dafabc8ec062d404093fc Mon Sep 17 00:00:00 2001 From: WrldEngine Date: Mon, 27 Oct 2025 03:24:11 +0500 Subject: [PATCH 2/3] chore: change docs url language path --- library/std/src/sys/fs/windows.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/sys/fs/windows.rs b/library/std/src/sys/fs/windows.rs index e60c70fcb4406..824e55a26b5bd 100644 --- a/library/std/src/sys/fs/windows.rs +++ b/library/std/src/sys/fs/windows.rs @@ -1037,7 +1037,7 @@ impl fmt::Debug for File { } // Getting analogue of file mode (unix) using file attributes - // See https://learn.microsoft.com/ru-ru/windows/win32/fileio/file-attribute-constants + // See https://learn.microsoft.com/windows/win32/fileio/file-attribute-constants b.field("attrs", &file_attr.attributes); } From 33fbf385d2df314d708dad9136e7dd45b3995636 Mon Sep 17 00:00:00 2001 From: Kamran Pulatov <84636918+WrldEngine@users.noreply.github.com> Date: Mon, 27 Oct 2025 16:33:23 +0500 Subject: [PATCH 3/3] chore: library/std/src/sys/fs/windows.rs Co-authored-by: Marijn Schouten --- library/std/src/sys/fs/windows.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/library/std/src/sys/fs/windows.rs b/library/std/src/sys/fs/windows.rs index 824e55a26b5bd..05b4764004206 100644 --- a/library/std/src/sys/fs/windows.rs +++ b/library/std/src/sys/fs/windows.rs @@ -1030,11 +1030,7 @@ impl fmt::Debug for File { if let Ok(file_attr) = self.file_attr() { b.field("read", &true); - if file_attr.perm().readonly() { - b.field("write", &false); - } else { - b.field("write", &true); - } + b.field("write", file_attr.perm().readonly()); // Getting analogue of file mode (unix) using file attributes // See https://learn.microsoft.com/windows/win32/fileio/file-attribute-constants