save Utils::getFileName return string value as static in order for it to be accessible outside the function scope

Signed-off-by: Vincent-FK <vincent.buso@funkey-project.com>
This commit is contained in:
Vincent-FK 2020-09-27 15:33:32 +02:00
parent e2951c7b8e
commit be9d569e78

View File

@ -241,7 +241,9 @@ std::string Utils::getParentDirectory(std::string directory)
std::string Utils::getFileName(std::string filePath)
{
std::string filename = filePath;
/** Declared static to be kept in memory even after this function's scope */
static std::string filename;
filename = filePath;
const size_t last_slash_idx = filePath.rfind(pathSeparator);
if (std::string::npos != last_slash_idx)