small fix to allow the foldername to be empty #9922
2 changed files with 8 additions and 3 deletions
|
@ -81,6 +81,8 @@ UNIT_TEST(FilePath_Join)
|
|||
TEST_EQUAL("omim/strings.txt", base::JoinPath("omim/", "strings.txt"), ());
|
||||
TEST_EQUAL("../../omim/strings.txt", base::JoinPath("..", "..", "omim", "strings.txt"), ());
|
||||
TEST_EQUAL("../../omim/strings.txt", base::JoinPath("../", "..", "omim/", "strings.txt"), ());
|
||||
TEST_EQUAL("omim/strings.txt", base::JoinPath("", "omim/", "strings.txt"), ());
|
||||
TEST_EQUAL("omim/strings.txt", base::JoinPath("", "","omim/", "strings.txt"), ());
|
||||
}
|
||||
|
||||
#endif // OMIM_OS_WINDOWS
|
||||
|
|
|
@ -40,7 +40,12 @@ template <typename... Args>
|
|||
std::string JoinPath(std::string const & folder, Args &&... args)
|
||||
{
|
||||
if (folder.empty())
|
||||
return {};
|
||||
{
|
||||
if (sizeof...(args) == 0)
|
||||
return {};
|
||||
else
|
||||
return impl::JoinPath(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
return AddSlashIfNeeded(folder) + impl::JoinPath(std::forward<Args>(args)...);
|
||||
}
|
||||
|
@ -50,8 +55,6 @@ std::string JoinPath(std::string const & folder, Args &&... args)
|
|||
template <typename... Args>
|
||||
std::string JoinPath(std::string const & dir, std::string const & fileOrDir, Args &&... args)
|
||||
{
|
||||
ASSERT(!dir.empty(), ("JoinPath dir is empty"));
|
||||
ASSERT(!fileOrDir.empty(), ("JoinPath fileOrDir is empty"));
|
||||
return impl::JoinPath(dir, fileOrDir, std::forward<Args>(args)...);
|
||||
}
|
||||
} // namespace base
|
||||
|
|
Reference in a new issue