mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-22 22:34:33 +01:00
Sanitize screenshot path
This commit is contained in:
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user