mirror of
https://git.mirrors.martin98.com/https://github.com/gulrak/filesystem
synced 2025-06-04 11:13:58 +08:00
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.
This commit is contained in:
parent
23710d3b56
commit
48d46cccef
@ -36,7 +36,7 @@
|
||||
|
||||
#ifndef GHC_OS_DETECTED
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
#define GHC_OS_MACOS
|
||||
#define GHC_OS_APPLE
|
||||
#elif defined(__linux__)
|
||||
#define GHC_OS_LINUX
|
||||
#if defined(__ANDROID__)
|
||||
@ -164,7 +164,7 @@
|
||||
#include <langinfo.h>
|
||||
#endif
|
||||
#endif
|
||||
#ifdef GHC_OS_MACOS
|
||||
#ifdef GHC_OS_APPLE
|
||||
#include <Availability.h>
|
||||
#endif
|
||||
|
||||
@ -4633,9 +4633,11 @@ GHC_INLINE void last_write_time(const path& p, file_time_type new_time, std::err
|
||||
if (!::SetFileTime(file.get(), 0, 0, &ft)) {
|
||||
ec = detail::make_system_error();
|
||||
}
|
||||
#elif defined(GHC_OS_MACOS) && \
|
||||
(__MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_13) || (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_11_0) || \
|
||||
(__TV_OS_VERSION_MIN_REQUIRED < __TVOS_11_0) || (__WATCH_OS_VERSION_MIN_REQUIRED < __WATCHOS_4_0)
|
||||
#elif defined(GHC_OS_APPLE) && \
|
||||
(__MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED < 101300 \
|
||||
|| __IPHONE_OS_VERSION_MIN_REQUIRED && __IPHONE_OS_VERSION_MIN_REQUIRED < 110000 \
|
||||
|| __TV_OS_VERSION_MIN_REQUIRED && __TVOS_VERSION_MIN_REQUIRED < 110000 \
|
||||
|| __WATCH_OS_VERSION_MIN_REQUIRED && __WATCHOS_VERSION_MIN_REQUIRED < 40000)
|
||||
struct ::stat fs;
|
||||
if (::stat(p.c_str(), &fs) == 0) {
|
||||
struct ::timeval tv[2];
|
||||
|
Loading…
x
Reference in New Issue
Block a user