Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure that an existing path is a directory for create_directories #98

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/rcpputils/filesystem_helper.hpp
Expand Up @@ -511,7 +511,7 @@ inline bool create_directories(const path & p)
#endif
}
}
return status == 0;
return status == 0 && p_built.is_directory();
ivanpauno marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
4 changes: 4 additions & 0 deletions test/test_filesystem_helper.cpp
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));
christophebedard marked this conversation as resolved.
Show resolved Hide resolved
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 Expand Up @@ -352,6 +353,9 @@ TEST(TestFilesystemHelper, filesystem_manipulation)
ASSERT_FALSE(rcpputils::fs::exists(file));
}
ASSERT_FALSE(rcpputils::fs::exists(dir));

// Empty path/directory cannot be created
EXPECT_FALSE(rcpputils::fs::create_directories(rcpputils::fs::path("")));
}

TEST(TestFilesystemHelper, remove_extension)
Expand Down