Skip to content

Commit 8182085

Browse files
committed
Fix compiling error for redox etc
1 parent d2f590a commit 8182085

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,23 +2113,22 @@ fn open_from(from: &Path) -> io::Result<(crate::fs::File, crate::fs::Metadata)>
21132113
Ok((reader, metadata))
21142114
}
21152115

2116-
fn set_times_impl(p: &CStr, times: FileTimes, flags: c_int) -> io::Result<()> {
2116+
fn set_times_impl(p: &CStr, times: FileTimes, follow_symlinks: bool) -> io::Result<()> {
21172117
cfg_select! {
21182118
any(target_os = "redox", target_os = "espidf", target_os = "horizon", target_os = "nuttx") => {
2119-
let _ = (p, times, flags);
2119+
let _ = (p, times, follow_symlinks);
21202120
Err(io::const_error!(
21212121
io::ErrorKind::Unsupported,
21222122
"setting file times not supported",
21232123
))
21242124
}
21252125
target_vendor = "apple" => {
21262126
// Apple platforms use setattrlist which supports setting times on symlinks
2127-
//let (attrlist, buf, num_times) = set_attrlist_with_times(&times)?;
21282127
let ta = TimesAttrlist::from_times(&times)?;
2129-
let options = if flags == libc::AT_SYMLINK_NOFOLLOW {
2130-
libc::FSOPT_NOFOLLOW
2131-
} else {
2128+
let options = if follow_symlinks {
21322129
0
2130+
} else {
2131+
libc::FSOPT_NOFOLLOW
21332132
};
21342133

21352134
cvt(unsafe { libc::setattrlist(
@@ -2143,6 +2142,7 @@ fn set_times_impl(p: &CStr, times: FileTimes, flags: c_int) -> io::Result<()> {
21432142
}
21442143
target_os = "android" => {
21452144
let times = [file_time_to_timespec(times.accessed)?, file_time_to_timespec(times.modified)?];
2145+
let flags = if follow_symlinks { 0 } else { libc::AT_SYMLINK_NOFOLLOW };
21462146
// utimensat requires Android API level 19
21472147
cvt(unsafe {
21482148
weak!(
@@ -2159,6 +2159,7 @@ fn set_times_impl(p: &CStr, times: FileTimes, flags: c_int) -> io::Result<()> {
21592159
Ok(())
21602160
}
21612161
_ => {
2162+
let flags = if follow_symlinks { 0 } else { libc::AT_SYMLINK_NOFOLLOW };
21622163
#[cfg(all(target_os = "linux", target_env = "gnu", target_pointer_width = "32", not(target_arch = "riscv32")))]
21632164
{
21642165
use crate::sys::{time::__timespec64, weak::weak};
@@ -2185,13 +2186,12 @@ fn set_times_impl(p: &CStr, times: FileTimes, flags: c_int) -> io::Result<()> {
21852186

21862187
#[inline(always)]
21872188
pub fn set_times(p: &CStr, times: FileTimes) -> io::Result<()> {
2188-
// flags = 0 means follow symlinks
2189-
set_times_impl(p, times, 0)
2189+
set_times_impl(p, times, true)
21902190
}
21912191

21922192
#[inline(always)]
21932193
pub fn set_times_nofollow(p: &CStr, times: FileTimes) -> io::Result<()> {
2194-
set_times_impl(p, times, libc::AT_SYMLINK_NOFOLLOW)
2194+
set_times_impl(p, times, false)
21952195
}
21962196

21972197
#[cfg(target_os = "espidf")]

0 commit comments

Comments
 (0)