Skip to content

Commit

Permalink
refs #55, fs::create_directories reported true if it didn't need to c…
Browse files Browse the repository at this point in the history
…reate anything.
  • Loading branch information
gulrak committed Mar 5, 2020
1 parent 70a0085 commit d93ccea
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion include/ghc/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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)) {
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ else()
target_link_libraries(filesystem_test ghc_filesystem)
target_compile_options(filesystem_test PRIVATE
$<$<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>)
if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
target_compile_definitions(filesystem_test PRIVATE _CRT_SECURE_NO_WARNINGS)
Expand Down
1 change: 1 addition & 0 deletions test/filesystem_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit d93ccea

Please sign in to comment.