diff --git a/app/actions.cpp b/app/actions.cpp index bd7744c76f..53692f90c3 100644 --- a/app/actions.cpp +++ b/app/actions.cpp @@ -17,16 +17,15 @@ #include "types.hpp" #include "xmp_exiv2.hpp" -// + standard includes -#include // for stat() -#include // for stat() - -#include #include #include #include #include #include + +// + standard includes +#include // for stat() +#include // for stat() #ifdef EXV_HAVE_UNISTD_H #include // for stat() #endif @@ -46,7 +45,13 @@ } while (false) #endif +#if __has_include() +#include namespace fs = std::filesystem; +#else +#include +namespace fs = std::experimental::filesystem; +#endif // ***************************************************************************** // local declarations diff --git a/app/getopt.cpp b/app/getopt.cpp index 935fd77d63..21a5992e6e 100644 --- a/app/getopt.cpp +++ b/app/getopt.cpp @@ -5,9 +5,14 @@ #include #include -#include +#if __has_include() +#include namespace fs = std::filesystem; +#else +#include +namespace fs = std::experimental::filesystem; +#endif namespace Util { // https://raw.githubusercontent.com/skeeto/getopt/master/getopt.h diff --git a/samples/path-test.cpp b/samples/path-test.cpp index 1dd3281d9e..cfbc4ddc6d 100644 --- a/samples/path-test.cpp +++ b/samples/path-test.cpp @@ -2,11 +2,16 @@ #include -#include #include #include +#if __has_include() +#include namespace fs = std::filesystem; +#else +#include +namespace fs = std::experimental::filesystem; +#endif int main(int argc, char* const argv[]) { Exiv2::XmpParser::initialize(); diff --git a/src/basicio.cpp b/src/basicio.cpp index 5192f9a4d9..fb2b135df8 100644 --- a/src/basicio.cpp +++ b/src/basicio.cpp @@ -19,7 +19,6 @@ #include // for alloc, realloc, free #include // std::memcpy #include // timestamp for the name of temporary file -#include #include // write the temporary file #include @@ -43,7 +42,13 @@ #include #endif +#if __has_include() +#include namespace fs = std::filesystem; +#else +#include +namespace fs = std::experimental::filesystem; +#endif // ***************************************************************************** // class member definitions diff --git a/src/futils.cpp b/src/futils.cpp index 7ded06c9fb..7239761605 100644 --- a/src/futils.cpp +++ b/src/futils.cpp @@ -12,15 +12,16 @@ #include #include #include -#include #include #include -#ifdef EXV_HAVE_UNISTD_H -#include // for stat() -#endif - +#if __has_include() +#include namespace fs = std::filesystem; +#else +#include +namespace fs = std::experimental::filesystem; +#endif #if defined(_WIN32) // clang-format off @@ -42,7 +43,10 @@ namespace fs = std::filesystem; #include #include #include -#include +#endif + +#ifdef EXV_HAVE_UNISTD_H +#include // for stat() #endif #ifndef _MAX_PATH @@ -374,7 +378,7 @@ std::string getProcessPath() { ret = path; } #elif defined(__unix__) - ret = std::filesystem::read_symlink("/proc/self/exe"); + ret = fs::read_symlink("/proc/self/exe"); #endif const size_t idxLastSeparator = ret.find_last_of(EXV_SEPARATOR_CHR); diff --git a/src/makernote_int.cpp b/src/makernote_int.cpp index 36c4a417c2..8144f6323e 100644 --- a/src/makernote_int.cpp +++ b/src/makernote_int.cpp @@ -15,14 +15,16 @@ #include "utils.hpp" // + standard includes -#ifdef EXV_ENABLE_INIH -#include -#endif #include -#include #include +#if __has_include() +#include namespace fs = std::filesystem; +#else +#include +namespace fs = std::experimental::filesystem; +#endif #if !defined(_WIN32) #include @@ -33,7 +35,10 @@ namespace fs = std::filesystem; #define CSIDL_PROFILE 40 #endif #include +#endif +#ifdef EXV_ENABLE_INIH +#include #endif // ***************************************************************************** diff --git a/unitTests/test_ImageFactory.cpp b/unitTests/test_ImageFactory.cpp index 72793043b8..fb19fec2cb 100644 --- a/unitTests/test_ImageFactory.cpp +++ b/unitTests/test_ImageFactory.cpp @@ -5,10 +5,16 @@ #include // Need to include this header for the Exiv2::Error exception #include + +#if __has_include() #include +namespace fs = std::filesystem; +#else +#include +namespace fs = std::experimental::filesystem; +#endif using namespace Exiv2; -namespace fs = std::filesystem; TEST(TheImageFactory, createsInstancesForFewSupportedTypesInMemory) { // Note that the constructor of these Image classes take an 'create' argument diff --git a/unitTests/test_futils.cpp b/unitTests/test_futils.cpp index 13d47c6ae9..6124e6f080 100644 --- a/unitTests/test_futils.cpp +++ b/unitTests/test_futils.cpp @@ -7,13 +7,18 @@ // Auxiliary headers #include #include -#include #include #include #include +#if __has_include() +#include namespace fs = std::filesystem; +#else +#include +namespace fs = std::experimental::filesystem; +#endif using namespace Exiv2;