cap_primitives/fs/via_parent/
access.rs

1use super::open_parent;
2use crate::fs::{access_unchecked, AccessType, FollowSymlinks, MaybeOwnedFile};
3use std::path::Path;
4use std::{fs, io};
5
6/// Implement `access` by `open`ing up the parent component of the path and
7/// then calling `access_unchecked` on the last component.
8pub(crate) fn access(
9    start: &fs::File,
10    path: &Path,
11    type_: AccessType,
12    follow: FollowSymlinks,
13) -> io::Result<()> {
14    let start = MaybeOwnedFile::borrowed(start);
15
16    let (dir, basename) = open_parent(start, path)?;
17
18    access_unchecked(&dir, basename.as_ref(), type_, follow)
19}