Skip to content

Commit e04198e

Browse files
committed
iso: Improve movie and audio path checks
Also reduce need for checking iso files for non-iso games
1 parent 4048b7a commit e04198e

6 files changed

Lines changed: 38 additions & 27 deletions

File tree

rpcs3/Emu/GameInfo.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,9 @@ struct GameInfo
2727
u64 size_on_disk = umax;
2828

2929
bool has_custom_icon = false;
30+
31+
bool is_iso_file = false;
3032
bool icon_in_archive = false;
33+
bool movie_in_archive = false;
34+
bool audio_in_archive = false;
3135
};

rpcs3/Emu/game_enumeration.h

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <set>
1414
#include <unordered_set>
1515
#include <vector>
16-
#include <mutex>
1716
#include <regex>
1817

1918
LOG_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

5352
private:
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

109108
template <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

345350
template <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
}

rpcs3/rpcs3qt/game_list_context_menu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ void game_list_context_menu::show_single_selection_context_menu(const game_info&
625625
// Check disc game integrity
626626
if (QString::fromStdString(current_game.category) == cat::cat_disc_game)
627627
{
628-
const bool raw_archive = is_iso_file(current_game.path);
628+
const bool raw_archive = current_game.is_iso_file && is_iso_file(current_game.path);
629629
const iso_type_status iso_type = iso_file_decryption::check_type(current_game.path);
630630

631631
// If it's an ISO file (e.g. even a decrypted ISO), always provide the entry on the context menu but disable

rpcs3/rpcs3qt/game_list_grid.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,16 @@ void game_list_grid::populate(
126126
if (play_hover_movies && !game->movie_path.empty())
127127
{
128128
item->set_video_path(game->movie_path);
129-
check_iso |= !fs::exists(game->movie_path);
129+
check_iso |= game->movie_in_archive;
130130
}
131131

132132
if (play_hover_music && !game->audio_path.empty())
133133
{
134134
item->set_audio_path(game->audio_path);
135-
check_iso |= !fs::exists(game->audio_path);
135+
check_iso |= game->audio_in_archive;
136136
}
137137

138-
if (check_iso && is_iso_file(game->path))
138+
if (check_iso && game->is_iso_file && is_iso_file(game->path))
139139
{
140140
item->set_iso_path(game->path);
141141
}

rpcs3/rpcs3qt/game_list_table.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,7 @@ void game_list_table::populate(
283283
// Do not report size of apps inside /dev_flash (it does not make sense to do so)
284284
game->size_on_disk = 0;
285285
}
286-
else if (is_iso_file(game->path, &game->size_on_disk)) // If iso file, game->size_on_disk is also set
287-
{
288-
}
289-
else
286+
else if (!game->is_iso_file || !is_iso_file(game->path, &game->size_on_disk)) // If iso file, game->size_on_disk is also set
290287
{
291288
game->size_on_disk = fs::get_dir_size(game->path, 1, cancel.get());
292289
}
@@ -304,16 +301,16 @@ void game_list_table::populate(
304301
if (play_hover_movies && !game->movie_path.empty())
305302
{
306303
icon_item->set_video_path(game->movie_path);
307-
check_iso |= !fs::exists(game->movie_path);
304+
check_iso |= game->movie_in_archive;
308305
}
309306

310307
if (play_hover_music && !game->audio_path.empty())
311308
{
312309
icon_item->set_audio_path(game->audio_path);
313-
check_iso |= !fs::exists(game->audio_path);
310+
check_iso |= game->audio_in_archive;
314311
}
315312

316-
if (check_iso && is_iso_file(game->path))
313+
if (check_iso && game->is_iso_file && is_iso_file(game->path))
317314
{
318315
icon_item->set_iso_path(game->path);
319316
}

rpcs3/rpcs3qt/shortcut_utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ namespace gui::utils
477477
if (!game || locations.empty()) return false;
478478

479479
const std::string dev_flash = g_cfg_vfs.get_dev_flash();
480-
const bool is_archive = is_iso_file(game->path);
480+
const bool is_archive = game->is_iso_file && is_iso_file(game->path);
481481
std::shared_ptr<iso_archive> archive;
482482

483483
const auto file_exists = [&archive](const std::string& path)

0 commit comments

Comments
 (0)