1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-22 22:34:33 +01:00

Sanitize screenshot path

This commit is contained in:
Tom Lankhorst
2019-02-03 22:59:28 +01:00
committed by Ted John
parent ebefe5721b
commit bbd69496b4
5 changed files with 119 additions and 72 deletions

View File

@@ -28,8 +28,10 @@
# include "../util/Util.h"
# include "platform.h"
# include <algorithm>
# include <iterator>
# include <lmcons.h>
# include <memory>
# include <psapi.h>
# include <shlobj.h>
# include <sys/stat.h>
@@ -253,6 +255,22 @@ std::string platform_get_rct2_steam_dir()
return "Rollercoaster Tycoon 2";
}
std::string platform_sanitise_filename(const std::string& path)
{
auto sanitised = path;
std::vector<std::string::value_type> prohibited = { '<', '>', '*', '\\', ':', '|', '?', '"', '/' };
std::replace_if(
sanitised.begin(), sanitised.end(),
[](const std::string::value_type& ch) {
return std::find(prohibited.begin(), prohibited.end(), ch) != prohibited.end();
},
'_');
return sanitised;
}
uint16_t platform_get_locale_language()
{
CHAR langCode[4];