1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-23 23:04:36 +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,6 +28,7 @@
#include "../world/Climate.h"
#include "platform.h"
#include <algorithm>
#include <stdlib.h>
#include <time.h>
@@ -198,6 +199,24 @@ uint8_t platform_get_currency_value(const char* currCode)
return CURRENCY_POUNDS;
}
#ifndef _WIN32
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(),
[&prohibited](const std::string::value_type& ch) {
return std::find(prohibited.begin(), prohibited.end(), ch) != prohibited.end();
},
'_');
return sanitised;
}
#endif
#ifndef __ANDROID__
float platform_get_default_scale()
{