cap_fs_ext/
open_options_follow_ext.rs

1use crate::FollowSymlinks;
2
3/// Extension trait for `cap_primitives::fs::OpenOptions` which adds
4/// `follow`, a function for controlling whether a symlink in the last
5/// component of a path is followed.
6pub trait OpenOptionsFollowExt {
7    /// Sets the option for following symlinks in the last component of a path.
8    ///
9    /// This option, when set to `FollowSymlinks::Yes`, will indicate that a
10    /// symbolic link in the last component of a path will be followed. When
11    /// set to `FollowSymlinks::No`, it will indicate that attempting to
12    /// resolve a path which ends in a symbolic link will fail.
13    fn follow(&mut self, follow: FollowSymlinks) -> &mut Self;
14}
15
16impl OpenOptionsFollowExt for cap_primitives::fs::OpenOptions {
17    #[inline]
18    fn follow(&mut self, follow: FollowSymlinks) -> &mut Self {
19        // `follow` functionality is implemented within `cap_primitives`; we're
20        // just exposing it here since `OpenOptions` is re-exported by
21        // `cap_std` etc. and `follow` isn't in `std`.
22        self._cap_fs_ext_follow(follow)
23    }
24}