I realise this is a potentially difficult thing to get right across multiple platforms, but it'd be super-nice if the filetime crate supported setting the file times on open files. In code I am writing now, I have had to wrapper up futimens() for myself because I need to be able to re-stamp an open file from time to time to fit with the semantics of what is being worked with.
I ended up with:
mod platform {
use libc::{futimens, timespec};
use std::fs::File;
use std::io::{Error, Result};
use std::os::unix::io::AsRawFd;
pub fn set_utime_now(fh: &File) -> Result<()> {
let fd = fh.as_raw_fd();
let rc = unsafe { futimens(fd, 0 as *const timespec) };
if rc == 0 {
Ok(())
} else {
Err(Error::last_os_error())
}
}
}
While this is pretty platform-specific and quite task-specific to myself, I would love to see a function (or trait I guess) in the filetime crate which was something along the lines of fn set_file_times(&File,Option<&FileTime>)
Is there any chance of this, or should I continue to use my hack for now?
Hi,
I realise this is a potentially difficult thing to get right across multiple platforms, but it'd be super-nice if the filetime crate supported setting the file times on open files. In code I am writing now, I have had to wrapper up
futimens()
for myself because I need to be able to re-stamp an open file from time to time to fit with the semantics of what is being worked with.I ended up with:
While this is pretty platform-specific and quite task-specific to myself, I would love to see a function (or trait I guess) in the filetime crate which was something along the lines of
fn set_file_times(&File,Option<&FileTime>)
Is there any chance of this, or should I continue to use my hack for now?
Thanks,
Daniel.