[][src]Function permissions::functions::access_syscall

pub fn access_syscall(path: impl AsRef<Path>, mode_mask: c_int) -> Result<bool>

Safe wrapper to the libc::access syscall.

See access man page.

Used by:

This function requires a bitmask made of:

To check for each given rwx permission, or:

Otherwise, the function fails with Err(kind: InvalidInput)

Examples:

use permissions::access_syscall;
use libc::{R_OK, W_OK, X_OK, F_OK};

fn main() -> std::io::Result<()> {
    assert!(access_syscall("src/lib.rs", R_OK | W_OK)?);
    assert!(access_syscall("/", R_OK | X_OK)?);
    assert!(access_syscall(".", F_OK)?);

    assert!(!access_syscall("src/lib.rs", X_OK)?);
    assert!(!access_syscall("/root", W_OK)?);

    Ok(())
}

Errors

See access man page.