set_times_nofollow in std::fs - Rust
Description: Changes the timestamps of the file or symlink at the specified path.

## set_times_nofollow

# Function set_times_nofollow

Source

    pub fn set_times_nofollow<P: AsRef<Path>>(
        path: P,
        times: FileTimes,
    ) -> Result<()>

🔬This is a nightly-only experimental API. (`fs_set_times` #147455)
Expand description

Changes the timestamps of the file or symlink at the specified path.

This function will attempt to set the access and modification times to the times specified. Differ from `set_times`, if the path refers to a symbolic link, this function will change the timestamps of the symlink itself, not the target file.

## §Platform-specific behavior

This function currently corresponds to the `utimensat` function with `AT_SYMLINK_NOFOLLOW` on Unix platforms, the `setattrlist` function with `FSOPT_NOFOLLOW` on Apple platforms, and the `SetFileTime` function on Windows.

## §Errors

This function will return an error if the user lacks permission to change timestamps on the target file or symlink. It may also return an error if the OS does not support it.

## §Examples

    #![feature(fs_set_times)]
    use std::fs::{self, FileTimes};
    use std::time::SystemTime;

    fn main() -> std::io::Result<()> {
        let now = SystemTime::now();
        let times = FileTimes::new()
            .set_accessed(now)
            .set_modified(now);
        fs::set_times_nofollow("symlink.txt", times)?;
        Ok(())
    }