alexcrichton / filetime

Accessing file timestamps in a platform-agnostic fashion in Rust
Apache License 2.0
122 stars 56 forks source link

Make `set_times` public #95

Open tertsdiepraam opened 1 year ago

tertsdiepraam commented 1 year ago

Hi! I have a use case[^1] where both the atime and mtime are optional and where following the symlink is optional. While looking through the source code of this crate, I found this function in the unix-specific part of the library, which fits my use case perfectly, but it's not public:

https://github.com/alexcrichton/filetime/blob/5eec5a5547b0fb67a3ed795db9da8e0c360c0009/src/unix/linux.rs#L87-L92

Similar functions do not yet exist for the Windows and Redox implementations, but I think those could be added with relatively little effort.

If you decide to expose this, I'd recommend a name like set_path_times, mirroring the set_file_handle_times name, which is very similar in functionality. I would be happy to open a PR for this.

This would also partially fix https://github.com/alexcrichton/filetime/issues/83, albeit not in the most elegant way.

[^1]: The touch utility of uutils, which basically acts as a wrapper around the utimensat syscall and therefore requires the same flexibility.