Config: Fix preceeding '/' in deducted game title
Also factor out the common code path
This commit is contained in:
parent
19dc83a5d5
commit
e9cf77dbce
|
@ -108,15 +108,21 @@ void Config::read()
|
||||||
#undef PO_DESC_ALL
|
#undef PO_DESC_ALL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string baseName(const std::string &path)
|
||||||
|
{
|
||||||
|
size_t pos = path.find_last_of("/\\") + 1;
|
||||||
|
|
||||||
|
if (pos == path.npos)
|
||||||
|
pos = 0;
|
||||||
|
|
||||||
|
return path.substr(pos);
|
||||||
|
}
|
||||||
|
|
||||||
void Config::readGameINI()
|
void Config::readGameINI()
|
||||||
{
|
{
|
||||||
if (!customScript.empty())
|
if (!customScript.empty())
|
||||||
{
|
{
|
||||||
size_t pos = customScript.find_last_of("/\\");
|
game.title = baseName(customScript);
|
||||||
if (pos == customScript.npos)
|
|
||||||
pos = 0;
|
|
||||||
game.title = customScript.substr(pos);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,10 +149,5 @@ void Config::readGameINI()
|
||||||
strReplace(game.scripts, '\\', '/');
|
strReplace(game.scripts, '\\', '/');
|
||||||
|
|
||||||
if (game.title.empty())
|
if (game.title.empty())
|
||||||
{
|
game.title = baseName(gameFolder);
|
||||||
size_t pos = gameFolder.find_last_of("/\\");
|
|
||||||
if (pos == gameFolder.npos)
|
|
||||||
pos = 0;
|
|
||||||
game.title = gameFolder.substr(pos);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue