Skip to content

Commit c66860a

Browse files
committed
SetFileTime doesn't allow setting the file time to 0xFFFF_FFFF_FFFF_FFFF
1 parent 39c0b00 commit c66860a

File tree

1 file changed

+8
-0
lines changed
  • library/std/src/sys/windows

1 file changed

+8
-0
lines changed

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

+8
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,14 @@ impl File {
572572
"Cannot set file timestamp to 0",
573573
));
574574
}
575+
let is_max =
576+
|t: c::FILETIME| t.dwLowDateTime == c::DWORD::MAX && t.dwHighDateTime == c::DWORD::MAX;
577+
if times.accessed.map_or(false, is_max) || times.modified.map_or(false, is_max) {
578+
return Err(io::const_io_error!(
579+
io::ErrorKind::InvalidInput,
580+
"Cannot set file timestamp to 0xFFFF_FFFF_FFFF_FFFF",
581+
));
582+
}
575583
cvt(unsafe {
576584
c::SetFileTime(self.as_handle(), None, times.accessed.as_ref(), times.modified.as_ref())
577585
})?;

0 commit comments

Comments
 (0)