1.1.0[−][src]Trait std::os::unix::fs::PermissionsExt
This is supported on Unix only.
Unix-specific extensions to fs::Permissions
.
Required methods
fn mode(&self) -> u32
This is supported on Unix only.
Returns the underlying raw st_mode
bits that contain the standard
Unix permissions for this file.
Examples
use std::fs::File; use std::os::unix::fs::PermissionsExt; fn main() -> std::io::Result<()> { let f = File::create("foo.txt")?; let metadata = f.metadata()?; let permissions = metadata.permissions(); println!("permissions: {}", permissions.mode()); Ok(()) }Run
fn set_mode(&mut self, mode: u32)
This is supported on Unix only.
Sets the underlying raw bits for this set of permissions.
Examples
use std::fs::File; use std::os::unix::fs::PermissionsExt; fn main() -> std::io::Result<()> { let f = File::create("foo.txt")?; let metadata = f.metadata()?; let mut permissions = metadata.permissions(); permissions.set_mode(0o644); // Read/write for owner and read for others. assert_eq!(permissions.mode(), 0o644); Ok(()) }Run
fn from_mode(mode: u32) -> Self
This is supported on Unix only.