devela::_dep::nc

Function utimes

pub unsafe fn utimes<P>(filename: P, times: &[timeval_t; 2]) -> Result<(), i32> 
where P: AsRef<Path>,
Available on crate feature dep_nc only.
Expand description

Change file last access and modification time.

§Examples

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());