game_list: Split game list scans to multiple functions
Avoids unnecessary rebuilds of control data on every layer of recursion in AddFstEntriesToGameList
This commit is contained in:
parent
8f06a0f898
commit
fdf27bf390
@ -405,6 +405,7 @@ void GameList::RefreshGameDirectory() {
|
|||||||
|
|
||||||
static void GetMetadataFromControlNCA(const std::shared_ptr<FileSys::NCA>& nca,
|
static void GetMetadataFromControlNCA(const std::shared_ptr<FileSys::NCA>& nca,
|
||||||
std::vector<u8>& icon, std::string& name) {
|
std::vector<u8>& icon, std::string& name) {
|
||||||
|
|
||||||
const auto control_dir = FileSys::ExtractRomFS(nca->GetRomFS());
|
const auto control_dir = FileSys::ExtractRomFS(nca->GetRomFS());
|
||||||
if (control_dir == nullptr)
|
if (control_dir == nullptr)
|
||||||
return;
|
return;
|
||||||
@ -425,7 +426,7 @@ static void GetMetadataFromControlNCA(const std::shared_ptr<FileSys::NCA>& nca,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsigned int recursion) {
|
void GameListWorker::AddInstalledTitlesToGameList() {
|
||||||
const auto usernand = Service::FileSystem::GetUserNANDContents();
|
const auto usernand = Service::FileSystem::GetUserNANDContents();
|
||||||
const auto installed_games = usernand->ListEntriesFilter(FileSys::TitleType::Application,
|
const auto installed_games = usernand->ListEntriesFilter(FileSys::TitleType::Application,
|
||||||
FileSys::ContentRecordType::Program);
|
FileSys::ContentRecordType::Program);
|
||||||
@ -456,8 +457,6 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::container::flat_map<u64, std::shared_ptr<FileSys::NCA>> nca_control_map;
|
|
||||||
|
|
||||||
const auto control_data = usernand->ListEntriesFilter(FileSys::TitleType::Application,
|
const auto control_data = usernand->ListEntriesFilter(FileSys::TitleType::Application,
|
||||||
FileSys::ContentRecordType::Control);
|
FileSys::ContentRecordType::Control);
|
||||||
|
|
||||||
@ -466,10 +465,11 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign
|
|||||||
if (nca != nullptr)
|
if (nca != nullptr)
|
||||||
nca_control_map.insert_or_assign(entry.title_id, nca);
|
nca_control_map.insert_or_assign(entry.title_id, nca);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const auto nca_control_callback =
|
void GameListWorker::FillControlMap(const std::string& dir_path) {
|
||||||
[this, &nca_control_map](u64* num_entries_out, const std::string& directory,
|
const auto nca_control_callback = [this](u64* num_entries_out, const std::string& directory,
|
||||||
const std::string& virtual_name) -> bool {
|
const std::string& virtual_name) -> bool {
|
||||||
std::string physical_name = directory + DIR_SEP + virtual_name;
|
std::string physical_name = directory + DIR_SEP + virtual_name;
|
||||||
|
|
||||||
if (stop_processing)
|
if (stop_processing)
|
||||||
@ -487,10 +487,11 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign
|
|||||||
};
|
};
|
||||||
|
|
||||||
FileUtil::ForeachDirectoryEntry(nullptr, dir_path, nca_control_callback);
|
FileUtil::ForeachDirectoryEntry(nullptr, dir_path, nca_control_callback);
|
||||||
|
}
|
||||||
|
|
||||||
const auto callback = [this, recursion,
|
void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsigned int recursion) {
|
||||||
&nca_control_map](u64* num_entries_out, const std::string& directory,
|
const auto callback = [this, recursion](u64* num_entries_out, const std::string& directory,
|
||||||
const std::string& virtual_name) -> bool {
|
const std::string& virtual_name) -> bool {
|
||||||
std::string physical_name = directory + DIR_SEP + virtual_name;
|
std::string physical_name = directory + DIR_SEP + virtual_name;
|
||||||
|
|
||||||
if (stop_processing)
|
if (stop_processing)
|
||||||
@ -547,7 +548,10 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign
|
|||||||
void GameListWorker::run() {
|
void GameListWorker::run() {
|
||||||
stop_processing = false;
|
stop_processing = false;
|
||||||
watch_list.append(dir_path);
|
watch_list.append(dir_path);
|
||||||
|
FillControlMap(dir_path.toStdString());
|
||||||
|
AddInstalledTitlesToGameList();
|
||||||
AddFstEntriesToGameList(dir_path.toStdString(), deep_scan ? 256 : 0);
|
AddFstEntriesToGameList(dir_path.toStdString(), deep_scan ? 256 : 0);
|
||||||
|
nca_control_map.clear();
|
||||||
emit Finished(watch_list);
|
emit Finished(watch_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,10 +163,13 @@ signals:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
FileSys::VirtualFilesystem vfs;
|
FileSys::VirtualFilesystem vfs;
|
||||||
|
std::map<u64, std::shared_ptr<FileSys::NCA>> nca_control_map;
|
||||||
QStringList watch_list;
|
QStringList watch_list;
|
||||||
QString dir_path;
|
QString dir_path;
|
||||||
bool deep_scan;
|
bool deep_scan;
|
||||||
std::atomic_bool stop_processing;
|
std::atomic_bool stop_processing;
|
||||||
|
|
||||||
|
void AddInstalledTitlesToGameList();
|
||||||
|
void FillControlMap(const std::string& dir_path);
|
||||||
void AddFstEntriesToGameList(const std::string& dir_path, unsigned int recursion = 0);
|
void AddFstEntriesToGameList(const std::string& dir_path, unsigned int recursion = 0);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user