If you want Windows support, check faccess instead.
Useful filesystem queries for Unix file permissions:
See functions
.
is_executable
is_readable
is_writable
is_removable
is_creatable
access_syscall
supports a custom bitfield of permissions.
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(())
}
- faccess - it provides Windows support and a trait-based API.