Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize Windows FileTypeExt with is_symlink_dir and is_symlink_file #98583

Merged
merged 2 commits into from
Jul 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions library/std/src/os/windows/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -502,17 +503,20 @@ 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")]
pub trait FileTypeExt {
#[stable(feature = "windows_file_type_ext", since = "1.64.0")]
pub trait FileTypeExt: Sealed {
/// 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 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 {
self.as_inner().is_symlink_dir()
Expand Down