From e374c911af9a723e513d947244e5e5b0c847f006 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Mon, 27 Jun 2022 09:41:12 -0700 Subject: [PATCH 1/2] Stabilize Windows `FileTypeExt` with `is_symlink_dir` and `is_symlink_file` These calls allow detecting whether a symlink is a file or a directory, a distinction Windows maintains, and one important to software that wants to do further operations on the symlink (e.g. removing it). --- library/std/src/os/windows/fs.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/std/src/os/windows/fs.rs b/library/std/src/os/windows/fs.rs index f15baff59dbfb..1e2a307ec36eb 100644 --- a/library/std/src/os/windows/fs.rs +++ b/library/std/src/os/windows/fs.rs @@ -502,17 +502,17 @@ impl MetadataExt for Metadata { /// Windows-specific extensions to [`fs::FileType`]. /// /// On Windows, a symbolic link knows whether it is a file or directory. -#[unstable(feature = "windows_file_type_ext", issue = "none")] +#[stable(feature = "windows_file_type_ext", since = "1.64.0")] pub trait FileTypeExt { /// Returns `true` if this file type is a symbolic link that is also a directory. - #[unstable(feature = "windows_file_type_ext", issue = "none")] + #[stable(feature = "windows_file_type_ext", since = "1.64.0")] fn is_symlink_dir(&self) -> bool; /// Returns `true` if this file type is a symbolic link that is also a file. - #[unstable(feature = "windows_file_type_ext", issue = "none")] + #[stable(feature = "windows_file_type_ext", since = "1.64.0")] fn is_symlink_file(&self) -> bool; } -#[unstable(feature = "windows_file_type_ext", issue = "none")] +#[stable(feature = "windows_file_type_ext", since = "1.64.0")] impl FileTypeExt for fs::FileType { fn is_symlink_dir(&self) -> bool { self.as_inner().is_symlink_dir() From a4cb0b90c049fd8bc6a4a13edad69d34b98627f0 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Mon, 27 Jun 2022 09:57:56 -0700 Subject: [PATCH 2/2] Seal Windows `FileTypeExt` extension trait to allow adding future methods --- library/std/src/os/windows/fs.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/library/std/src/os/windows/fs.rs b/library/std/src/os/windows/fs.rs index 1e2a307ec36eb..a091f06dd532c 100644 --- a/library/std/src/os/windows/fs.rs +++ b/library/std/src/os/windows/fs.rs @@ -7,6 +7,7 @@ use crate::fs::{self, Metadata, OpenOptions}; use crate::io; use crate::path::Path; +use crate::sealed::Sealed; use crate::sys; use crate::sys_common::{AsInner, AsInnerMut}; @@ -503,7 +504,7 @@ impl MetadataExt for Metadata { /// /// On Windows, a symbolic link knows whether it is a file or directory. #[stable(feature = "windows_file_type_ext", since = "1.64.0")] -pub trait FileTypeExt { +pub trait FileTypeExt: Sealed { /// Returns `true` if this file type is a symbolic link that is also a directory. #[stable(feature = "windows_file_type_ext", since = "1.64.0")] fn is_symlink_dir(&self) -> bool; @@ -512,6 +513,9 @@ pub trait FileTypeExt { fn is_symlink_file(&self) -> bool; } +#[stable(feature = "windows_file_type_ext", since = "1.64.0")] +impl Sealed for fs::FileType {} + #[stable(feature = "windows_file_type_ext", since = "1.64.0")] impl FileTypeExt for fs::FileType { fn is_symlink_dir(&self) -> bool {