Crate permissions
source ·Expand description
NOTE
If you want Windows support, check faccess instead.
Useful filesystem queries for file permissions:
See functions
.
is_executable
is_readable
is_writable
is_removable
is_creatable
access_syscall
supports a custom bitfield of permissions
Examples:
use permissions::*;
fn main() -> std::io::Result<()> {
// Functions accept `AsRef<Path>`
assert!(is_readable("src/")?);
assert!(is_writable("src/")?);
assert!(is_writable("src/lib.rs")?);
assert!(is_executable("/usr/bin/cat")?);
assert!(is_removable("src/lib.rs")?);
assert!(is_creatable("src/file.rs")?);
Ok(())
}
Alternatives
- faccess - it provides Windows support and a trait-based API.
Re-exports
pub use functions::*;
Modules
- Permission checks at some path using
access_syscall
.