@@ -1192,8 +1192,6 @@ impl File {
1192
1192
None => Ok ( libc:: timespec { tv_sec : 0 , tv_nsec : libc:: UTIME_OMIT as _ } ) ,
1193
1193
}
1194
1194
} ;
1195
- #[ cfg( not( any( target_os = "redox" , target_os = "espidf" , target_os = "horizon" ) ) ) ]
1196
- let times = [ to_timespec ( times. accessed ) ?, to_timespec ( times. modified ) ?] ;
1197
1195
cfg_if:: cfg_if! {
1198
1196
if #[ cfg( any( target_os = "redox" , target_os = "espidf" , target_os = "horizon" ) ) ] {
1199
1197
// Redox doesn't appear to support `UTIME_OMIT`.
@@ -1205,6 +1203,7 @@ impl File {
1205
1203
"setting file times not supported" ,
1206
1204
) )
1207
1205
} else if #[ cfg( any( target_os = "android" , target_os = "macos" ) ) ] {
1206
+ let times = [ to_timespec( times. accessed) ?, to_timespec( times. modified) ?] ;
1208
1207
// futimens requires macOS 10.13, and Android API level 19
1209
1208
cvt( unsafe {
1210
1209
weak!( fn futimens( c_int, * const libc:: timespec) -> c_int) ;
@@ -1231,6 +1230,22 @@ impl File {
1231
1230
} ) ?;
1232
1231
Ok ( ( ) )
1233
1232
} else {
1233
+ #[ cfg( all( target_os = "linux" , target_env = "gnu" , target_pointer_width = "32" , not( target_arch = "riscv32" ) ) ) ]
1234
+ {
1235
+ use crate :: sys:: { time:: __timespec64, weak:: weak} ;
1236
+
1237
+ // Added in glibc 2.34
1238
+ weak!( fn __futimens64( libc:: c_int, * const __timespec64) -> libc:: c_int) ;
1239
+
1240
+ if let Some ( futimens64) = __futimens64. get( ) {
1241
+ let to_timespec = |time: Option <SystemTime >| time. map( |time| time. t. to_timespec64( ) )
1242
+ . unwrap_or( __timespec64:: new( 0 , libc:: UTIME_OMIT as _) ) ;
1243
+ let times = [ to_timespec( times. accessed) , to_timespec( times. modified) ] ;
1244
+ cvt( unsafe { futimens64( self . as_raw_fd( ) , times. as_ptr( ) ) } ) ?;
1245
+ return Ok ( ( ) ) ;
1246
+ }
1247
+ }
1248
+ let times = [ to_timespec( times. accessed) ?, to_timespec( times. modified) ?] ;
1234
1249
cvt( unsafe { libc:: futimens( self . as_raw_fd( ) , times. as_ptr( ) ) } ) ?;
1235
1250
Ok ( ( ) )
1236
1251
}
0 commit comments