From 4cd75971f0024199de44d5b055d4a0eec9afb502 Mon Sep 17 00:00:00 2001 From: Functionable <40835042+Functionable@users.noreply.github.com> Date: Wed, 7 Jan 2026 18:39:05 +0000 Subject: [PATCH] ISO: Move code to load psf::registry into iso_archive - Multiple places end up needing to retrieve a psf::registry from an is o archive. - Added a safety check along with this --- rpcs3/Loader/ISO.cpp | 13 +++++++++++++ rpcs3/Loader/ISO.h | 4 ++++ rpcs3/rpcs3qt/game_list_frame.cpp | 17 +++-------------- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/rpcs3/Loader/ISO.cpp b/rpcs3/Loader/ISO.cpp index 9804407767..3c3a0a8c20 100644 --- a/rpcs3/Loader/ISO.cpp +++ b/rpcs3/Loader/ISO.cpp @@ -340,6 +340,19 @@ iso_file iso_archive::open(const std::string& path) return iso_file(fs::file(m_path), *retrieve(path)); } +psf::registry iso_archive::open_psf(const std::string& path) +{ + auto* archive_file = retrieve(path); + if (!archive_file) return psf::registry(); + + // HACK: psf does not accept a file_base argument, + // instead we are creating a dummy fs::file and replacing the internal file_base handle with an iso_file + fs::file psf_file(path); + psf_file.reset(std::make_unique(fs::file(m_path), *archive_file)); + + return psf::load_object(psf_file, path); +} + iso_file::iso_file(fs::file&& iso_handle, const iso_fs_node& node) : m_file(std::move(iso_handle)), m_meta(node.metadata), m_pos(0) { diff --git a/rpcs3/Loader/ISO.h b/rpcs3/Loader/ISO.h index f986899db8..55c8b99f16 100644 --- a/rpcs3/Loader/ISO.h +++ b/rpcs3/Loader/ISO.h @@ -1,5 +1,7 @@ #pragma once +#include "Loader/PSF.h" + #include "Utilities/File.h" #include "util/types.hpp" @@ -86,6 +88,8 @@ class iso_archive bool is_file(const std::string& path); iso_file open(const std::string& path); + + psf::registry open_psf(const std::string& path); }; class iso_device : public fs::device_base diff --git a/rpcs3/rpcs3qt/game_list_frame.cpp b/rpcs3/rpcs3qt/game_list_frame.cpp index 6c8dee2a15..34aa4147f2 100644 --- a/rpcs3/rpcs3qt/game_list_frame.cpp +++ b/rpcs3/rpcs3qt/game_list_frame.cpp @@ -523,19 +523,6 @@ void game_list_frame::OnParsingFinished() const auto add_game = [this, localized_title, localized_icon, localized_movie, dev_flash, cat_unknown_localized = localized.category.unknown.toStdString(), cat_unknown = cat::cat_unknown.toStdString(), game_icon_path, _hdd, play_hover_movies = m_play_hover_movies, show_custom_icons = m_show_custom_icons](const std::string& dir_or_elf) { - const auto load_game_psf = [&dir_or_elf](const std::string& sfo_path, const std::unique_ptr& archive) - { - if (!archive) return psf::load_object(sfo_path); - - // HACK: psf does not accept a file_base argument, - // so we are creating a dummy fs:file and replacing the internal file_base handle with an iso_file - // instead. - fs::file psf_file(sfo_path); - psf_file.reset(std::make_unique(fs::file(dir_or_elf), *archive->retrieve(sfo_path))); - - return psf::load_object(psf_file, sfo_path); - }; - std::unique_ptr archive; if (is_file_iso(dir_or_elf)) { @@ -562,7 +549,9 @@ void game_list_frame::OnParsingFinished() const Localized thread_localized; const std::string sfo_dir = !archive ? rpcs3::utils::get_sfo_dir_from_game_path(dir_or_elf) : "PS3_GAME"; - const psf::registry psf = load_game_psf(sfo_dir + "/PARAM.SFO", archive); + const std::string sfo_path = sfo_dir + "/PARAM.SFO"; + + const psf::registry psf = !archive ? psf::load_object(sfo_path) : archive->open_psf(sfo_path); const std::string_view title_id = psf::get_string(psf, "TITLE_ID", ""); if (title_id.empty())