Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion include/rcpputils/filesystem_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,10 @@ inline bool create_directories(const path & p)
path p_built;
int status = 0;

if (p.empty()) {
return true;
}

for (auto it = p.cbegin(); it != p.cend() && status == 0; ++it) {
if (!p_built.empty() || it->empty()) {
p_built /= *it;
Expand All @@ -511,7 +515,7 @@ inline bool create_directories(const path & p)
#endif
}
}
return status == 0;
return p_built.is_directory() && status == 0;
}

/**
Expand Down
1 change: 1 addition & 0 deletions test/test_filesystem_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ TEST(TestFilesystemHelper, filesystem_manipulation)
EXPECT_TRUE(rcpputils::fs::exists(file));
EXPECT_TRUE(rcpputils::fs::is_regular_file(file));
EXPECT_FALSE(rcpputils::fs::is_directory(file));
EXPECT_FALSE(rcpputils::fs::create_directories(file));
EXPECT_GE(rcpputils::fs::file_size(file), expected_file_size);
EXPECT_THROW(rcpputils::fs::file_size(dir), std::system_error) <<
"file_size is only applicable for files!";
Expand Down