From 2af7b58ce44a3b2bf2764c4f913e87aa5a2e2023 Mon Sep 17 00:00:00 2001 From: Antonino Di Guardo <64427768+digant73@users.noreply.github.com> Date: Sun, 21 Jun 2026 19:38:03 +0200 Subject: [PATCH] fix double path delimiter (#18923) A cosmetic fix. It removes a double delimiter at the end of a path in `games.yml` when using `VFS games` path. --- Utilities/StrFmt.cpp | 7 +++++++ rpcs3/Emu/System.cpp | 14 ++++++++++---- rpcs3/Emu/System.h | 6 +++--- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Utilities/StrFmt.cpp b/Utilities/StrFmt.cpp index d68ef51cb5..cd0fe2b5dc 100644 --- a/Utilities/StrFmt.cpp +++ b/Utilities/StrFmt.cpp @@ -921,6 +921,13 @@ std::string_view fmt::trim_front_sv(std::string_view source, std::string_view va void fmt::trim_back(std::string& source, std::string_view values) { const usz index = source.find_last_not_of(values); + + if (index == source.npos) + { + source.clear(); + return; + } + source.resize(index + 1); } diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 12013c7965..60e6cb3fca 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -4276,10 +4276,12 @@ std::set Emulator::GetGameDirs() const return dirs; } -u32 Emulator::AddGamesFromDir(const std::string& path) +u32 Emulator::AddGamesFromDir(std::string path) { u32 games_added = 0; + fmt::trim_back(path, fs::delim); + m_games_config.set_save_on_dirty(false); // search for a game on the provided path first (game on ISO file or on folder type) @@ -4313,7 +4315,7 @@ u32 Emulator::AddGamesFromDir(const std::string& path) continue; } - const std::string dir_path = path + '/' + dir_entry.name; + const std::string dir_path = path + "/" + dir_entry.name; if (!dir_entry.is_directory && !is_iso_file(dir_path)) { @@ -4349,8 +4351,10 @@ u32 Emulator::AddGamesFromDir(const std::string& path) return games_added; } -game_boot_result Emulator::AddGame(const std::string& path) +game_boot_result Emulator::AddGame(std::string path) { + fmt::trim_back(path, fs::delim); + // Handle files directly if (!fs::is_dir(path) || fs::get_optical_raw_device(path)) { @@ -4396,8 +4400,10 @@ game_boot_result Emulator::AddGame(const std::string& path) return result; } -game_boot_result Emulator::AddGameToYml(const std::string& path) +game_boot_result Emulator::AddGameToYml(std::string path) { + fmt::trim_back(path, fs::delim); + // Detect boot location const auto is_invalid_path = [this](std::string_view path, std::string_view dir) -> game_boot_result { diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index e0efebc1d8..6f89967d79 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -489,9 +489,9 @@ public: void ConfigurePPUCache() const; std::set GetGameDirs() const; - u32 AddGamesFromDir(const std::string& path); - game_boot_result AddGame(const std::string& path); - game_boot_result AddGameToYml(const std::string& path); + u32 AddGamesFromDir(std::string path); + game_boot_result AddGame(std::string path); + game_boot_result AddGameToYml(std::string path); u32 RemoveGamesFromDir(const std::string& games_dir, const std::vector& serials_to_remove_from_yml = {}, bool save_on_disk = true); u32 RemoveGames(const std::vector& title_id_list, bool save_on_disk = true); game_boot_result RemoveGameFromYml(const std::string& title_id);