1313#include < set>
1414#include < unordered_set>
1515#include < vector>
16- #include < mutex>
1716#include < regex>
1817
1918LOG_CHANNEL (sys_log, " SYS" );
@@ -51,12 +50,12 @@ class game_enumeration
5150 std::vector<game_info_type> take_games () { return std::move (m_games); }
5251
5352private:
54- std::optional<game_info_type> get_game_info (const std::string& dir_or_elf, const std::string& game_dir);
53+ std::optional<game_info_type> get_game_info (const std::string& dir_or_elf, const std::string& game_dir, bool is_iso, bool is_raw );
5554
5655 bool was_canceled () const { return m_canceled_callback && m_canceled_callback (); }
5756
5857 void push_path (const std::string& path, std::vector<std::string>& legit_paths);
59- void add_game (const std::string& path, const std::string& game_dir = " PS3_GAME" );
58+ void add_game (const std::string& path, const std::string& game_dir = " PS3_GAME" , bool is_iso = false , bool is_raw = false );
6059 virtual void add_game_apply_extras ([[maybe_unused]] game_info_type& game) {}
6160 void add_disc_dir (const std::string& path, std::vector<std::string>& legit_paths);
6261
@@ -107,16 +106,18 @@ void game_enumeration<game_info_type>::set_localization(s32 index, std::string&&
107106}
108107
109108template <typename game_info_type>
110- std::optional<game_info_type> game_enumeration<game_info_type>::get_game_info(const std::string& dir_or_elf, const std::string& game_dir)
109+ std::optional<game_info_type> game_enumeration<game_info_type>::get_game_info(const std::string& dir_or_elf, const std::string& game_dir, bool is_iso, bool is_raw )
111110{
111+ game_info_type info{};
112+
112113 std::unique_ptr<iso_archive> archive;
113114 iso_metadata_cache_entry cache_entry{};
114- bool is_raw_device = false ;
115- const bool is_archive = is_iso_file (dir_or_elf, nullptr , &is_raw_device);
115+ bool is_raw_device = is_raw ;
116+ info. is_iso_file = is_iso && is_iso_file (dir_or_elf, nullptr , &is_raw_device);
116117 const bool is_ps3_game = game_dir == " PS3_GAME" ;
117118 std::string iso_cache_key;
118119
119- if (is_archive )
120+ if (info. is_iso_file )
120121 {
121122 iso_cache_key = is_ps3_game ? dir_or_elf : dir_or_elf + " //" + game_dir;
122123 // Only construct iso_archive (which walks the full directory tree) in case of raw device or
@@ -141,7 +142,6 @@ std::optional<game_info_type> game_enumeration<game_info_type>::get_game_info(co
141142 return fs::is_file (path);
142143 };
143144
144- game_info_type info{};
145145 info.path = dir_or_elf;
146146 info.game_dir = is_ps3_game ? " " : game_dir;
147147
@@ -273,14 +273,17 @@ std::optional<game_info_type> game_enumeration<game_info_type>::get_game_info(co
273273 {
274274 // Cache hit — restore previously resolved movie path.
275275 info.movie_path = cache_entry.movie_path ;
276+ info.movie_in_archive = true ;
276277 }
277278 else if (std::string movie_path = sfo_dir + " /" + m_localized_movie; file_exists (movie_path))
278279 {
279280 info.movie_path = std::move (movie_path);
281+ info.movie_in_archive = archive && archive->exists (info.movie_path );
280282 }
281283 else if (std::string movie_path = sfo_dir + " /ICON1.PAM" ; file_exists (movie_path))
282284 {
283285 info.movie_path = std::move (movie_path);
286+ info.movie_in_archive = archive && archive->exists (info.movie_path );
284287 }
285288 }
286289
@@ -290,16 +293,18 @@ std::optional<game_info_type> game_enumeration<game_info_type>::get_game_info(co
290293 {
291294 // Cache hit — restore previously resolved audio path.
292295 info.audio_path = cache_entry.audio_path ;
296+ info.audio_in_archive = true ;
293297 }
294298 else if (std::string audio_path = sfo_dir + " /SND0.AT3" ; file_exists (audio_path))
295299 {
296300 info.audio_path = std::move (audio_path);
301+ info.audio_in_archive = archive && archive->exists (info.audio_path );
297302 }
298303 }
299304
300305 // With the exception of raw device, on cache miss for an ISO, persist the resolved metadata so subsequent
301306 // launches skip iso_archive construction entirely
302- if (archive && is_archive && !is_raw_device)
307+ if (archive && info. is_iso_file && !is_raw_device)
303308 {
304309 fs::stat_t iso_stat{};
305310 if (fs::get_stat (dir_or_elf, iso_stat))
@@ -343,9 +348,9 @@ void game_enumeration<game_info_type>::push_path(const std::string& path, std::v
343348}
344349
345350template <typename game_info_type>
346- void game_enumeration<game_info_type>::add_game(const std::string& path, const std::string& game_dir)
351+ void game_enumeration<game_info_type>::add_game(const std::string& path, const std::string& game_dir, bool is_iso, bool is_raw )
347352{
348- if (std::optional<game_info_type> game = get_game_info (path, game_dir))
353+ if (std::optional<game_info_type> game = get_game_info (path, game_dir, is_iso, is_raw ))
349354 {
350355 add_game_apply_extras (*game);
351356
@@ -430,7 +435,8 @@ void game_enumeration<game_info_type>::parse_entry(const path_entry& entry)
430435
431436 if (entry.is_from_yml )
432437 {
433- if (is_iso_file (entry.path ))
438+ bool is_raw_device = false ;
439+ if (is_iso_file (entry.path , nullptr , &is_raw_device))
434440 {
435441 std::vector<std::string> subdirs;
436442
@@ -439,7 +445,7 @@ void game_enumeration<game_info_type>::parse_entry(const path_entry& entry)
439445 for (const std::string& name : subdirs)
440446 {
441447 if (was_canceled ()) break ;
442- add_game (entry.path , name);
448+ add_game (entry.path , name, true , is_raw_device );
443449 }
444450
445451 return ;
@@ -466,13 +472,13 @@ void game_enumeration<game_info_type>::parse_entry(const path_entry& entry)
466472 if (name == " PS3_GAME" || std::regex_match (name, ps3_gm_regex))
467473 {
468474 subdirs.push_back (name);
469- add_game (entry.path , name);
475+ add_game (entry.path , name, true , is_raw_device );
470476 }
471477 }
472478 if (subdirs.empty ())
473479 {
474- add_game (entry.path );
475480 subdirs.push_back (" PS3_GAME" );
481+ add_game (entry.path , " PS3_GAME" , true , is_raw_device);
476482 }
477483 if (!was_canceled ())
478484 {
@@ -551,10 +557,12 @@ void game_enumeration<game_info_type>::apply_patches()
551557 if (std::string icon_path = other.path + " /" + m_localized_icon; fs::is_file (icon_path))
552558 {
553559 info.icon_path = std::move (icon_path);
560+ info.icon_in_archive = false ;
554561 }
555562 else if (std::string icon_path = other.path + " /ICON0.PNG" ; fs::is_file (icon_path))
556563 {
557564 info.icon_path = std::move (icon_path);
565+ info.icon_in_archive = false ;
558566 }
559567 }
560568
@@ -564,10 +572,12 @@ void game_enumeration<game_info_type>::apply_patches()
564572 if (std::string movie_path = other.path + " /" + m_localized_icon; fs::is_file (movie_path))
565573 {
566574 info.movie_path = std::move (movie_path);
575+ info.movie_in_archive = false ;
567576 }
568577 else if (std::string movie_path = other.path + " /ICON1.PAM" ; fs::is_file (movie_path))
569578 {
570579 info.movie_path = std::move (movie_path);
580+ info.movie_in_archive = false ;
571581 }
572582 }
573583 }
0 commit comments