From be9d569e78104044fd3d8e39343dff642c57bbb5 Mon Sep 17 00:00:00 2001 From: Vincent-FK Date: Sun, 27 Sep 2020 15:33:32 +0200 Subject: [PATCH] save Utils::getFileName return string value as static in order for it to be accessible outside the function scope Signed-off-by: Vincent-FK --- RetroFE/Source/Utility/Utils.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/RetroFE/Source/Utility/Utils.cpp b/RetroFE/Source/Utility/Utils.cpp index f0840dd..7622f31 100755 --- a/RetroFE/Source/Utility/Utils.cpp +++ b/RetroFE/Source/Utility/Utils.cpp @@ -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)