Skip to content

Commit 48d46cc

Browse files
committed
Improve apple conditionals in filesystem.hpp
Two changes: - (minor) Rename GHC_OS_MACOS -> GHC_OS_APPLE, since it is defined all apple platforms (iOS, watchOS, etc.), not just macOS. - Changed the preprocessor conditional in last_write_time to align with its presumed intent. Previously, it would always have been true, which can't be intentional, because the *_OS_VERSION_MIN_REQUIRED is undefined and thus zero for platforms besides the current one, and therefore less than the constants--except for on very old SDKs where, e.g., MAC_OS_X_VERSION_10_13 and others would be undefined and therefore 0 and therefore making the clause false when it needed to be true. Therefore, I changed the conditions to be parallel to those in the dynamic selection headers, checking for the undefined, zero case and hardcoding the version values to support old SDKs.
1 parent 23710d3 commit 48d46cc

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

include/ghc/filesystem.hpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
#ifndef GHC_OS_DETECTED
3838
#if defined(__APPLE__) && defined(__MACH__)
39-
#define GHC_OS_MACOS
39+
#define GHC_OS_APPLE
4040
#elif defined(__linux__)
4141
#define GHC_OS_LINUX
4242
#if defined(__ANDROID__)
@@ -164,7 +164,7 @@
164164
#include <langinfo.h>
165165
#endif
166166
#endif
167-
#ifdef GHC_OS_MACOS
167+
#ifdef GHC_OS_APPLE
168168
#include <Availability.h>
169169
#endif
170170

@@ -4633,9 +4633,11 @@ GHC_INLINE void last_write_time(const path& p, file_time_type new_time, std::err
46334633
if (!::SetFileTime(file.get(), 0, 0, &ft)) {
46344634
ec = detail::make_system_error();
46354635
}
4636-
#elif defined(GHC_OS_MACOS) && \
4637-
(__MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_13) || (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_11_0) || \
4638-
(__TV_OS_VERSION_MIN_REQUIRED < __TVOS_11_0) || (__WATCH_OS_VERSION_MIN_REQUIRED < __WATCHOS_4_0)
4636+
#elif defined(GHC_OS_APPLE) && \
4637+
(__MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED < 101300 \
4638+
|| __IPHONE_OS_VERSION_MIN_REQUIRED && __IPHONE_OS_VERSION_MIN_REQUIRED < 110000 \
4639+
|| __TV_OS_VERSION_MIN_REQUIRED && __TVOS_VERSION_MIN_REQUIRED < 110000 \
4640+
|| __WATCH_OS_VERSION_MIN_REQUIRED && __WATCHOS_VERSION_MIN_REQUIRED < 40000)
46394641
struct ::stat fs;
46404642
if (::stat(p.c_str(), &fs) == 0) {
46414643
struct ::timeval tv[2];

0 commit comments

Comments
 (0)