Skip to content

Commit

Permalink
Also use fallback for futimens on Android
Browse files Browse the repository at this point in the history
futimens requires Android API level 19, and std still supports older API
levels.
  • Loading branch information
joshtriplett committed Jul 15, 2022
1 parent 828b637 commit e387cff
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions library/std/src/sys/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
target_os = "ios",
))]
use crate::sys::weak::syscall;
#[cfg(target_os = "macos")]
#[cfg(any(target_os = "android", target_os = "macos"))]
use crate::sys::weak::weak;

use libc::{c_int, mode_t};
Expand Down Expand Up @@ -1064,8 +1064,8 @@ impl File {

pub fn set_times(&self, times: FileTimes) -> io::Result<()> {
cfg_if::cfg_if! {
// futimens requires macOS 10.13
if #[cfg(target_os = "macos")] {
// futimens requires macOS 10.13, and Android API level 19
if #[cfg(any(target_os = "android", target_os = "macos"))] {
fn ts_to_tv(ts: &libc::timespec) -> libc::timeval {
libc::timeval { tv_sec: ts.tv_sec, tv_usec: (ts.tv_nsec / 1000) as _ }
}
Expand Down

0 comments on commit e387cff

Please sign in to comment.