From 27ae261d0e3dc11199bc747bde2c85c66631c819 Mon Sep 17 00:00:00 2001 From: Edward Rudd Date: Tue, 31 Dec 2013 16:27:28 -0500 Subject: [PATCH] don't use base name it's destructive to the incoming string which you shouldn't modify as c_str() is const. --- src/config.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index 1775a55..e6f3354 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -101,7 +101,9 @@ void Config::readGameINI() { if (!customScript.empty()) { - game.title = basename(customScript.c_str()); + size_t pos = customScript.find_last_of("/\\"); + if (pos == customScript.npos) pos = 0; + game.title = customScript.substr(pos); return; } @@ -128,6 +130,9 @@ void Config::readGameINI() strReplace(game.scripts, '\\', '/'); - if (game.title.empty()) - game.title = basename(gameFolder.c_str()); + if (game.title.empty()) { + size_t pos = gameFolder.find_last_of("/\\"); + if (pos == gameFolder.npos) pos = 0; + game.title = gameFolder.substr(pos); + } }