Function std::fs::set_file_times can't set only accessed or modified time


We sometimes want to change only accessed time (or modified time) of a file.
However, function std::fs::set_file_times requires both accessed and modified time.

I think the signature of set_files_times should be something like:

pub fn set_file_times<P: AsRef<Path>>(path: P, accessed: Option<u64>, modified: Option<u64>) -> Result<()>;

I know it is waiting for the time when the standard library gains a type to represent a moment.
I just want to know if there is a plan to consider the case above.



SetFileTime on Windows allows you to use the equivalent of Option for each parameter (null pointers), so I see no reason why the Rust API can’t expose something like this.


While this is possible on Windows, as far as I can tell the unix equivalent (utime) requires both at the same time.

This would be nice to have as a function in std::os, because of the limitation in unix I don’t think it belongs in cross-platform API. Even though it would be possible to grab the time, then copy what time was specified as None, I don’t think that behavior would be atomic and that would be a bit counter-intuitive for an API like this.