Trait PermissionsExt

pub trait PermissionsExt

Windows-specific extensions to fs::Permissions. This extension trait provides extra utilities to shows what Windows file attributes are enabled in Permissions and to manually set file attributes on Permissions.

See Microsoft's File Attribute Constants page to know what file attribute metadata are defined and stored on Windows files.

Example

#![feature(windows_permissions_ext)]
use std::fs::Permissions;
use std::os::windows::fs::PermissionsExt;

const FILE_ATTRIBUTE_SYSTEM: u32 = 0x4;
const FILE_ATTRIBUTE_ARCHIVE: u32 = 0x20;
let my_file_attr = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE;
let mut permissions = Permissions::from_file_attributes(my_file_attr);
assert_eq!(permissions.file_attributes(), my_file_attr);

const FILE_ATTRIBUTE_HIDDEN: u32 = 0x2;
let new_file_attr = permissions.file_attributes() | FILE_ATTRIBUTE_HIDDEN;
permissions.set_file_attributes(new_file_attr);
assert_eq!(permissions.file_attributes(), new_file_attr);

Required Methods

fn file_attributes(&self) -> u32

Returns the file attribute bits.

fn set_file_attributes(&mut self, mask: u32)

Sets the file attribute bits.

fn from_file_attributes(mask: u32) -> Self

Creates a new instance from the given file attribute bits.

Implementors