Fixed cppcheck warning

This commit is contained in:
Jan Möbius
2023-08-23 11:00:36 +02:00
parent d53a9c99fc
commit 56e967da79

View File

@@ -178,9 +178,18 @@ replace_extension( std::string& _s, const std::string& _e )
{ {
std::string::size_type dot = _s.rfind("."); std::string::size_type dot = _s.rfind(".");
if (dot == std::string::npos) if (dot == std::string::npos)
{ _s += "." + _e; } {
// The name does not include a dot and therefore no extension. Adding both.
_s += "." + _e;
}
else else
{ _s = _s.substr(0,dot+1)+_e; } {
// get everything of the name including the dot but remove the extension.
const std::string name = _s.substr(0,dot+1);
// Add the new extenion
_s = name + _e;
}
return _s; return _s;
} }