pub fn from_path(path: impl AsRef<Path>, dereference: bool) -> Option<Self> {
        #[cfg(unix)]
        {
            let stat = if dereference {
                nix::sys::stat::stat(path.as_ref())
            } else {
                nix::sys::stat::lstat(path.as_ref())
            };
            if let Ok(stat) = stat {
                Some(Self(stat))
            } else {
                None
            }
        }
        #[cfg(target_os = "windows")]
        {
            use std::fs::OpenOptions;
            use std::os::windows::prelude::*;
            let mut open_options = OpenOptions::new();
            if !dereference {
                open_options.custom_flags(winapi::um::winbase::FILE_FLAG_OPEN_REPARSE_POINT);
            }
            open_options
                .read(true)
                .open(path.as_ref())
                .ok()
                .and_then(|file| Self::from_file(&file))
        }
    }
/// Get information for a given path.
///
/// If `path` points to a symlink and `dereference` is true, information about
/// the link's target will be returned.
Get information for a given path.
If `path` points to a symlink and `dereference` is true, information about
the link's target will be returned.
Get information for a given path . If ` path ` points to a symlink and ` dereference ` is true information about the link ' s target will be returned .
pub fn from_path(path: impl AsRef<Path>, dereference: bool) -> Option<Self> {
        #[cfg(unix)]
        {
            let stat = if dereference {
                nix::sys::stat::stat(path.as_ref())
            } else {
                nix::sys::stat::lstat(path.as_ref())
            };
            if let Ok(stat) = stat {
                Some(Self(stat))
            } else {
                None
            }
        }
        #[cfg(target_os = "windows")]
        {
            use std::fs::OpenOptions;
            use std::os::windows::prelude::*;
            let mut open_options = OpenOptions::new();
            if !dereference {
                open_options.custom_flags(winapi::um::winbase::FILE_FLAG_OPEN_REPARSE_POINT);
            }
            open_options
                .read(true)
                .open(path.as_ref())
                .ok()
                .and_then(|file| Self::from_file(&file))
        }
    }
pub fn from_path ( path : impl AsRef < Path > , dereference : bool ) -> Option < Self > { # [ cfg ( unix ) ] { let stat = if dereference { nix :: sys :: stat :: stat ( path . as_ref ( ) ) } else { nix :: sys :: stat :: lstat ( path . as_ref ( ) ) } ; if let Ok ( stat ) = stat { Some ( Self ( stat ) ) } else { None } } # [ cfg ( target_os " " ) ] { use std :: fs :: OpenOptions ; use std :: os :: windows :: prelude :: * ; let mut open_options = OpenOptions :: new ( ) ; if ! dereference { open_options . custom_flags ( winapi :: um :: winbase :: FILE_FLAG_OPEN_REPARSE_POINT ) ; } open_options . read ( true ) . open ( path . as_ref ( ) ) . ok ( ) . and_then ( | file | Self :: from_file ( & file ) ) } }
Get information for a given path.
Get information for a given path .
path
impl AsRef<Path>
dereference
bool
path
impl AsRef<Path>
dereference
bool