refs #55, fs::create_directories reported true if it didn't need to create anything.

This commit is contained in:
Steffen Schuemann 2020-03-05 06:48:54 +01:00
parent 70a0085a47
commit d93ccea812
3 changed files with 5 additions and 2 deletions

View File

@ -3397,6 +3397,7 @@ GHC_INLINE bool create_directories(const path& p, std::error_code& ec) noexcept
{ {
path current; path current;
ec.clear(); ec.clear();
bool didCreate = false;
for (path::string_type part : p) { for (path::string_type part : p) {
current /= part; current /= part;
if (current != p.root_name() && current != p.root_path()) { 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; return false;
} }
} }
didCreate = true;
} }
#ifndef LWG_2935_BEHAVIOUR #ifndef LWG_2935_BEHAVIOUR
else if (!is_directory(fs)) { else if (!is_directory(fs)) {
@ -3425,7 +3427,7 @@ GHC_INLINE bool create_directories(const path& p, std::error_code& ec) noexcept
#endif #endif
} }
} }
return true; return didCreate;
} }
GHC_INLINE bool create_directory(const path& p) GHC_INLINE bool create_directory(const path& p)

View File

@ -19,7 +19,7 @@ else()
target_link_libraries(filesystem_test ghc_filesystem) target_link_libraries(filesystem_test ghc_filesystem)
target_compile_options(filesystem_test PRIVATE target_compile_options(filesystem_test PRIVATE
$<$<CXX_COMPILER_ID:Clang>:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Werror> $<$<CXX_COMPILER_ID:Clang>:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Werror>
$<$<CXX_COMPILER_ID:GNU>:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Werror -Wno-psabi> $<$<CXX_COMPILER_ID:GNU>:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Wno-psabi -Werror>
$<$<CXX_COMPILER_ID:MSVC>:/WX>) $<$<CXX_COMPILER_ID:MSVC>:/WX>)
if(CMAKE_CXX_COMPILER_ID MATCHES MSVC) if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
target_compile_definitions(filesystem_test PRIVATE _CRT_SECURE_NO_WARNINGS) target_compile_definitions(filesystem_test PRIVATE _CRT_SECURE_NO_WARNINGS)

View File

@ -1674,6 +1674,7 @@ TEST_CASE("30.10.15.6 create_directories", "[filesystem][operations][fs.op.creat
CHECK(fs::create_directories(p2)); CHECK(fs::create_directories(p2));
CHECK(fs::is_directory(p)); CHECK(fs::is_directory(p));
CHECK(fs::is_directory(p2)); CHECK(fs::is_directory(p2));
CHECK(!fs::create_directories(p2));
#ifdef TEST_LWG_2935_BEHAVIOUR #ifdef TEST_LWG_2935_BEHAVIOUR
INFO("This test expects LWG #2935 result conformance."); INFO("This test expects LWG #2935 result conformance.");
p = t.path() / "testfile"; p = t.path() / "testfile";