]> git.proxmox.com Git - cargo.git/blobdiff - vendor/winapi-util/src/file.rs
New upstream version 0.33.0
[cargo.git] / vendor / winapi-util / src / file.rs
index a9be91a431b84796edb6728b25e03ada7d918cb4..99f7981b54a334aded9bc526d0548ead8a57b470 100644 (file)
@@ -8,6 +8,7 @@ use winapi::um::fileapi::{
     BY_HANDLE_FILE_INFORMATION,
     GetFileInformationByHandle, GetFileType,
 };
+use winapi::um::winnt;
 
 use AsHandleRef;
 
@@ -49,6 +50,12 @@ pub fn typ<H: AsHandleRef>(h: H) -> io::Result<Type> {
     }
 }
 
+/// Returns true if and only if the given file attributes contain the
+/// `FILE_ATTRIBUTE_HIDDEN` attribute.
+pub fn is_hidden(file_attributes: u64) -> bool {
+    file_attributes & (winnt::FILE_ATTRIBUTE_HIDDEN as u64) > 0
+}
+
 /// Represents file information such as creation time, file size, etc.
 ///
 /// This wraps a [`BY_HANDLE_FILE_INFORMATION`].
@@ -65,6 +72,12 @@ impl Information {
         self.0.dwFileAttributes as u64
     }
 
+    /// Returns true if and only if this file information has the
+    /// `FILE_ATTRIBUTE_HIDDEN` attribute.
+    pub fn is_hidden(&self) -> bool {
+        is_hidden(self.file_attributes())
+    }
+
     /// Return the creation time, if one exists.
     ///
     /// This corresponds to `ftCreationTime`.