Skip to content
Snippets Groups Projects
Commit a701cefd authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

Rewrite copyPathToFileName().

parent 7d49a74d
No related branches found
No related tags found
No related merge requests found
......@@ -114,21 +114,15 @@ bool hasFileExtension(std::string const& extension, std::string const& filename)
return ext == file_ext;
}
std::string copyPathToFileName(const std::string &file_name, const std::string &source)
std::string copyPathToFileName(const std::string &file_name,
const std::string &source)
{
// check if file_name already contains a full path
size_t pos(file_name.rfind("/")); // linux, mac delimiter
if (pos == std::string::npos)
{
pos = file_name.rfind("\\"); // windows delimiter
if (pos == std::string::npos)
{
std::string path = BaseLib::extractPath(source);
return path.append(file_name);
}
else return std::string(file_name);
}
else return std::string(file_name);
const size_t pos = findLastPathSeparator(file_name);
if (pos != std::string::npos)
return file_name;
return BaseLib::extractPath(source).append(file_name);
}
std::string extractPath(std::string const& pathname)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment