mirror of
https://git.mirrors.martin98.com/https://github.com/gulrak/filesystem
synced 2025-06-11 02:36:33 +08:00
Merge pull request #153 from kkaefer/last_write_time-ios
Fix `ghc::filesystem::last_write_time()` setter on iOS/tvOS/watchOS
This commit is contained in:
commit
3337cc252a
@ -4606,9 +4606,9 @@ GHC_INLINE void last_write_time(const path& p, file_time_type new_time, std::err
|
|||||||
if (!::SetFileTime(file.get(), 0, 0, &ft)) {
|
if (!::SetFileTime(file.get(), 0, 0, &ft)) {
|
||||||
ec = detail::make_system_error();
|
ec = detail::make_system_error();
|
||||||
}
|
}
|
||||||
#elif defined(GHC_OS_MACOS)
|
#elif defined(GHC_OS_MACOS) && \
|
||||||
#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
|
(__MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_13) || (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_11_0) || \
|
||||||
#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101300
|
(__TV_OS_VERSION_MIN_REQUIRED < __TVOS_11_0) || (__WATCH_OS_VERSION_MIN_REQUIRED < __WATCHOS_4_0)
|
||||||
struct ::stat fs;
|
struct ::stat fs;
|
||||||
if (::stat(p.c_str(), &fs) == 0) {
|
if (::stat(p.c_str(), &fs) == 0) {
|
||||||
struct ::timeval tv[2];
|
struct ::timeval tv[2];
|
||||||
@ -4622,18 +4622,6 @@ GHC_INLINE void last_write_time(const path& p, file_time_type new_time, std::err
|
|||||||
}
|
}
|
||||||
ec = detail::make_system_error();
|
ec = detail::make_system_error();
|
||||||
return;
|
return;
|
||||||
#else
|
|
||||||
struct ::timespec times[2];
|
|
||||||
times[0].tv_sec = 0;
|
|
||||||
times[0].tv_nsec = UTIME_OMIT;
|
|
||||||
times[1].tv_sec = std::chrono::duration_cast<std::chrono::seconds>(d).count();
|
|
||||||
times[1].tv_nsec = 0; // std::chrono::duration_cast<std::chrono::nanoseconds>(d).count() % 1000000000;
|
|
||||||
if (::utimensat(AT_FDCWD, p.c_str(), times, AT_SYMLINK_NOFOLLOW) != 0) {
|
|
||||||
ec = detail::make_system_error();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
#ifndef UTIME_OMIT
|
#ifndef UTIME_OMIT
|
||||||
#define UTIME_OMIT ((1l << 30) - 2l)
|
#define UTIME_OMIT ((1l << 30) - 2l)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user