From 77e5defecabb2a991e4e34cc58062296389463b4 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Wed, 5 Jan 2022 14:17:19 +0100 Subject: [PATCH 1/6] Upgrade platform_original_game_data_exists() --- src/openrct2/Context.cpp | 2 +- src/openrct2/config/Config.cpp | 10 +++++----- src/openrct2/platform/Platform2.h | 2 ++ src/openrct2/platform/Posix.cpp | 9 --------- src/openrct2/platform/Shared.cpp | 7 +++++++ src/openrct2/platform/Windows.cpp | 9 --------- src/openrct2/platform/platform.h | 1 - 7 files changed, 15 insertions(+), 25 deletions(-) diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index 524727a1fc..ac71323c15 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -772,7 +772,7 @@ namespace OpenRCT2 if (String::IsNullOrEmpty(gCustomRCT2DataPath)) { // Check install directory - if (gConfigGeneral.rct2_path.empty() || !platform_original_game_data_exists(gConfigGeneral.rct2_path.c_str())) + if (gConfigGeneral.rct2_path.empty() || !Platform::OriginalGameDataExists(gConfigGeneral.rct2_path)) { log_verbose( "install directory does not exist or invalid directory selected, %s", gConfigGeneral.rct2_path.c_str()); diff --git a/src/openrct2/config/Config.cpp b/src/openrct2/config/Config.cpp index 1390aee5b8..e228409149 100644 --- a/src/openrct2/config/Config.cpp +++ b/src/openrct2/config/Config.cpp @@ -695,7 +695,7 @@ namespace Config for (const utf8* location : searchLocations) { - if (platform_original_game_data_exists(location)) + if (Platform::OriginalGameDataExists(location)) { return location; } @@ -705,20 +705,20 @@ namespace Config if (platform_get_steam_path(steamPath, sizeof(steamPath))) { std::string location = Path::Combine(steamPath, platform_get_rct2_steam_dir()); - if (platform_original_game_data_exists(location.c_str())) + if (Platform::OriginalGameDataExists(location)) { return location; } } auto discordPath = Platform::GetFolderPath(SPECIAL_FOLDER::RCT2_DISCORD); - if (!discordPath.empty() && platform_original_game_data_exists(discordPath.c_str())) + if (!discordPath.empty() && Platform::OriginalGameDataExists(discordPath)) { return discordPath; } auto exePath = Path::GetDirectory(Platform::GetCurrentExecutablePath()); - if (platform_original_game_data_exists(exePath.c_str())) + if (Platform::OriginalGameDataExists(exePath)) { return exePath; } @@ -922,7 +922,7 @@ bool config_find_or_browse_install_directory() } gConfigGeneral.rct2_path = installPath; - if (platform_original_game_data_exists(installPath.c_str())) + if (Platform::OriginalGameDataExists(installPath)) { return true; } diff --git a/src/openrct2/platform/Platform2.h b/src/openrct2/platform/Platform2.h index 98d886d282..936b0c8675 100644 --- a/src/openrct2/platform/Platform2.h +++ b/src/openrct2/platform/Platform2.h @@ -46,6 +46,8 @@ namespace Platform bool FindApp(const std::string& app, std::string* output); int32_t Execute(const std::string& command, std::string* output = nullptr); + bool OriginalGameDataExists(std::string_view path); + #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD__) std::string GetEnvironmentPath(const char* name); std::string GetHomePath(); diff --git a/src/openrct2/platform/Posix.cpp b/src/openrct2/platform/Posix.cpp index af42078dcf..720fa8c38c 100644 --- a/src/openrct2/platform/Posix.cpp +++ b/src/openrct2/platform/Posix.cpp @@ -77,15 +77,6 @@ bool platform_directory_exists(const utf8* path) return result == 0 && S_ISDIR(dirinfo.st_mode); } -bool platform_original_game_data_exists(const utf8* path) -{ - char checkPath[MAX_PATH]; - safe_strcpy(checkPath, path, MAX_PATH); - safe_strcat_path(checkPath, "Data", MAX_PATH); - safe_strcat_path(checkPath, "g1.dat", MAX_PATH); - return Platform::FileExists(checkPath); -} - // Implement our own version of getumask(), as it is documented being // "a vaporware GNU extension". static mode_t openrct2_getumask() diff --git a/src/openrct2/platform/Shared.cpp b/src/openrct2/platform/Shared.cpp index 4a2ab65df6..dff4ae2ca9 100644 --- a/src/openrct2/platform/Shared.cpp +++ b/src/openrct2/platform/Shared.cpp @@ -20,6 +20,7 @@ #include "../OpenRCT2.h" #include "../config/Config.h" #include "../core/FileSystem.hpp" +#include "../core/Path.hpp" #include "../drawing/Drawing.h" #include "../drawing/LightFX.h" #include "../localisation/Currency.h" @@ -99,6 +100,12 @@ namespace Platform log_verbose("Checking if file exists: %s", path.c_str()); return fs::exists(file); } + + bool OriginalGameDataExists(std::string_view path) + { + std::string combinedPath = Path::ResolveCasing(Path::Combine(path, "Data", "g1.dat")); + return Platform::FileExists(combinedPath); + } } // namespace Platform using update_palette_func = void (*)(const uint8_t*, int32_t, int32_t); diff --git a/src/openrct2/platform/Windows.cpp b/src/openrct2/platform/Windows.cpp index 04c70360e1..41cc19b896 100644 --- a/src/openrct2/platform/Windows.cpp +++ b/src/openrct2/platform/Windows.cpp @@ -66,15 +66,6 @@ bool platform_directory_exists(const utf8* path) return dwAttrib != INVALID_FILE_ATTRIBUTES && (dwAttrib & FILE_ATTRIBUTE_DIRECTORY); } -bool platform_original_game_data_exists(const utf8* path) -{ - utf8 checkPath[MAX_PATH]; - safe_strcpy(checkPath, path, MAX_PATH); - safe_strcat_path(checkPath, "Data", MAX_PATH); - safe_strcat_path(checkPath, "g1.dat", MAX_PATH); - return Platform::FileExists(checkPath); -} - bool platform_ensure_directory_exists(const utf8* path) { if (platform_directory_exists(path)) diff --git a/src/openrct2/platform/platform.h b/src/openrct2/platform/platform.h index af85318121..d7d357c686 100644 --- a/src/openrct2/platform/platform.h +++ b/src/openrct2/platform/platform.h @@ -90,7 +90,6 @@ void platform_get_time_utc(rct2_time* out_time); // Platform specific definitions bool platform_directory_exists(const utf8* path); -bool platform_original_game_data_exists(const utf8* path); time_t platform_file_get_modified_time(const utf8* path); bool platform_ensure_directory_exists(const utf8* path); bool platform_directory_delete(const utf8* path); From 2e7e90a0185b15a06a0e445b60e51b4465b2ca40 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Wed, 5 Jan 2022 14:26:00 +0100 Subject: [PATCH 2/6] Remove platform_get_openrct2_data_path() --- src/openrct2/Context.cpp | 11 ----------- src/openrct2/drawing/Drawing.Sprite.cpp | 6 +++--- src/openrct2/platform/macos.mm | 6 ------ src/openrct2/platform/platform.h | 1 - 4 files changed, 3 insertions(+), 21 deletions(-) diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index ac71323c15..7d310e3df1 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -1557,14 +1557,3 @@ void platform_get_user_directory(utf8* outPath, const utf8* subDirectory, size_t } String::Set(outPath, outSize, path.c_str()); } - -/** - * This function is deprecated. - * Use IPlatformEnvironment instead. - */ -void platform_get_openrct2_data_path(utf8* outPath, size_t outSize) -{ - auto env = GetContext()->GetPlatformEnvironment(); - auto path = env->GetDirectoryPath(DIRBASE::OPENRCT2); - String::Set(outPath, outSize, path.c_str()); -} diff --git a/src/openrct2/drawing/Drawing.Sprite.cpp b/src/openrct2/drawing/Drawing.Sprite.cpp index 7bf52cd054..b7046e8146 100644 --- a/src/openrct2/drawing/Drawing.Sprite.cpp +++ b/src/openrct2/drawing/Drawing.Sprite.cpp @@ -265,10 +265,10 @@ bool gfx_load_g2() { log_verbose("gfx_load_g2()"); - char path[MAX_PATH]; + auto env = GetContext()->GetPlatformEnvironment(); + + std::string path = Path::Combine(env->GetDirectoryPath(DIRBASE::OPENRCT2), "g2.dat"); - platform_get_openrct2_data_path(path, sizeof(path)); - safe_strcat_path(path, "g2.dat", MAX_PATH); try { auto fs = FileStream(path, FILE_MODE_OPEN); diff --git a/src/openrct2/platform/macos.mm b/src/openrct2/platform/macos.mm index 099454291b..abfa15ee88 100644 --- a/src/openrct2/platform/macos.mm +++ b/src/openrct2/platform/macos.mm @@ -137,12 +137,6 @@ MeasurementFormat platform_get_locale_measurement_format() } } -void platform_get_changelog_path(utf8* outPath, size_t outSize) -{ - platform_get_openrct2_data_path(outPath, outSize); - safe_strcat_path(outPath, "changelog.txt", outSize); -} - bool platform_get_steam_path(utf8* outPath, size_t outSize) { char steamPath[1024] = { 0 }; diff --git a/src/openrct2/platform/platform.h b/src/openrct2/platform/platform.h index d7d357c686..894f2f2c86 100644 --- a/src/openrct2/platform/platform.h +++ b/src/openrct2/platform/platform.h @@ -104,7 +104,6 @@ bool platform_file_move(const utf8* srcPath, const utf8* dstPath); bool platform_file_delete(const utf8* path); uint32_t platform_get_ticks(); void platform_sleep(uint32_t ms); -void platform_get_openrct2_data_path(utf8* outPath, size_t outSize); void platform_get_user_directory(utf8* outPath, const utf8* subDirectory, size_t outSize); std::string platform_get_username(); bool platform_open_common_file_dialog(utf8* outFilename, file_dialog_desc* desc, size_t outSize); From a21e54591712e889b05a0b89056a3c3e83172feb Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Wed, 5 Jan 2022 14:42:46 +0100 Subject: [PATCH 3/6] Upgrade platform_get_username() --- src/openrct2/config/Config.cpp | 2 +- src/openrct2/platform/Platform.Posix.cpp | 11 +++++++++++ src/openrct2/platform/Platform.Win32.cpp | 13 +++++++++++++ src/openrct2/platform/Platform2.h | 2 ++ src/openrct2/platform/Posix.cpp | 11 ----------- src/openrct2/platform/Windows.cpp | 12 ------------ src/openrct2/platform/platform.h | 1 - 7 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/openrct2/config/Config.cpp b/src/openrct2/config/Config.cpp index e228409149..ce1a3c3ab6 100644 --- a/src/openrct2/config/Config.cpp +++ b/src/openrct2/config/Config.cpp @@ -388,7 +388,7 @@ namespace Config auto playerName = reader->GetString("player_name", ""); if (playerName.empty()) { - playerName = platform_get_username(); + playerName = Platform::GetUsername(); if (playerName.empty()) { playerName = "Player"; diff --git a/src/openrct2/platform/Platform.Posix.cpp b/src/openrct2/platform/Platform.Posix.cpp index 1b1ec5ecd1..73bba433a4 100644 --- a/src/openrct2/platform/Platform.Posix.cpp +++ b/src/openrct2/platform/Platform.Posix.cpp @@ -253,6 +253,17 @@ namespace Platform { return true; } + + std::string GetUsername() + { + std::string result; + auto pw = getpwuid(getuid()); + if (pw != nullptr) + { + result = std::string(pw->pw_name); + } + return result; + } } // namespace Platform #endif diff --git a/src/openrct2/platform/Platform.Win32.cpp b/src/openrct2/platform/Platform.Win32.cpp index 1cd6a50026..92e2100222 100644 --- a/src/openrct2/platform/Platform.Win32.cpp +++ b/src/openrct2/platform/Platform.Win32.cpp @@ -16,6 +16,7 @@ # include "../Version.h" # include +# include # include # include # undef GetEnvironmentVariable @@ -613,6 +614,18 @@ namespace Platform // using the same window in an unaccelerated and accelerated context is unsupported by SDL2 return openGL; } + + std::string GetUsername() + { + std::string result; + wchar_t usernameW[UNLEN + 1]{}; + DWORD usernameLength = UNLEN + 1; + if (GetUserNameW(usernameW, &usernameLength)) + { + result = String::ToUtf8(usernameW); + } + return result; + } } // namespace Platform #endif diff --git a/src/openrct2/platform/Platform2.h b/src/openrct2/platform/Platform2.h index 936b0c8675..ab99e0fc14 100644 --- a/src/openrct2/platform/Platform2.h +++ b/src/openrct2/platform/Platform2.h @@ -48,6 +48,8 @@ namespace Platform bool OriginalGameDataExists(std::string_view path); + std::string GetUsername(); + #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD__) std::string GetEnvironmentPath(const char* name); std::string GetHomePath(); diff --git a/src/openrct2/platform/Posix.cpp b/src/openrct2/platform/Posix.cpp index 720fa8c38c..5bb15be93e 100644 --- a/src/openrct2/platform/Posix.cpp +++ b/src/openrct2/platform/Posix.cpp @@ -337,17 +337,6 @@ datetime64 platform_get_datetime_now_utc() return utcNow; } -std::string platform_get_username() -{ - std::string result; - auto pw = getpwuid(getuid()); - if (pw != nullptr) - { - result = std::string(pw->pw_name); - } - return result; -} - bool platform_process_is_elevated() { # ifndef __EMSCRIPTEN__ diff --git a/src/openrct2/platform/Windows.cpp b/src/openrct2/platform/Windows.cpp index 41cc19b896..19738ebb28 100644 --- a/src/openrct2/platform/Windows.cpp +++ b/src/openrct2/platform/Windows.cpp @@ -460,18 +460,6 @@ datetime64 platform_get_datetime_now_utc() return utcNow; } -std::string platform_get_username() -{ - std::string result; - wchar_t usernameW[UNLEN + 1]{}; - DWORD usernameLength = UNLEN + 1; - if (GetUserNameW(usernameW, &usernameLength)) - { - result = String::ToUtf8(usernameW); - } - return result; -} - bool platform_process_is_elevated() { BOOL isElevated = FALSE; diff --git a/src/openrct2/platform/platform.h b/src/openrct2/platform/platform.h index 894f2f2c86..b83c6fb8a4 100644 --- a/src/openrct2/platform/platform.h +++ b/src/openrct2/platform/platform.h @@ -105,7 +105,6 @@ bool platform_file_delete(const utf8* path); uint32_t platform_get_ticks(); void platform_sleep(uint32_t ms); void platform_get_user_directory(utf8* outPath, const utf8* subDirectory, size_t outSize); -std::string platform_get_username(); bool platform_open_common_file_dialog(utf8* outFilename, file_dialog_desc* desc, size_t outSize); utf8* platform_open_directory_browser(const utf8* title); CurrencyType platform_get_locale_currency(); From 1eba59699712616ba59b4b2c65b971dbdd9054a2 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Wed, 5 Jan 2022 14:52:19 +0100 Subject: [PATCH 4/6] Remove platform_get_{date,time}_utc() --- src/openrct2/platform/Posix.cpp | 27 --------------------------- src/openrct2/platform/platform.h | 2 -- 2 files changed, 29 deletions(-) diff --git a/src/openrct2/platform/Posix.cpp b/src/openrct2/platform/Posix.cpp index 5bb15be93e..675142a9c8 100644 --- a/src/openrct2/platform/Posix.cpp +++ b/src/openrct2/platform/Posix.cpp @@ -42,33 +42,6 @@ static utf8 _userDataDirectoryPath[MAX_PATH] = { 0 }; -void platform_get_date_utc(rct2_date* out_date) -{ - assert(out_date != nullptr); - time_t rawtime; - struct tm* timeinfo; - struct tm buf; - time(&rawtime); - timeinfo = gmtime_r(&rawtime, &buf); - out_date->day = timeinfo->tm_mday; - out_date->month = timeinfo->tm_mon + 1; - out_date->year = timeinfo->tm_year + 1900; - out_date->day_of_week = timeinfo->tm_wday; -} - -void platform_get_time_utc(rct2_time* out_time) -{ - assert(out_time != nullptr); - time_t rawtime; - struct tm* timeinfo; - struct tm buf; - time(&rawtime); - timeinfo = gmtime_r(&rawtime, &buf); - out_time->second = timeinfo->tm_sec; - out_time->minute = timeinfo->tm_min; - out_time->hour = timeinfo->tm_hour; -} - bool platform_directory_exists(const utf8* path) { struct stat dirinfo; diff --git a/src/openrct2/platform/platform.h b/src/openrct2/platform/platform.h index b83c6fb8a4..17e37d9b9b 100644 --- a/src/openrct2/platform/platform.h +++ b/src/openrct2/platform/platform.h @@ -85,8 +85,6 @@ struct file_dialog_desc void platform_update_palette(const uint8_t* colours, int32_t start_index, int32_t num_colours); void platform_toggle_windowed_mode(); void platform_refresh_video(bool recreate_window); -void platform_get_date_utc(rct2_date* out_date); -void platform_get_time_utc(rct2_time* out_time); // Platform specific definitions bool platform_directory_exists(const utf8* path); From de867827a1c1d582e7e60c36e9b3f1585ff1f700 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Wed, 5 Jan 2022 14:53:41 +0100 Subject: [PATCH 5/6] Remove update_palette_func --- src/openrct2/platform/Shared.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/openrct2/platform/Shared.cpp b/src/openrct2/platform/Shared.cpp index dff4ae2ca9..8e17060ed6 100644 --- a/src/openrct2/platform/Shared.cpp +++ b/src/openrct2/platform/Shared.cpp @@ -108,8 +108,6 @@ namespace Platform } } // namespace Platform -using update_palette_func = void (*)(const uint8_t*, int32_t, int32_t); - GamePalette gPalette; void platform_update_palette(const uint8_t* colours, int32_t start_index, int32_t num_colours) From e4496c41bd83bd1f20e76bdd33dd9e2977b817a3 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Wed, 5 Jan 2022 15:00:16 +0100 Subject: [PATCH 6/6] Upgrade platform_sanitise_filename() --- src/openrct2/interface/Screenshot.cpp | 2 +- src/openrct2/platform/Platform2.h | 2 ++ src/openrct2/platform/Shared.cpp | 34 +++++++++++++++------------ src/openrct2/platform/Windows.cpp | 14 ----------- src/openrct2/platform/platform.h | 1 - test/tests/Platform.cpp | 18 ++++++-------- 6 files changed, 29 insertions(+), 42 deletions(-) diff --git a/src/openrct2/interface/Screenshot.cpp b/src/openrct2/interface/Screenshot.cpp index 6f2674d823..0aa89605c3 100644 --- a/src/openrct2/interface/Screenshot.cpp +++ b/src/openrct2/interface/Screenshot.cpp @@ -139,7 +139,7 @@ static std::optional screenshot_get_next_path() // Generate a path with a `tries` number auto pathComposer = [&screenshotDirectory, &name](int tries) { - auto composedFilename = platform_sanitise_filename( + auto composedFilename = Platform::SanitiseFilename( name + ((tries > 0) ? " ("s + std::to_string(tries) + ")" : ""s) + ".png"); return screenshotDirectory + PATH_SEPARATOR + composedFilename; }; diff --git a/src/openrct2/platform/Platform2.h b/src/openrct2/platform/Platform2.h index ab99e0fc14..dee152a456 100644 --- a/src/openrct2/platform/Platform2.h +++ b/src/openrct2/platform/Platform2.h @@ -50,6 +50,8 @@ namespace Platform std::string GetUsername(); + std::string SanitiseFilename(std::string_view originalName); + #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD__) std::string GetEnvironmentPath(const char* name); std::string GetHomePath(); diff --git a/src/openrct2/platform/Shared.cpp b/src/openrct2/platform/Shared.cpp index 8e17060ed6..7dc3e0b8b7 100644 --- a/src/openrct2/platform/Shared.cpp +++ b/src/openrct2/platform/Shared.cpp @@ -21,6 +21,7 @@ #include "../config/Config.h" #include "../core/FileSystem.hpp" #include "../core/Path.hpp" +#include "../core/String.hpp" #include "../drawing/Drawing.h" #include "../drawing/LightFX.h" #include "../localisation/Currency.h" @@ -106,6 +107,24 @@ namespace Platform std::string combinedPath = Path::ResolveCasing(Path::Combine(path, "Data", "g1.dat")); return Platform::FileExists(combinedPath); } + + std::string SanitiseFilename(std::string_view originalName) + { +#ifdef _WIN32 + static constexpr std::array prohibited = { '<', '>', '*', '\\', ':', '|', '?', '"', '/' }; +#else + static constexpr std::array prohibited = { '/' }; +#endif + auto sanitised = std::string(originalName); + std::replace_if( + sanitised.begin(), sanitised.end(), + [](const std::string::value_type& ch) -> bool { + return std::find(prohibited.begin(), prohibited.end(), ch) != prohibited.end(); + }, + '_'); + sanitised = String::Trim(sanitised); + return sanitised; + } } // namespace Platform GamePalette gPalette; @@ -241,21 +260,6 @@ CurrencyType platform_get_currency_value(const char* currCode) return CurrencyType::Pounds; } -#ifndef _WIN32 -std::string platform_sanitise_filename(const std::string& path) -{ - static constexpr std::array prohibited = { '/' }; - auto sanitised = path; - std::replace_if( - sanitised.begin(), sanitised.end(), - [](const std::string::value_type& ch) -> bool { - return std::find(prohibited.begin(), prohibited.end(), ch) != prohibited.end(); - }, - '_'); - return sanitised; -} -#endif - #ifndef __ANDROID__ float platform_get_default_scale() { diff --git a/src/openrct2/platform/Windows.cpp b/src/openrct2/platform/Windows.cpp index 19738ebb28..13aefacb2b 100644 --- a/src/openrct2/platform/Windows.cpp +++ b/src/openrct2/platform/Windows.cpp @@ -185,20 +185,6 @@ std::string platform_get_rct2_steam_dir() return "Rollercoaster Tycoon 2"; } -std::string platform_sanitise_filename(const std::string& path) -{ - static constexpr std::array prohibited = { '<', '>', '*', '\\', ':', '|', '?', '"', '/' }; - auto sanitised = path; - std::replace_if( - sanitised.begin(), sanitised.end(), - [](const std::string::value_type& ch) -> bool { - return std::find(prohibited.begin(), prohibited.end(), ch) != prohibited.end(); - }, - '_'); - sanitised = String::Trim(sanitised); - return sanitised; -} - uint16_t platform_get_locale_language() { CHAR langCode[4]; diff --git a/src/openrct2/platform/platform.h b/src/openrct2/platform/platform.h index 17e37d9b9b..3b547ddbfb 100644 --- a/src/openrct2/platform/platform.h +++ b/src/openrct2/platform/platform.h @@ -115,7 +115,6 @@ bool platform_process_is_elevated(); bool platform_get_steam_path(utf8* outPath, size_t outSize); std::string platform_get_rct1_steam_dir(); std::string platform_get_rct2_steam_dir(); -std::string platform_sanitise_filename(const std::string&); #ifndef NO_TTF bool platform_get_font_path(TTFFontDescriptor* font, utf8* buffer, size_t size); diff --git a/test/tests/Platform.cpp b/test/tests/Platform.cpp index dccea3aad0..4724d6735d 100644 --- a/test/tests/Platform.cpp +++ b/test/tests/Platform.cpp @@ -8,21 +8,17 @@ *****************************************************************************/ #include -#include +#include TEST(platform, sanitise_filename) { + ASSERT_EQ("normal-filename.png", Platform::SanitiseFilename("normal-filename.png")); + ASSERT_EQ("utf🎱", Platform::SanitiseFilename("utf🎱")); + ASSERT_EQ("forbidden_char", Platform::SanitiseFilename("forbidden/char")); + ASSERT_EQ("non trimmed", Platform::SanitiseFilename(" non trimmed ")); #ifndef _WIN32 - ASSERT_EQ("normal-filename.png", platform_sanitise_filename("normal-filename.png")); - ASSERT_EQ("utf🎱", platform_sanitise_filename("utf🎱")); - ASSERT_EQ("forbidden_char", platform_sanitise_filename("forbidden/char")); - ASSERT_EQ("forbidden_\\:\"|?*chars", platform_sanitise_filename("forbidden/\\:\"|?*chars")); - ASSERT_EQ(" non trimmed ", platform_sanitise_filename(" non trimmed ")); + ASSERT_EQ("forbidden_\\:\"|?*chars", Platform::SanitiseFilename("forbidden/\\:\"|?*chars")); #else - ASSERT_EQ("normal-filename.png", platform_sanitise_filename("normal-filename.png")); - ASSERT_EQ("utf🎱", platform_sanitise_filename("utf🎱")); - ASSERT_EQ("forbidden_char", platform_sanitise_filename("forbidden/char")); - ASSERT_EQ("forbidden_______chars", platform_sanitise_filename("forbidden/\\:\"|?*chars")); - ASSERT_EQ("non trimmed", platform_sanitise_filename(" non trimmed ")); + ASSERT_EQ("forbidden_______chars", Platform::SanitiseFilename("forbidden/\\:\"|?*chars")); #endif }