[−][src]Crate faccess
faccess
provides an extension trait for std::path::Path
which adds
access
, readable
, writable
, and executable
methods to test whether
the current user (or effective user) is likely to be able to read, write,
or execute a given path.
This corresponds to the faccessat
function on Unix platforms where
available.
A custom implementation is included for Windows which attempts to approximate
its semantics in a best-effort fashion, including but not limited to the use
of AccessCheck
.
On other platforms, a fallback to std::path::Path::exists
and
std::fs::Permissions::readonly
is used.
Care should be taken with these functions not to introduce time-of-check to time-of-use (TOCTOU) bugs, and in particular should not be relied upon in a security context.
Example
use std::path::Path; use faccess::PathExt; use faccess::AccessMode; let path = Path::new("/bin/sh"); assert_eq!(path.access(AccessMode::READ | AccessMode::EXECUTE).is_ok(), true); assert_eq!(path.readable(), true); assert_eq!(path.writable(), false); assert_eq!(path.executable(), true);
Structs
AccessMode | Access mode flags for |
Traits
PathExt | Extension trait for |