Function nix::sys::stat::utimensat

source ·
pub fn utimensat<Fd: AsFd, P: ?Sized + NixPath>(
    dirfd: Fd,
    path: &P,
    atime: &TimeSpec,
    mtime: &TimeSpec,
    flag: UtimensatFlags,
) -> Result<()>
Expand description

Change the access and modification times of a file.

The file to be changed is determined relative to the directory associated with the file descriptor dirfd or the current working directory if dirfd is AT_FDCWD.

If flag is UtimensatFlags::NoFollowSymlink and path names a symbolic link, then the mode of the symbolic link is changed.

utimensat(AT_FDCWD, path, times, UtimensatFlags::FollowSymlink) is identical to utimes(path, times). The latter is a deprecated API so prefer using the former if the platforms you care about support it.

If you want to set the timestamp to now, use TimeSpec::UTIME_NOW. Use TimeSpec::UTIME_OMIT if you don’t want to change it.

§References

utimensat(2).