diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 3aae20452a..1e994d829a 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -4144,15 +4144,18 @@ u32 Emulator::RemoveGamesFromDir(const std::string& games_dir, const std::vector // List of serials (title id) to remove in "games.yml" file (if any) std::vector serials_to_remove = serials_to_remove_from_yml; // Initialize the list with the specified serials (if any) - // Scan game list to detect the titles belonging to auto-detection "games_dir" folder - for (const auto& [serial, path] : Emu.GetGamesConfig().get_games()) // Loop on game list file + if (!games_dir.empty()) // Skip an empty folder, otherwise we'll remove all games (which is not the intention) { - // NOTE: Used starts_with(games_dir) instead of Emu.IsPathInsideDir(path, games_dir) due the latter would check - // also the existence of the paths - // - if (path.starts_with(games_dir)) // If game path belongs to auto-detection "games_dir" folder, add the serial to the removal list + // Scan game list to detect the titles belonging to auto-detection "games_dir" folder + for (const auto& [serial, path] : Emu.GetGamesConfig().get_games()) // Loop on game list file { - serials_to_remove.push_back(serial); + // NOTE: Used starts_with(games_dir) instead of Emu.IsPathInsideDir(path, games_dir) due the latter would check + // also the existence of the paths + // + if (path.starts_with(games_dir)) // If game path belongs to auto-detection "games_dir" folder, add the serial to the removal list + { + serials_to_remove.push_back(serial); + } } }