System: Ensure titles are sanitized for screenshots

This commit is contained in:
Stenzek 2024-06-28 15:37:03 +10:00
parent 41f40248d2
commit 3877486712
No known key found for this signature in database

View File

@ -4764,13 +4764,13 @@ bool System::SaveScreenshot(const char* filename, DisplayScreenshotMode mode, Di
std::string auto_filename;
if (!filename)
{
const std::string& name = System::GetGameTitle();
const std::string sanitized_name = Path::SanitizeFileName(System::GetGameTitle());
const char* extension = Settings::GetDisplayScreenshotFormatExtension(format);
std::string basename;
if (name.empty())
if (sanitized_name.empty())
basename = fmt::format("{}", GetTimestampStringForFileName());
else
basename = fmt::format("{} {}", name, GetTimestampStringForFileName());
basename = fmt::format("{} {}", sanitized_name, GetTimestampStringForFileName());
auto_filename = fmt::format("{}" FS_OSPATH_SEPARATOR_STR "{}.{}", EmuFolders::Screenshots, basename, extension);