8 releases (4 breaking)
| 0.5.1 | Sep 4, 2023 |
|---|---|
| 0.4.1 | Nov 18, 2022 |
| 0.3.0 |
|
| 0.2.1 |
|
| 0.0.1 | Sep 22, 2020 |
#2465 in Filesystem
4,795 downloads per month
Used in 10 crates
(7 directly)
13KB
72 lines
NOTE
If you want Windows support, check faccess instead.
permissions
Useful filesystem queries for file permissions:
See functions.
is_executableis_readableis_writableis_removableis_creatableaccess_syscallsupports 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.
Dependencies
~42KB