Function nc::utimes

source ·
pub unsafe fn utimes<P: AsRef<Path>>(
    filename: P,
    times: &[timeval_t; 2]
) -> Result<(), Errno>
Expand description

Change file last access and modification time.

§Example

let path = "/tmp/nc-utimes";
let ret = unsafe { nc::openat(nc::AT_FDCWD, path, nc::O_WRONLY | nc::O_CREAT, 0o644) };
assert!(ret.is_ok());
let fd = ret.unwrap();
let ret = unsafe { nc::close(fd) };
assert!(ret.is_ok());
let times = [
    nc::timeval_t {
        tv_sec: 100,
        tv_usec: 0,
    },
    nc::timeval_t {
        tv_sec: 10,
        tv_usec: 0,
    },
];
let ret = unsafe { nc::utimes(path, &times) };
assert!(ret.is_ok());
let ret = unsafe { nc::unlinkat(nc::AT_FDCWD, path, 0) };
assert!(ret.is_ok());