Skip to content
Snippets Groups Projects
Commit 16dd98d9 authored by Tom Fischer's avatar Tom Fischer
Browse files

[BL] copyPathToFileName: Fix unexpected behaviour.

parent e01eba56
No related branches found
No related tags found
No related merge requests found
...@@ -123,6 +123,13 @@ bool hasFileExtension(std::string const& extension, std::string const& filename) ...@@ -123,6 +123,13 @@ bool hasFileExtension(std::string const& extension, std::string const& filename)
return boost::iequals(extension, getFileExtension(filename)); return boost::iequals(extension, getFileExtension(filename));
} }
static const char pathSeparator =
#ifdef _WIN32
'\\';
#else
'/';
#endif
std::string copyPathToFileName(const std::string &file_name, std::string copyPathToFileName(const std::string &file_name,
const std::string &source) const std::string &source)
{ {
...@@ -131,6 +138,10 @@ std::string copyPathToFileName(const std::string &file_name, ...@@ -131,6 +138,10 @@ std::string copyPathToFileName(const std::string &file_name,
if (pos != std::string::npos) if (pos != std::string::npos)
return file_name; return file_name;
if (source.empty())
return file_name;
if (source.back() != pathSeparator)
return BaseLib::extractPath(source + pathSeparator).append(file_name);
return BaseLib::extractPath(source).append(file_name); return BaseLib::extractPath(source).append(file_name);
} }
...@@ -141,12 +152,6 @@ std::string extractPath(std::string const& pathname) ...@@ -141,12 +152,6 @@ std::string extractPath(std::string const& pathname)
return ""; return "";
return pathname.substr(0, pos + 1); return pathname.substr(0, pos + 1);
} }
static const char pathSeparator =
#ifdef _WIN32
'\\';
#else
'/';
#endif
std::string appendPathSeparator(std::string const& path) std::string appendPathSeparator(std::string const& path)
{ {
......
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