cap_primitives/fs/
set_times.rs

1//! This defines `set_times`, the primary entrypoint to sandboxed
2//! filesystem times modification.
3//!
4//! TODO: `check_set_times` etc.
5
6use crate::fs::{set_times_impl, set_times_nofollow_impl, SystemTimeSpec};
7use std::path::Path;
8use std::{fs, io};
9
10/// Perform a `utimensat`-like operation, ensuring that the resolution of the
11/// path never escapes the directory tree rooted at `start`. This function
12/// follows symlinks.
13#[inline]
14pub fn set_times(
15    start: &fs::File,
16    path: &Path,
17    atime: Option<SystemTimeSpec>,
18    mtime: Option<SystemTimeSpec>,
19) -> io::Result<()> {
20    set_times_impl(start, path, atime, mtime)
21}
22
23/// Like `set_times`, but never follows symlinks.
24#[inline]
25pub fn set_times_nofollow(
26    start: &fs::File,
27    path: &Path,
28    atime: Option<SystemTimeSpec>,
29    mtime: Option<SystemTimeSpec>,
30) -> io::Result<()> {
31    set_times_nofollow_impl(start, path, atime, mtime)
32}