MemoryCard: Sanitize game titles for file names

This commit is contained in:
Connor McLaughlin
2021-05-16 16:50:28 +10:00
parent ee5bf410e6
commit bced237034
4 changed files with 21 additions and 2 deletions

View File

@ -24,6 +24,20 @@ MemoryCard::~MemoryCard()
SaveIfChanged(false);
}
std::string MemoryCard::SanitizeGameTitleForFileName(const std::string_view& name)
{
std::string ret(name);
const u32 len = static_cast<u32>(ret.length());
for (u32 i = 0; i < len; i++)
{
if (ret[i] == '\\' || ret[i] == '/' || ret[i] == '?' || ret[i] == '*')
ret[i] = '_';
}
return ret;
}
TickCount MemoryCard::GetSaveDelayInTicks()
{
return System::GetTicksPerSecond() * SAVE_DELAY_IN_SECONDS;