From 6ba0a3bd49bdb686a0ad7c240db3d47419a6429d Mon Sep 17 00:00:00 2001 From: Hielke Morsink Date: Sun, 27 Feb 2022 22:23:35 +0100 Subject: [PATCH] Use u8 strings when dealing with file paths --- src/openrct2-ui/interface/Theme.cpp | 4 +- src/openrct2-ui/windows/InstallTrack.cpp | 2 +- src/openrct2/Context.cpp | 6 +- src/openrct2/Game.cpp | 8 +- src/openrct2/PlatformEnvironment.cpp | 121 +++++++++--------- src/openrct2/cmdline/RootCommands.cpp | 2 +- src/openrct2/config/Config.cpp | 12 +- src/openrct2/drawing/Drawing.Sprite.cpp | 4 +- .../localisation/LocalisationService.cpp | 2 +- src/openrct2/network/NetworkBase.cpp | 6 +- src/openrct2/network/ServerList.cpp | 2 +- src/openrct2/object/ImageTable.cpp | 2 +- src/openrct2/object/ObjectRepository.cpp | 2 +- src/openrct2/platform/Platform.Linux.cpp | 10 +- src/openrct2/platform/Platform.Win32.cpp | 8 +- src/openrct2/platform/Shared.cpp | 2 +- src/openrct2/scenario/Scenario.cpp | 2 +- src/openrct2/scenario/ScenarioRepository.cpp | 4 +- src/openrct2/scripting/ScriptEngine.cpp | 2 +- src/openrct2/title/TitleSequence.cpp | 6 +- src/openrct2/title/TitleSequenceManager.cpp | 4 +- test/tests/CLITests.cpp | 10 +- test/tests/CryptTests.cpp | 4 +- test/tests/ImageImporterTests.cpp | 2 +- test/tests/ReplayTests.cpp | 4 +- test/tests/RideRatings.cpp | 2 +- test/tests/TestData.cpp | 2 +- 27 files changed, 115 insertions(+), 120 deletions(-) diff --git a/src/openrct2-ui/interface/Theme.cpp b/src/openrct2-ui/interface/Theme.cpp index f9d8e62f8f..f0a9905b86 100644 --- a/src/openrct2-ui/interface/Theme.cpp +++ b/src/openrct2-ui/interface/Theme.cpp @@ -531,7 +531,7 @@ namespace ThemeManager NumPredefinedThemes++; } - auto themesPattern = Path::Combine(GetThemePath(), "*.json"); + auto themesPattern = Path::Combine(GetThemePath(), u8"*.json"); auto scanner = Path::ScanDirectory(themesPattern, true); while (scanner->Next()) { @@ -633,7 +633,7 @@ namespace ThemeManager std::string GetThemeFileName(const std::string& name) { auto themeDirectory = GetThemePath(); - auto themePath = Path::Combine(themeDirectory, name + ".json"); + auto themePath = Path::Combine(themeDirectory, name + u8".json"); return themePath; } diff --git a/src/openrct2-ui/windows/InstallTrack.cpp b/src/openrct2-ui/windows/InstallTrack.cpp index bfa042c8a9..47305a54a5 100644 --- a/src/openrct2-ui/windows/InstallTrack.cpp +++ b/src/openrct2-ui/windows/InstallTrack.cpp @@ -439,7 +439,7 @@ static void WindowInstallTrackDesign(rct_window* w) return; } - destPath = Path::Combine(destPath, _trackName + ".td6"); + destPath = Path::Combine(destPath, _trackName + u8".td6"); if (File::Exists(destPath)) { diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index 0fae96f0e3..42eb803d9c 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -333,18 +333,18 @@ namespace OpenRCT2 if (!(_env->GetDirectoryPath(DIRBASE::RCT1).empty())) { auto dataPath = _env->GetDirectoryPath(DIRBASE::RCT1, DIRID::DATA); - result = Path::ResolveCasing(Path::Combine(dataPath, "css17.dat")); + result = Path::ResolveCasing(Path::Combine(dataPath, u8"css17.dat")); if (!File::Exists(result)) { auto rct1Path = _env->GetDirectoryPath(DIRBASE::RCT1); - result = Path::ResolveCasing(Path::Combine(rct1Path, "RCTdeluxe_install", "Data", "css17.dat")); + result = Path::ResolveCasing(Path::Combine(rct1Path, u8"RCTdeluxe_install", u8"Data", u8"css17.dat")); } } else { auto dataPath = _env->GetDirectoryPath(DIRBASE::RCT2, DIRID::DATA); - result = Path::ResolveCasing(Path::Combine(dataPath, "css50.dat")); + result = Path::ResolveCasing(Path::Combine(dataPath, u8"css50.dat")); } } else if (pathId >= 0 && pathId < PATH_ID_END) diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index 5880f2aae1..e8cb7deae7 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -560,7 +560,7 @@ void save_game_cmd(u8string_view name /* = {} */) else { auto env = GetContext()->GetPlatformEnvironment(); - auto savePath = Path::Combine(env->GetDirectoryPath(DIRBASE::USER, DIRID::SAVE), u8string(name) + ".park"); + auto savePath = Path::Combine(env->GetDirectoryPath(DIRBASE::USER, DIRID::SAVE), u8string(name) + u8".park"); save_game_with_name(savePath); } } @@ -686,11 +686,11 @@ void game_autosave() limit_autosave_count(autosavesToKeep - 1, (gScreenFlags & SCREEN_FLAGS_EDITOR)); auto env = GetContext()->GetPlatformEnvironment(); - auto autosaveDir = Path::Combine(env->GetDirectoryPath(DIRBASE::USER, subDirectory), "autosave"); + auto autosaveDir = Path::Combine(env->GetDirectoryPath(DIRBASE::USER, subDirectory), u8"autosave"); Platform::EnsureDirectoryExists(autosaveDir.c_str()); auto path = Path::Combine(autosaveDir, timeName); - auto backupFileName = u8string("autosave") + fileExtension + ".bak"; + auto backupFileName = u8string(u8"autosave") + fileExtension + u8".bak"; auto backupPath = Path::Combine(autosaveDir, backupFileName); if (File::Exists(path)) @@ -764,7 +764,7 @@ void game_load_or_quit_no_save_prompt() void start_silent_record() { std::string name = Path::Combine( - OpenRCT2::GetContext()->GetPlatformEnvironment()->GetDirectoryPath(OpenRCT2::DIRBASE::USER), "debug_replay.parkrep"); + OpenRCT2::GetContext()->GetPlatformEnvironment()->GetDirectoryPath(OpenRCT2::DIRBASE::USER), u8"debug_replay.parkrep"); auto* replayManager = OpenRCT2::GetContext()->GetReplayManager(); if (replayManager->StartRecording(name, OpenRCT2::k_MaxReplayTicks, OpenRCT2::IReplayManager::RecordType::SILENT)) { diff --git a/src/openrct2/PlatformEnvironment.cpp b/src/openrct2/PlatformEnvironment.cpp index 527b1c148f..282b42272d 100644 --- a/src/openrct2/PlatformEnvironment.cpp +++ b/src/openrct2/PlatformEnvironment.cpp @@ -39,7 +39,7 @@ public: u8string GetDirectoryPath(DIRBASE base, DIRID did) const override { auto basePath = GetDirectoryPath(base); - const utf8* directoryName; + u8string_view directoryName; switch (base) { default: @@ -72,8 +72,8 @@ public: private: static const char* DirectoryNamesRCT2[]; - static const char* DirectoryNamesOpenRCT2[]; - static const char* FileNames[]; + static const u8string DirectoryNamesOpenRCT2[]; + static const u8string FileNames[]; static DIRBASE GetDefaultBaseDirectory(PATHID pathid) { @@ -109,12 +109,12 @@ std::unique_ptr OpenRCT2::CreatePlatformEnvironment(DIRBAS return std::make_unique(basePaths); } -static std::string GetOpenRCT2DirectoryName() +static u8string GetOpenRCT2DirectoryName() { #if defined(__ANDROID__) - return "openrct2-user"; + return u8"openrct2-user"; #else - return "OpenRCT2"; + return u8"OpenRCT2"; #endif } @@ -187,65 +187,60 @@ std::unique_ptr OpenRCT2::CreatePlatformEnvironment() return env; } -// clang-format off -const char * PlatformEnvironment::DirectoryNamesRCT2[] = -{ - "Data", // DATA - "Landscapes", // LANDSCAPE - nullptr, // LANGUAGE - nullptr, // LOG_CHAT - nullptr, // LOG_SERVER - nullptr, // NETWORK_KEY - "ObjData", // OBJECT - nullptr, // PLUGIN - "Saved Games", // SAVE - "Scenarios", // SCENARIO - nullptr, // SCREENSHOT - nullptr, // SEQUENCE - nullptr, // SHADER - nullptr, // THEME - "Tracks", // TRACK +const char* PlatformEnvironment::DirectoryNamesRCT2[] = { + "Data", // DATA + "Landscapes", // LANDSCAPE + nullptr, // LANGUAGE + nullptr, // LOG_CHAT + nullptr, // LOG_SERVER + nullptr, // NETWORK_KEY + "ObjData", // OBJECT + nullptr, // PLUGIN + "Saved Games", // SAVE + "Scenarios", // SCENARIO + nullptr, // SCREENSHOT + nullptr, // SEQUENCE + nullptr, // SHADER + nullptr, // THEME + "Tracks", // TRACK }; -const char * PlatformEnvironment::DirectoryNamesOpenRCT2[] = -{ - "data", // DATA - "landscape", // LANDSCAPE - "language", // LANGUAGE - "chatlogs", // LOG_CHAT - "serverlogs", // LOG_SERVER - "keys", // NETWORK_KEY - "object", // OBJECT - "plugin", // PLUGIN - "save", // SAVE - "scenario", // SCENARIO - "screenshot", // SCREENSHOT - "sequence", // SEQUENCE - "shaders", // SHADER - "themes", // THEME - "track", // TRACK - "heightmap", // HEIGHTMAP - "replay", // REPLAY - "desyncs", // DESYNCS - "crash", // CRASH +const u8string PlatformEnvironment::DirectoryNamesOpenRCT2[] = { + u8"data", // DATA + u8"landscape", // LANDSCAPE + u8"language", // LANGUAGE + u8"chatlogs", // LOG_CHAT + u8"serverlogs", // LOG_SERVER + u8"keys", // NETWORK_KEY + u8"object", // OBJECT + u8"plugin", // PLUGIN + u8"save", // SAVE + u8"scenario", // SCENARIO + u8"screenshot", // SCREENSHOT + u8"sequence", // SEQUENCE + u8"shaders", // SHADER + u8"themes", // THEME + u8"track", // TRACK + u8"heightmap", // HEIGHTMAP + u8"replay", // REPLAY + u8"desyncs", // DESYNCS + u8"crash", // CRASH }; -const char * PlatformEnvironment::FileNames[] = -{ - "config.ini", // CONFIG - "hotkeys.dat", // CONFIG_SHORTCUTS_LEGACY - "shortcuts.json", // CONFIG_SHORTCUTS - "objects.idx", // CACHE_OBJECTS - "tracks.idx", // CACHE_TRACKS - "scenarios.idx", // CACHE_SCENARIOS - "Data" PATH_SEPARATOR "mp.dat", // MP_DAT - "groups.json", // NETWORK_GROUPS - "servers.cfg", // NETWORK_SERVERS - "users.json", // NETWORK_USERS - "highscores.dat", // SCORES - "scores.dat", // SCORES (LEGACY) - "Saved Games" PATH_SEPARATOR "scores.dat", // SCORES (RCT2) - "changelog.txt", // CHANGELOG - "plugin.store.json" // PLUGIN_STORE +const u8string PlatformEnvironment::FileNames[] = { + u8"config.ini", // CONFIG + u8"hotkeys.dat", // CONFIG_SHORTCUTS_LEGACY + u8"shortcuts.json", // CONFIG_SHORTCUTS + u8"objects.idx", // CACHE_OBJECTS + u8"tracks.idx", // CACHE_TRACKS + u8"scenarios.idx", // CACHE_SCENARIOS + u8"Data" PATH_SEPARATOR "mp.dat", // MP_DAT + u8"groups.json", // NETWORK_GROUPS + u8"servers.cfg", // NETWORK_SERVERS + u8"users.json", // NETWORK_USERS + u8"highscores.dat", // SCORES + u8"scores.dat", // SCORES (LEGACY) + u8"Saved Games" PATH_SEPARATOR "scores.dat", // SCORES (RCT2) + u8"changelog.txt", // CHANGELOG + u8"plugin.store.json" // PLUGIN_STORE }; -// clang-format on diff --git a/src/openrct2/cmdline/RootCommands.cpp b/src/openrct2/cmdline/RootCommands.cpp index c1e8d2276a..46cc4d9b17 100644 --- a/src/openrct2/cmdline/RootCommands.cpp +++ b/src/openrct2/cmdline/RootCommands.cpp @@ -356,7 +356,7 @@ static exitcode_t HandleCommandSetRCT2(CommandLineArgEnumerator* enumerator) // Check if g1.dat exists (naive but good check) Console::WriteLine("Checking g1.dat..."); - auto pathG1Check = Path::Combine(path, "Data", "g1.dat"); + auto pathG1Check = Path::Combine(path, u8"Data", u8"g1.dat"); if (!File::Exists(pathG1Check)) { Console::Error::WriteLine("RCT2 path not valid."); diff --git a/src/openrct2/config/Config.cpp b/src/openrct2/config/Config.cpp index b801be7fa3..0b509b91d9 100644 --- a/src/openrct2/config/Config.cpp +++ b/src/openrct2/config/Config.cpp @@ -793,7 +793,7 @@ void config_release() u8string config_get_default_path() { auto env = GetContext()->GetPlatformEnvironment(); - return Path::Combine(env->GetDirectoryPath(DIRBASE::USER), "config.ini"); + return Path::Combine(env->GetDirectoryPath(DIRBASE::USER), u8"config.ini"); } bool config_save_default() @@ -892,7 +892,7 @@ bool config_find_or_browse_install_directory() uiContext->ShowMessageBox(language_get_string(STR_NOT_THE_GOG_INSTALLER)); } - installPath = Path::Combine(dest, "app"); + installPath = Path::Combine(dest, u8"app"); } if (installPath.empty()) { @@ -926,8 +926,8 @@ bool config_find_or_browse_install_directory() std::string FindCsg1datAtLocation(u8string_view path) { - auto checkPath1 = Path::Combine(path, "Data", "CSG1.DAT"); - auto checkPath2 = Path::Combine(path, "Data", "CSG1.1"); + auto checkPath1 = Path::Combine(path, u8"Data", u8"CSG1.DAT"); + auto checkPath2 = Path::Combine(path, u8"Data", u8"CSG1.1"); // Since Linux is case sensitive (and macOS sometimes too), make sure we handle case properly. std::string path1result = Path::ResolveCasing(checkPath1); @@ -948,12 +948,12 @@ bool Csg1datPresentAtLocation(u8string_view path) u8string FindCsg1idatAtLocation(u8string_view path) { - auto result1 = Path::ResolveCasing(Path::Combine(path, "Data", "CSG1I.DAT")); + auto result1 = Path::ResolveCasing(Path::Combine(path, u8"Data", u8"CSG1I.DAT")); if (!result1.empty()) { return result1; } - auto result2 = Path::ResolveCasing(Path::Combine(path, "RCTdeluxe_install", "Data", "CSG1I.DAT")); + auto result2 = Path::ResolveCasing(Path::Combine(path, u8"RCTdeluxe_install", u8"Data", u8"CSG1I.DAT")); return result2; } diff --git a/src/openrct2/drawing/Drawing.Sprite.cpp b/src/openrct2/drawing/Drawing.Sprite.cpp index 3be02bb489..2aa8091295 100644 --- a/src/openrct2/drawing/Drawing.Sprite.cpp +++ b/src/openrct2/drawing/Drawing.Sprite.cpp @@ -198,7 +198,7 @@ bool gfx_load_g1(const IPlatformEnvironment& env) log_verbose("gfx_load_g1(...)"); try { - auto path = Path::Combine(env.GetDirectoryPath(DIRBASE::RCT2, DIRID::DATA), "g1.dat"); + auto path = Path::Combine(env.GetDirectoryPath(DIRBASE::RCT2, DIRID::DATA), u8"g1.dat"); auto fs = FileStream(path, FILE_MODE_OPEN); _g1.header = fs.ReadValue(); @@ -267,7 +267,7 @@ bool gfx_load_g2() auto env = GetContext()->GetPlatformEnvironment(); - std::string path = Path::Combine(env->GetDirectoryPath(DIRBASE::OPENRCT2), "g2.dat"); + std::string path = Path::Combine(env->GetDirectoryPath(DIRBASE::OPENRCT2), u8"g2.dat"); try { diff --git a/src/openrct2/localisation/LocalisationService.cpp b/src/openrct2/localisation/LocalisationService.cpp index 4b3949b55a..9b43783803 100644 --- a/src/openrct2/localisation/LocalisationService.cpp +++ b/src/openrct2/localisation/LocalisationService.cpp @@ -80,7 +80,7 @@ std::string LocalisationService::GetLanguagePath(uint32_t languageId) const { auto locale = std::string(LanguagesDescriptors[languageId].locale); auto languageDirectory = _env->GetDirectoryPath(DIRBASE::OPENRCT2, DIRID::LANGUAGE); - auto languagePath = Path::Combine(languageDirectory, locale + ".txt"); + auto languagePath = Path::Combine(languageDirectory, locale + u8".txt"); return languagePath; } diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index f49613df8b..bddce90ea4 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -3869,17 +3869,17 @@ void network_append_server_log(const utf8* text) static u8string network_get_keys_directory() { auto env = GetContext()->GetPlatformEnvironment(); - return Path::Combine(env->GetDirectoryPath(DIRBASE::USER), "keys"); + return Path::Combine(env->GetDirectoryPath(DIRBASE::USER), u8"keys"); } static u8string network_get_private_key_path(u8string_view playerName) { - return Path::Combine(network_get_keys_directory(), u8string(playerName) + ".privkey"); + return Path::Combine(network_get_keys_directory(), u8string(playerName) + u8".privkey"); } static u8string network_get_public_key_path(u8string_view playerName, u8string_view hash) { - const auto filename = u8string(playerName) + "-" + u8string(hash) + ".pubkey"; + const auto filename = u8string(playerName) + u8"-" + u8string(hash) + u8".pubkey"; return Path::Combine(network_get_keys_directory(), filename); } diff --git a/src/openrct2/network/ServerList.cpp b/src/openrct2/network/ServerList.cpp index 5bc07ef011..fc5de05871 100644 --- a/src/openrct2/network/ServerList.cpp +++ b/src/openrct2/network/ServerList.cpp @@ -215,7 +215,7 @@ bool ServerList::WriteFavourites(const std::vector& entries) co log_verbose("server_list_write(%d, 0x%p)", entries.size(), entries.data()); auto env = GetContext()->GetPlatformEnvironment(); - auto path = Path::Combine(env->GetDirectoryPath(DIRBASE::USER), "servers.cfg"); + auto path = Path::Combine(env->GetDirectoryPath(DIRBASE::USER), u8"servers.cfg"); try { diff --git a/src/openrct2/object/ImageTable.cpp b/src/openrct2/object/ImageTable.cpp index 984baa7d1a..db78511872 100644 --- a/src/openrct2/object/ImageTable.cpp +++ b/src/openrct2/object/ImageTable.cpp @@ -325,7 +325,7 @@ std::string ImageTable::FindLegacyObject(const std::string& name) if (!File::Exists(objectPath)) { // Search recursively for any file with the target name (case insensitive) - auto filter = Path::Combine(objectsPath, "*.dat;*.pob"); + auto filter = Path::Combine(objectsPath, u8"*.dat;*.pob"); auto scanner = Path::ScanDirectory(filter, true); while (scanner->Next()) { diff --git a/src/openrct2/object/ObjectRepository.cpp b/src/openrct2/object/ObjectRepository.cpp index 30a62b725c..20ec336949 100644 --- a/src/openrct2/object/ObjectRepository.cpp +++ b/src/openrct2/object/ObjectRepository.cpp @@ -585,7 +585,7 @@ private: // Find a unique file name auto fileName = GetFileNameForNewObject(generation, name); - auto extension = (generation == ObjectGeneration::DAT ? ".DAT" : ".parkobj"); + auto extension = (generation == ObjectGeneration::DAT ? u8".DAT" : u8".parkobj"); auto fullPath = Path::Combine(userObjPath, fileName + extension); auto counter = 1U; while (File::Exists(fullPath)) diff --git a/src/openrct2/platform/Platform.Linux.cpp b/src/openrct2/platform/Platform.Linux.cpp index deb634480a..1b85e367a6 100644 --- a/src/openrct2/platform/Platform.Linux.cpp +++ b/src/openrct2/platform/Platform.Linux.cpp @@ -47,7 +47,7 @@ namespace Platform if (path.empty()) { auto home = GetFolderPath(SPECIAL_FOLDER::USER_HOME); - path = Path::Combine(home, ".config"); + path = Path::Combine(home, u8".config"); } return path; } @@ -279,13 +279,13 @@ namespace Platform const char* steamRoot = getenv("STEAMROOT"); if (steamRoot != nullptr) { - return Path::Combine(steamRoot, "ubuntu12_32/steamapps/content"); + return Path::Combine(steamRoot, u8"ubuntu12_32/steamapps/content"); } const char* localSharePath = getenv("XDG_DATA_HOME"); if (localSharePath != nullptr) { - auto steamPath = Path::Combine(localSharePath, "Steam/ubuntu12_32/steamapps/content"); + auto steamPath = Path::Combine(localSharePath, u8"Steam/ubuntu12_32/steamapps/content"); if (Path::DirectoryExists(steamPath)) { return steamPath; @@ -298,13 +298,13 @@ namespace Platform return {}; } - auto steamPath = Path::Combine(homeDir, ".local/share/Steam/ubuntu12_32/steamapps/content"); + auto steamPath = Path::Combine(homeDir, u8".local/share/Steam/ubuntu12_32/steamapps/content"); if (Path::DirectoryExists(steamPath)) { return steamPath; } - steamPath = Path::Combine(homeDir, ".steam/steam/ubuntu12_32/steamapps/content"); + steamPath = Path::Combine(homeDir, u8".steam/steam/ubuntu12_32/steamapps/content"); if (Path::DirectoryExists(steamPath)) { return steamPath; diff --git a/src/openrct2/platform/Platform.Win32.cpp b/src/openrct2/platform/Platform.Win32.cpp index f9bcb4d0e8..8e8371af50 100644 --- a/src/openrct2/platform/Platform.Win32.cpp +++ b/src/openrct2/platform/Platform.Win32.cpp @@ -171,7 +171,7 @@ namespace Platform # endif if (!path.empty()) { - path = Path::Combine(path, "DiscordGames\\RollerCoaster Tycoon 2 Triple Thrill Pack\\content\\Game"); + path = Path::Combine(path, u8"DiscordGames\\RollerCoaster Tycoon 2 Triple Thrill Pack\\content\\Game"); } return path; } @@ -197,7 +197,7 @@ namespace Platform else { auto exeDirectory = GetCurrentExecutableDirectory(); - path = Path::Combine(exeDirectory, "data"); + path = Path::Combine(exeDirectory, u8"data"); } return path; } @@ -862,7 +862,7 @@ namespace Platform if (result == ERROR_SUCCESS) { auto utf8SteamPath = String::ToUtf8(wSteamPath); - outPath = Path::Combine(utf8SteamPath, "steamapps", "common"); + outPath = Path::Combine(utf8SteamPath, u8"steamapps", u8"common"); } free(wSteamPath); RegCloseKey(hKey); @@ -885,7 +885,7 @@ namespace Platform return {}; # else log_warning("Compatibility hack: falling back to C:\\Windows\\Fonts"); - return Path::Combine("C:\\Windows\\Fonts\\", font.filename); + return Path::Combine(u8"C:\\Windows\\Fonts\\", font.filename); # endif } diff --git a/src/openrct2/platform/Shared.cpp b/src/openrct2/platform/Shared.cpp index ebb3c9ed18..3bb9a2d216 100644 --- a/src/openrct2/platform/Shared.cpp +++ b/src/openrct2/platform/Shared.cpp @@ -90,7 +90,7 @@ namespace Platform bool OriginalGameDataExists(std::string_view path) { - std::string combinedPath = Path::ResolveCasing(Path::Combine(path, "Data", "g1.dat")); + std::string combinedPath = Path::ResolveCasing(Path::Combine(path, u8"Data", u8"g1.dat")); return File::Exists(combinedPath); } diff --git a/src/openrct2/scenario/Scenario.cpp b/src/openrct2/scenario/Scenario.cpp index c3259fe1e5..94308baa67 100644 --- a/src/openrct2/scenario/Scenario.cpp +++ b/src/openrct2/scenario/Scenario.cpp @@ -137,7 +137,7 @@ void scenario_begin() // Set the last saved game path auto env = GetContext()->GetPlatformEnvironment(); auto savePath = env->GetDirectoryPath(DIRBASE::USER, DIRID::SAVE); - gScenarioSavePath = Path::Combine(savePath, park.Name + ".park"); + gScenarioSavePath = Path::Combine(savePath, park.Name + u8".park"); gCurrentExpenditure = 0; gCurrentProfit = 0; diff --git a/src/openrct2/scenario/ScenarioRepository.cpp b/src/openrct2/scenario/ScenarioRepository.cpp index 54dd575e06..ed6ef39a09 100644 --- a/src/openrct2/scenario/ScenarioRepository.cpp +++ b/src/openrct2/scenario/ScenarioRepository.cpp @@ -507,14 +507,14 @@ private: { auto mpdatPath = _env->GetFilePath(PATHID::MP_DAT); auto scenarioDirectory = _env->GetDirectoryPath(DIRBASE::USER, DIRID::SCENARIO); - auto expectedSc21Path = Path::Combine(scenarioDirectory, "sc21.sc4"); + auto expectedSc21Path = Path::Combine(scenarioDirectory, u8"sc21.sc4"); auto sc21Path = Path::ResolveCasing(expectedSc21Path); // If the user has a Steam installation. if (!File::Exists(mpdatPath)) { mpdatPath = Path::ResolveCasing( - Path::Combine(_env->GetDirectoryPath(DIRBASE::RCT1), "RCTdeluxe_install", "Data", "mp.dat")); + Path::Combine(_env->GetDirectoryPath(DIRBASE::RCT1), u8"RCTdeluxe_install", "Data", u8"mp.dat")); } if (File::Exists(mpdatPath) && !File::Exists(sc21Path)) diff --git a/src/openrct2/scripting/ScriptEngine.cpp b/src/openrct2/scripting/ScriptEngine.cpp index 5ca156f6c8..c79c711bb5 100644 --- a/src/openrct2/scripting/ScriptEngine.cpp +++ b/src/openrct2/scripting/ScriptEngine.cpp @@ -456,7 +456,7 @@ void ScriptEngine::LoadPlugins() auto base = _env.GetDirectoryPath(DIRBASE::USER, DIRID::PLUGIN); if (Path::DirectoryExists(base)) { - auto pattern = Path::Combine(base, "*.js"); + auto pattern = Path::Combine(base, u8"*.js"); auto scanner = Path::ScanDirectory(pattern, true); while (scanner->Next()) { diff --git a/src/openrct2/title/TitleSequence.cpp b/src/openrct2/title/TitleSequence.cpp index 1eec8440a4..c89497fabd 100644 --- a/src/openrct2/title/TitleSequence.cpp +++ b/src/openrct2/title/TitleSequence.cpp @@ -72,7 +72,7 @@ std::unique_ptr LoadTitleSequence(const std::string& path) } else { - auto scriptPath = Path::Combine(path, "script.txt"); + auto scriptPath = Path::Combine(path, u8"script.txt"); script = ReadScriptFile(scriptPath); if (script.empty()) { @@ -157,7 +157,7 @@ bool TitleSequenceSave(const TitleSequence& seq) } else { - auto scriptPath = Path::Combine(seq.Path, "script.txt"); + auto scriptPath = Path::Combine(seq.Path, u8"script.txt"); File::WriteAllBytes(scriptPath, script.data(), script.size()); } return true; @@ -291,7 +291,7 @@ static std::vector GetSaves(const std::string& directory) { std::vector saves; - auto pattern = Path::Combine(directory, "*.sc6;*.sv6;*.park;*.sv4;*.sc4"); + auto pattern = Path::Combine(directory, u8"*.sc6;*.sv6;*.park;*.sv4;*.sc4"); auto scanner = Path::ScanDirectory(pattern, true); while (scanner->Next()) { diff --git a/src/openrct2/title/TitleSequenceManager.cpp b/src/openrct2/title/TitleSequenceManager.cpp index 9845907dac..f80eaf04ab 100644 --- a/src/openrct2/title/TitleSequenceManager.cpp +++ b/src/openrct2/title/TitleSequenceManager.cpp @@ -209,7 +209,7 @@ namespace TitleSequenceManager static void Scan(const std::string& directory) { - auto pattern = Path::Combine(directory, "script.txt;*.parkseq"); + auto pattern = Path::Combine(directory, u8"script.txt;*.parkseq"); auto fileScanner = Path::ScanDirectory(pattern, true); while (fileScanner->Next()) { @@ -221,7 +221,7 @@ namespace TitleSequenceManager { TitleSequenceManagerItem item{}; - if (String::Equals(Path::GetExtension(scanPath), ".txt", true)) + if (String::Equals(Path::GetExtension(scanPath), u8".txt", true)) { // If we are given a .txt file, set the path to the containing directory item.Path = Path::GetDirectory(scanPath); diff --git a/test/tests/CLITests.cpp b/test/tests/CLITests.cpp index 92be6408f1..fe075b9431 100644 --- a/test/tests/CLITests.cpp +++ b/test/tests/CLITests.cpp @@ -13,27 +13,27 @@ class CommandLineTests : public testing::Test public: static std::string SpriteTestDataPath() { - return Path::Combine(TestData::GetBasePath(), "sprites"); + return Path::Combine(TestData::GetBasePath(), u8"sprites"); } static std::string ManifestFilePath() { - return Path::Combine(SpriteTestDataPath(), "manifest.json"); + return Path::Combine(SpriteTestDataPath(), u8"manifest.json"); } static std::string BadManifestFilePath() { - return Path::Combine(SpriteTestDataPath(), "badManifest.json"); + return Path::Combine(SpriteTestDataPath(), u8"badManifest.json"); } static std::string ExampleSpriteFilePath() { - return Path::Combine(SpriteTestDataPath(), "example.dat"); + return Path::Combine(SpriteTestDataPath(), u8"example.dat"); } static std::string BuildOutputfilePath() { - return Path::Combine(SpriteTestDataPath(), "result.dat"); + return Path::Combine(SpriteTestDataPath(), u8"result.dat"); } static bool CompareSpriteFiles(std::string original, std::string generated) diff --git a/test/tests/CryptTests.cpp b/test/tests/CryptTests.cpp index e2afd9a6ba..7f5af7e864 100644 --- a/test/tests/CryptTests.cpp +++ b/test/tests/CryptTests.cpp @@ -43,12 +43,12 @@ public: std::string GetTestPrivateKeyPath() { - return Path::Combine(TestData::GetBasePath(), "keys", "Player.privkey"); + return Path::Combine(TestData::GetBasePath(), u8"keys", u8"Player.privkey"); } std::string GetTestPublicKeyPath() { - return Path::Combine(TestData::GetBasePath(), "keys", "Player-56f4afb74622a23bd2539ee701fe1b2c13d7e6ba.pubkey"); + return Path::Combine(TestData::GetBasePath(), u8"keys", u8"Player-56f4afb74622a23bd2539ee701fe1b2c13d7e6ba.pubkey"); } }; diff --git a/test/tests/ImageImporterTests.cpp b/test/tests/ImageImporterTests.cpp index 059790ba14..e04b971e74 100644 --- a/test/tests/ImageImporterTests.cpp +++ b/test/tests/ImageImporterTests.cpp @@ -21,7 +21,7 @@ class ImageImporterTests : public testing::Test public: static std::string GetImagePath(const std::string& name) { - return Path::Combine(TestData::GetBasePath(), "images", name.c_str()); + return Path::Combine(TestData::GetBasePath(), u8"images", name.c_str()); } static uint32_t GetHash(void* buffer, size_t bufferLength) diff --git a/test/tests/ReplayTests.cpp b/test/tests/ReplayTests.cpp index 18cadcfddd..9a7b8f274a 100644 --- a/test/tests/ReplayTests.cpp +++ b/test/tests/ReplayTests.cpp @@ -49,8 +49,8 @@ static std::vector GetReplayFiles() { std::vector res; std::string basePath = TestData::GetBasePath(); - std::string replayPath = Path::Combine(basePath, "replays"); - std::string replayPathPattern = Path::Combine(replayPath, "*.parkrep"); + std::string replayPath = Path::Combine(basePath, u8"replays"); + std::string replayPathPattern = Path::Combine(replayPath, u8"*.parkrep"); std::vector files; auto scanner = Path::ScanDirectory(replayPathPattern, true); diff --git a/test/tests/RideRatings.cpp b/test/tests/RideRatings.cpp index ece0c11bf6..70e77a9bcd 100644 --- a/test/tests/RideRatings.cpp +++ b/test/tests/RideRatings.cpp @@ -74,7 +74,7 @@ TEST_F(RideRatings, all) CalculateRatingsForAllRides(); // Load expected ratings - auto expectedDataPath = Path::Combine(TestData::GetBasePath(), "ratings", "bpb.sv6.txt"); + auto expectedDataPath = Path::Combine(TestData::GetBasePath(), u8"ratings", u8"bpb.sv6.txt"); auto expectedRatings = File::ReadAllLines(expectedDataPath); // Check ride ratings diff --git a/test/tests/TestData.cpp b/test/tests/TestData.cpp index 3bc3d3a501..dc81fdce7f 100644 --- a/test/tests/TestData.cpp +++ b/test/tests/TestData.cpp @@ -20,7 +20,7 @@ namespace TestData std::string GetParkPath(std::string name) { - std::string path = Path::Combine(GetBasePath(), "parks", name); + std::string path = Path::Combine(GetBasePath(), u8"parks", name); return path; } } // namespace TestData