diff --git a/Cargo.toml b/Cargo.toml index 6b64e14..0d100f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "readable-perms" description = "More usable UNIX file permissions interface" keywords = ["unix", "fs", "permissions", "file", "chmod"] -version = "0.1.2" +version = "0.1.3" authors = ["Avril "] edition = "2018" license = "GPL-3.0-or-later" diff --git a/README.md b/README.md index 759385f..3ab2d7b 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,23 @@ fn do_thing(file: &mut std::fs::File) } ``` +### Modifying permissions +With default feature `chmod` enabled, also define extension traits for modifying permissions on types that implement `AsRawFd` (like `std::fs::File`), and `AsRef`. + +``` rust +use readable_perms::{FChmodExt,ChmodExt}; + +fn mod_path>(path: P) +{ + path.chmod(Permissions::from_mask(0o644)).expect("Uh oh") +} + +fn mod_file(file: &mut std::fs::File) +{ + file.chmod(Permissinos::from_mask(0u777)).expect("Uh oh") +} +``` + ## Performance On nightly, most functions are `const fn` incuring no runtime cost for constant definitions. On stable, not so. Either way, we define a global `const` lookup table, so that conversions are as fast as a memory lookup.