diff --git a/CMakeLists.txt b/CMakeLists.txt index f344511..811456f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -186,6 +186,9 @@ set(CONFIGURATION_PACKAGE_SUFFIX find_package(c++utilities${CONFIGURATION_PACKAGE_SUFFIX} 5.10.0 REQUIRED) use_cpp_utilities(VISIBILITY PUBLIC) +# link against a possibly required extra library for std::filesystem +use_standard_filesystem() + # find 3rd party libraries include(3rdParty) # zlib diff --git a/backuphelper.cpp b/backuphelper.cpp index 87b7530..294caad 100644 --- a/backuphelper.cpp +++ b/backuphelper.cpp @@ -5,13 +5,8 @@ #include #include -#ifdef PLATFORM_WINDOWS -#include -#else -#include -#endif - #include +#include #include #include #include @@ -155,12 +150,7 @@ void createBackupFile(const std::string &backupDir, const std::string &originalP } // test whether the backup path is still unused; otherwise continue loop -#ifdef PLATFORM_WINDOWS - if (GetFileAttributes(BasicFileInfo::pathForOpen(backupPath).data()) == INVALID_FILE_ATTRIBUTES) { -#else - struct stat backupStat; - if (stat(BasicFileInfo::pathForOpen(backupPath).data(), &backupStat)) { -#endif + if (auto ec = std::error_code(); !std::filesystem::exists(BasicFileInfo::pathForOpen(backupPath), ec)) { break; } }