2525#include < sys/stat.h>
2626#include < sys/time.h>
2727
28- #include " futimesat.hpp" /* futimesat replacement */
28+ #include " fs_base_futimesat.hpp"
29+ #include " fs_base_stat.hpp"
2930
3031#ifndef UTIME_NOW
3132# define UTIME_NOW ((1l << 30 ) - 1l )
@@ -125,7 +126,8 @@ _set_utime_omit_to_current_value(const int dirfd,
125126{
126127 int rv;
127128 struct stat st;
128- timespec *atime, *mtime;
129+ timespec *atime;
130+ timespec *mtime;
129131
130132 if (!_any_timespec_is_utime_omit (ts))
131133 return 0 ;
@@ -134,14 +136,9 @@ _set_utime_omit_to_current_value(const int dirfd,
134136 if (rv == -1 )
135137 return -1 ;
136138
137- #if __APPLE__
138- atime = &st.st_atimespec ;
139- mtime = &st.st_mtimespec ;
140- #else
141- atime = &st.st_atim ;
142- mtime = &st.st_mtim ;
143- #endif
144-
139+ atime = fs::stat_atime (st);
140+ mtime = fs::stat_mtime (st);
141+
145142 if (ts[0 ].tv_nsec == UTIME_OMIT)
146143 TIMESPEC_TO_TIMEVAL (&tv[0 ],atime);
147144 if (ts[1 ].tv_nsec == UTIME_OMIT)
@@ -159,7 +156,8 @@ _set_utime_omit_to_current_value(const int fd,
159156{
160157 int rv;
161158 struct stat st;
162- timespec *atime, *mtime;
159+ timespec *atime;
160+ timespec *mtime;
163161
164162 if (!_any_timespec_is_utime_omit (ts))
165163 return 0 ;
@@ -168,13 +166,8 @@ _set_utime_omit_to_current_value(const int fd,
168166 if (rv == -1 )
169167 return -1 ;
170168
171- #if __APPLE__
172- atime = &st.st_atimespec ;
173- mtime = &st.st_mtimespec ;
174- #else
175- atime = &st.st_atim ;
176- mtime = &st.st_mtim ;
177- #endif
169+ atime = fs::stat_atime (st);
170+ mtime = fs::stat_mtime (st);
178171
179172 if (ts[0 ].tv_nsec == UTIME_OMIT)
180173 TIMESPEC_TO_TIMEVAL (&tv[0 ],atime);
@@ -289,13 +282,9 @@ namespace fs
289282 if (rv == -1 )
290283 return -1 ;
291284
292- if ((flags & AT_SYMLINK_NOFOLLOW) == 0 ) {
293- #if __APPLE__
294- return _futimesat (dirfd,path.c_str (),tvp);
295- #else
296- return ::futimesat (dirfd,path.c_str (),tvp);
297- #endif
298- }
285+ if ((flags & AT_SYMLINK_NOFOLLOW) == 0 )
286+ return fs::futimesat (dirfd,path.c_str (),tvp);
287+
299288 if (_can_call_lutimes (dirfd,path,flags))
300289 return ::lutimes (path.c_str (),tvp);
301290
0 commit comments