mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-22 04:25:19 +00:00
Optimize AddGamesFromDir a bit
This commit is contained in:
parent
76a36f45bf
commit
a1741f21cc
2 changed files with 12 additions and 23 deletions
|
@ -1572,7 +1572,13 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool
|
|||
fs::pending_file temp(fs::get_config_dir() + "/games.yml");
|
||||
|
||||
// Do not update games.yml when TITLE_ID is empty
|
||||
return temp.file && temp.file.write(out.c_str(), out.size()), temp.commit();
|
||||
if (temp.file && temp.file.write(out.c_str(), out.size()), temp.commit())
|
||||
{
|
||||
m_games_yml_invalidated = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
// Check /dev_bdvd/
|
||||
|
@ -3149,27 +3155,14 @@ void Emulator::AddGamesFromDir(const std::string& path)
|
|||
if (!IsStopped())
|
||||
return;
|
||||
|
||||
const std::string games_yml = fs::get_cache_dir() + "/games.yml";
|
||||
|
||||
std::string content_before, content_after;
|
||||
|
||||
if (fs::file fd{games_yml})
|
||||
{
|
||||
content_before = fd.to_string();
|
||||
}
|
||||
m_games_yml_invalidated = false;
|
||||
|
||||
// search dropped path first or else the direct parent to an elf is wrongly skipped
|
||||
if (const auto error = BootGame(path, "", false, true); error == game_boot_result::no_errors)
|
||||
{
|
||||
if (fs::file fd{games_yml, fs::read + fs::isfile})
|
||||
{
|
||||
content_after = fd.to_string();
|
||||
}
|
||||
|
||||
if (content_before != content_after)
|
||||
if (std::exchange(m_games_yml_invalidated, false))
|
||||
{
|
||||
sys_log.notice("Registered game directory: %s", path);
|
||||
content_before = content_after;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3185,15 +3178,9 @@ void Emulator::AddGamesFromDir(const std::string& path)
|
|||
|
||||
if (const auto error = BootGame(dir_path, "", false, true); error == game_boot_result::no_errors)
|
||||
{
|
||||
if (fs::file fd{games_yml, fs::read + fs::isfile})
|
||||
{
|
||||
content_after = fd.to_string();
|
||||
}
|
||||
|
||||
if (content_before != content_after)
|
||||
if (std::exchange(m_games_yml_invalidated, false))
|
||||
{
|
||||
sys_log.notice("Registered game directory: %s", dir_path);
|
||||
content_before = content_after;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,6 +119,8 @@ class Emulator final
|
|||
atomic_t<u64> m_pause_amend_time{0}; // increased when resumed
|
||||
atomic_t<u64> m_stop_ctr{0}; // Increments when emulation is stopped
|
||||
|
||||
bool m_games_yml_invalidated = false;
|
||||
|
||||
video_renderer m_default_renderer;
|
||||
std::string m_default_graphics_adapter;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue