diff --git a/README.md b/README.md index 948b594..c744716 100644 --- a/README.md +++ b/README.md @@ -122,8 +122,8 @@ Everything is in the namespace `ghc::filesystem`, so one way to use it only as a fallback could be: ```cpp -#if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include) -#if __has_include() +#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (defined(__cplusplus) && __cplusplus >= 201703L)) && defined(__has_include) +#if __has_include() && (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) #define GHC_USE_STD_FS #include namespace fs = std::filesystem; @@ -136,18 +136,22 @@ namespace fs = ghc::filesystem; ``` **Note that this code uses a two-stage preprocessor condition because Visual Studio 2015 -doesn't like the `(<...>)` syntax, even if it could cut evaluation early before.** +doesn't like the `(<...>)` syntax, even if it could cut evaluation early before. This code also +used the minimum deployment target to detect if std::filesystem really is available on macOS +compilation.** -**Note also, that on MSVC this detection only works starting from version 15.7 on and when setting -the `/Zc:__cplusplus` compile switch, as the compiler allways reports `199711L` -without that switch ([see](https://blogs.msdn.microsoft.com/vcblog/2018/04/09/msvc-now-correctly-reports-__cplusplus/)).** +**Note also, this detection now works on MSVC versions prior to 15.7 on, or without setting +the `/Zc:__cplusplus` compile switch that would fix `__cplusplus` on MSVC. (Without the switch +the compiler allways reports `199711L` +([see](https://blogs.msdn.microsoft.com/vcblog/2018/04/09/msvc-now-correctly-reports-__cplusplus/)), +but `_MSVC_LANG` works without it.** If you want to also use the `fstream` wrapper with `path` support as fallback, you might use: ```cpp -#if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include) -#if __has_include() +#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (defined(__cplusplus) && __cplusplus >= 201703L)) && defined(__has_include) +#if __has_include() && (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) #define GHC_USE_STD_FS #include namespace fs { @@ -201,8 +205,8 @@ If you use the forwarding/implementation approach, you can still use the dynamic switching like this: ```cpp -#if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include) -#if __has_include() +#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (defined(__cplusplus) && __cplusplus >= 201703L)) && defined(__has_include) +#if __has_include() && (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) #define GHC_USE_STD_FS #include namespace fs { @@ -228,11 +232,15 @@ and in the implementation hiding cpp, you might use (before any include that inc to take precedence: ```cpp -#if !(defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include) -#if __has_include()) -#include +#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (defined(__cplusplus) && __cplusplus >= 201703L)) && defined(__has_include) +#if __has_include() && (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) +#define GHC_USE_STD_FS #endif #endif +#ifndef GHC_USE_STD_FS +#define GHC_FILESYSTEM_IMPLEMENTATION +#include +#endif ``` :information_source: **Hint:** There are additional helper headers, named `ghc/fs_std_fwd.hpp` and @@ -498,6 +506,22 @@ to the expected behavior. ## Release Notes +### [v1.3.8](https://github.com/gulrak/filesystem/releases/tag/v1.3.8) + +* Refactoring for [#78](https://github.com/gulrak/filesystem/issues/78), the dynamic + switching helper includes are now using `__MAC_OS_X_VERSION_MIN_REQUIRED` to + ensure that `std::filesystem` is only selected on macOS if the deployment target is + at least Catalina. +* Bugfix for [#77](https://github.com/gulrak/filesystem/issues/77), the `directory_iterator` + and the `recursive_directory_iterator` had an issue with the `skip_permission_denied` + option, that leads to the inability to skip SIP protected folders on macOS. +* Enhancement for [#76](https://github.com/gulrak/filesystem/issues/76), `_MSVC_LANG` is + now used when available, additionally to `__cplusplus`, in the helping headers to + allow them to work even when `/Zc:__cplusplus` is not used. +* Bugfix for [#75](https://github.com/gulrak/filesystem/issues/75), NTFS reparse points + to mapped volumes where handled incorrect, leading to `false` on `fs::exists` or + not-found-errors on `fs::status`. Namespaced paths are not filtered anymore. + ### [v1.3.6](https://github.com/gulrak/filesystem/releases/tag/v1.3.6) * Pull request [#74](https://github.com/gulrak/filesystem/pull/74), on Windows symlink diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index d371bc0..267f494 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -26,12 +26,17 @@ // //--------------------------------------------------------------------------------------- // -// To dynamically select std::filesystem where available, you could use: +// To dynamically select std::filesystem where available on most platforms, +// you could use: // -// #if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include) && __has_include() +// #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (defined(__cplusplus) && __cplusplus >= 201703L)) && defined(__has_include) +// #if __has_include() && (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) +// #define GHC_USE_STD_FS // #include // namespace fs = std::filesystem; -// #else +// #endif +// #endif +// #ifndef GHC_USE_STD_FS // #include // namespace fs = ghc::filesystem; // #endif diff --git a/include/ghc/fs_std.hpp b/include/ghc/fs_std.hpp index 8056569..f295e37 100644 --- a/include/ghc/fs_std.hpp +++ b/include/ghc/fs_std.hpp @@ -30,7 +30,7 @@ // namespace fs. //--------------------------------------------------------------------------------------- #ifndef GHC_FILESYSTEM_STD_H -#if (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (defined(__cplusplus) && __cplusplus >= 201703L) && defined(__has_include) +#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (defined(__cplusplus) && __cplusplus >= 201703L)) && defined(__has_include) #if __has_include() && (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) #define GHC_USE_STD_FS #include diff --git a/include/ghc/fs_std_fwd.hpp b/include/ghc/fs_std_fwd.hpp index 1a7d4bb..f07c09b 100644 --- a/include/ghc/fs_std_fwd.hpp +++ b/include/ghc/fs_std_fwd.hpp @@ -33,7 +33,7 @@ //--------------------------------------------------------------------------------------- #ifndef GHC_FILESYSTEM_STD_FWD_H #define GHC_FILESYSTEM_STD_FWD_H -#if (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (defined(__cplusplus) && __cplusplus >= 201703L) && defined(__has_include) +#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (defined(__cplusplus) && __cplusplus >= 201703L)) && defined(__has_include) #if __has_include() && (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) #define GHC_USE_STD_FS #include diff --git a/include/ghc/fs_std_impl.hpp b/include/ghc/fs_std_impl.hpp index beb2b8e..d7b609d 100644 --- a/include/ghc/fs_std_impl.hpp +++ b/include/ghc/fs_std_impl.hpp @@ -31,7 +31,7 @@ // The cpp has to include this before including fs_std_fwd.hpp directly or via a different // header to work. //--------------------------------------------------------------------------------------- -#if (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (defined(__cplusplus) && __cplusplus >= 201703L) && defined(__has_include) +#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (defined(__cplusplus) && __cplusplus >= 201703L)) && defined(__has_include) #if __has_include() && (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) #define GHC_USE_STD_FS #endif