[platform] Fixed MkDirRecursively

This commit is contained in:
Maksim Andrianov 2018-12-06 17:34:28 +03:00 committed by Tatiana Yan
parent 1513218db9
commit 70661f172c
2 changed files with 6 additions and 2 deletions

View file

@ -40,6 +40,9 @@ inline std::string JoinPath(std::string const & file) { return file; }
template <typename... Args>
std::string JoinPath(std::string const & folder, Args &&... args)
{
if (folder.empty())
return JoinPath(std::forward<Args>(args)...);
return AddSlashIfNeeded(folder) + JoinPath(std::forward<Args>(args)...);
}
} // namespace base

View file

@ -294,8 +294,9 @@ bool Platform::MkDirChecked(string const & dirName)
// static
bool Platform::MkDirRecursively(string const & dirName)
{
auto const tokens = strings::Tokenize(dirName, base::GetNativeSeparator().c_str());
string path = base::GetNativeSeparator();
auto const sep = base::GetNativeSeparator();
string path = strings::StartsWith(dirName, sep) ? sep : "";
auto const tokens = strings::Tokenize(dirName, sep.c_str());
for (auto const & t : tokens)
{
path = base::JoinPath(path, t);