Skip to content

Commit 11d9be6

Browse files
committed
Stub out set_times to return unsupported on Redox
Redox doesn't appear to support `UTIME_OMIT`, so we can't set file times individually.
1 parent 3da1729 commit 11d9be6

File tree

1 file changed

+13
-2
lines changed
  • library/std/src/sys/unix

1 file changed

+13
-2
lines changed

library/std/src/sys/unix/fs.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,11 @@ impl fmt::Debug for FileTimes {
538538

539539
impl Default for FileTimes {
540540
fn default() -> Self {
541+
// Redox doesn't appear to support `UTIME_OMIT`, so we stub it out here, and always return
542+
// an error in `set_times`.
543+
#[cfg(target_os = "redox")]
544+
let omit = libc::timespec { tv_sec: 0, tv_nsec: 0 };
545+
#[cfg(not(target_os = "redox"))]
541546
let omit = libc::timespec { tv_sec: 0, tv_nsec: libc::UTIME_OMIT as _ };
542547
Self([omit; 2])
543548
}
@@ -1064,8 +1069,14 @@ impl File {
10641069

10651070
pub fn set_times(&self, times: FileTimes) -> io::Result<()> {
10661071
cfg_if::cfg_if! {
1067-
// futimens requires macOS 10.13, and Android API level 19
1068-
if #[cfg(any(target_os = "android", target_os = "macos"))] {
1072+
if #[cfg(target_os = "redox")] {
1073+
// Redox doesn't appear to support `UTIME_OMIT`.
1074+
return Err(io::const_io_error!(
1075+
io::ErrorKind::Unsupported,
1076+
"setting file times not supported",
1077+
));
1078+
} else if #[cfg(any(target_os = "android", target_os = "macos"))] {
1079+
// futimens requires macOS 10.13, and Android API level 19
10691080
cvt(unsafe {
10701081
weak!(fn futimens(c_int, *const libc::timespec) -> c_int);
10711082
match futimens.get() {

0 commit comments

Comments
 (0)