diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index be90574..300a645 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -3397,6 +3397,7 @@ GHC_INLINE bool create_directories(const path& p, std::error_code& ec) noexcept { path current; ec.clear(); + bool didCreate = false; for (path::string_type part : p) { current /= part; if (current != p.root_name() && current != p.root_path()) { @@ -3416,6 +3417,7 @@ GHC_INLINE bool create_directories(const path& p, std::error_code& ec) noexcept return false; } } + didCreate = true; } #ifndef LWG_2935_BEHAVIOUR else if (!is_directory(fs)) { @@ -3425,7 +3427,7 @@ GHC_INLINE bool create_directories(const path& p, std::error_code& ec) noexcept #endif } } - return true; + return didCreate; } GHC_INLINE bool create_directory(const path& p) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4f0686d..71255a4 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -19,7 +19,7 @@ else() target_link_libraries(filesystem_test ghc_filesystem) target_compile_options(filesystem_test PRIVATE $<$:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Werror> - $<$:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Werror -Wno-psabi> + $<$:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Wno-psabi -Werror> $<$:/WX>) if(CMAKE_CXX_COMPILER_ID MATCHES MSVC) target_compile_definitions(filesystem_test PRIVATE _CRT_SECURE_NO_WARNINGS) diff --git a/test/filesystem_test.cpp b/test/filesystem_test.cpp index 62588f9..ffaa0c6 100644 --- a/test/filesystem_test.cpp +++ b/test/filesystem_test.cpp @@ -1674,6 +1674,7 @@ TEST_CASE("30.10.15.6 create_directories", "[filesystem][operations][fs.op.creat CHECK(fs::create_directories(p2)); CHECK(fs::is_directory(p)); CHECK(fs::is_directory(p2)); + CHECK(!fs::create_directories(p2)); #ifdef TEST_LWG_2935_BEHAVIOUR INFO("This test expects LWG #2935 result conformance."); p = t.path() / "testfile";