2018-09-07 13:08:08 -07:00
|
|
|
// Copyright 2018 yuzu emulator team
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <QDir>
|
2019-05-30 19:13:38 -07:00
|
|
|
#include <QFile>
|
2018-09-07 13:08:08 -07:00
|
|
|
#include <QFileInfo>
|
2019-04-23 06:08:38 -07:00
|
|
|
#include <QSettings>
|
2018-09-07 13:08:08 -07:00
|
|
|
|
2021-05-25 16:32:56 -07:00
|
|
|
#include "common/fs/fs.h"
|
|
|
|
#include "common/fs/path_util.h"
|
2019-03-04 09:40:53 -08:00
|
|
|
#include "core/core.h"
|
|
|
|
#include "core/file_sys/card_image.h"
|
2018-09-07 13:08:08 -07:00
|
|
|
#include "core/file_sys/content_archive.h"
|
|
|
|
#include "core/file_sys/control_metadata.h"
|
|
|
|
#include "core/file_sys/mode.h"
|
|
|
|
#include "core/file_sys/nca_metadata.h"
|
|
|
|
#include "core/file_sys/patch_manager.h"
|
|
|
|
#include "core/file_sys/registered_cache.h"
|
2019-03-04 09:40:53 -08:00
|
|
|
#include "core/file_sys/submission_package.h"
|
2018-09-07 13:08:08 -07:00
|
|
|
#include "core/hle/service/filesystem/filesystem.h"
|
|
|
|
#include "core/loader/loader.h"
|
2018-09-09 16:09:37 -07:00
|
|
|
#include "yuzu/compatibility_list.h"
|
2018-09-07 13:08:08 -07:00
|
|
|
#include "yuzu/game_list.h"
|
|
|
|
#include "yuzu/game_list_p.h"
|
|
|
|
#include "yuzu/game_list_worker.h"
|
2019-07-29 13:06:33 -07:00
|
|
|
#include "yuzu/uisettings.h"
|
2018-09-07 13:08:08 -07:00
|
|
|
|
|
|
|
namespace {
|
2019-04-23 06:08:38 -07:00
|
|
|
|
|
|
|
QString GetGameListCachedObject(const std::string& filename, const std::string& ext,
|
|
|
|
const std::function<QString()>& generator) {
|
2019-05-26 14:14:09 -07:00
|
|
|
if (!UISettings::values.cache_game_list || filename == "0000000000000000") {
|
2019-04-23 06:08:38 -07:00
|
|
|
return generator();
|
2019-05-26 14:14:09 -07:00
|
|
|
}
|
2019-04-23 06:08:38 -07:00
|
|
|
|
2021-05-25 16:32:56 -07:00
|
|
|
const auto path =
|
|
|
|
Common::FS::PathToUTF8String(Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) /
|
|
|
|
"game_list" / fmt::format("{}.{}", filename, ext));
|
2019-04-23 06:08:38 -07:00
|
|
|
|
2021-05-25 16:32:56 -07:00
|
|
|
void(Common::FS::CreateParentDirs(path));
|
2019-04-23 06:08:38 -07:00
|
|
|
|
2020-08-15 05:33:16 -07:00
|
|
|
if (!Common::FS::Exists(path)) {
|
2019-04-23 06:08:38 -07:00
|
|
|
const auto str = generator();
|
|
|
|
|
2019-05-30 19:13:38 -07:00
|
|
|
QFile file{QString::fromStdString(path)};
|
|
|
|
if (file.open(QFile::WriteOnly)) {
|
|
|
|
file.write(str.toUtf8());
|
2019-05-26 14:14:09 -07:00
|
|
|
}
|
2019-04-23 06:08:38 -07:00
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2019-05-30 19:13:38 -07:00
|
|
|
QFile file{QString::fromStdString(path)};
|
|
|
|
if (file.open(QFile::ReadOnly)) {
|
|
|
|
return QString::fromUtf8(file.readAll());
|
2019-04-23 06:08:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return generator();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::pair<std::vector<u8>, std::string> GetGameListCachedObject(
|
|
|
|
const std::string& filename, const std::string& ext,
|
|
|
|
const std::function<std::pair<std::vector<u8>, std::string>()>& generator) {
|
2019-05-26 14:14:09 -07:00
|
|
|
if (!UISettings::values.cache_game_list || filename == "0000000000000000") {
|
2019-04-23 06:08:38 -07:00
|
|
|
return generator();
|
2019-05-26 14:14:09 -07:00
|
|
|
}
|
2019-04-23 06:08:38 -07:00
|
|
|
|
2021-05-25 16:32:56 -07:00
|
|
|
const auto game_list_dir =
|
|
|
|
Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) / "game_list";
|
|
|
|
const auto jpeg_name = fmt::format("{}.jpeg", filename);
|
|
|
|
const auto app_name = fmt::format("{}.appname.txt", filename);
|
2019-04-23 06:08:38 -07:00
|
|
|
|
2021-05-25 16:32:56 -07:00
|
|
|
const auto path1 = Common::FS::PathToUTF8String(game_list_dir / jpeg_name);
|
|
|
|
const auto path2 = Common::FS::PathToUTF8String(game_list_dir / app_name);
|
|
|
|
|
|
|
|
void(Common::FS::CreateParentDirs(path1));
|
2019-04-23 06:08:38 -07:00
|
|
|
|
2020-08-15 05:33:16 -07:00
|
|
|
if (!Common::FS::Exists(path1) || !Common::FS::Exists(path2)) {
|
2019-04-23 06:08:38 -07:00
|
|
|
const auto [icon, nacp] = generator();
|
|
|
|
|
2019-05-30 19:13:38 -07:00
|
|
|
QFile file1{QString::fromStdString(path1)};
|
|
|
|
if (!file1.open(QFile::WriteOnly)) {
|
2019-05-26 14:14:09 -07:00
|
|
|
LOG_ERROR(Frontend, "Failed to open cache file.");
|
|
|
|
return generator();
|
|
|
|
}
|
|
|
|
|
2019-05-30 19:13:38 -07:00
|
|
|
if (!file1.resize(icon.size())) {
|
2019-05-26 14:14:09 -07:00
|
|
|
LOG_ERROR(Frontend, "Failed to resize cache file to necessary size.");
|
|
|
|
return generator();
|
|
|
|
}
|
|
|
|
|
2020-04-15 12:59:23 -07:00
|
|
|
if (file1.write(reinterpret_cast<const char*>(icon.data()), icon.size()) !=
|
|
|
|
s64(icon.size())) {
|
2019-05-26 14:14:09 -07:00
|
|
|
LOG_ERROR(Frontend, "Failed to write data to cache file.");
|
|
|
|
return generator();
|
|
|
|
}
|
2019-04-23 06:08:38 -07:00
|
|
|
|
2019-05-30 19:13:38 -07:00
|
|
|
QFile file2{QString::fromStdString(path2)};
|
|
|
|
if (file2.open(QFile::WriteOnly)) {
|
|
|
|
file2.write(nacp.data(), nacp.size());
|
2019-05-26 14:14:09 -07:00
|
|
|
}
|
2019-04-23 06:08:38 -07:00
|
|
|
|
|
|
|
return std::make_pair(icon, nacp);
|
|
|
|
}
|
|
|
|
|
2019-05-30 19:13:38 -07:00
|
|
|
QFile file1(QString::fromStdString(path1));
|
|
|
|
QFile file2(QString::fromStdString(path2));
|
2019-04-23 06:08:38 -07:00
|
|
|
|
2019-05-30 19:13:38 -07:00
|
|
|
if (!file1.open(QFile::ReadOnly)) {
|
2019-05-26 14:14:09 -07:00
|
|
|
LOG_ERROR(Frontend, "Failed to open cache file for reading.");
|
|
|
|
return generator();
|
|
|
|
}
|
|
|
|
|
2019-05-30 19:13:38 -07:00
|
|
|
if (!file2.open(QFile::ReadOnly)) {
|
2019-05-26 14:14:09 -07:00
|
|
|
LOG_ERROR(Frontend, "Failed to open cache file for reading.");
|
|
|
|
return generator();
|
|
|
|
}
|
|
|
|
|
2019-05-30 19:13:38 -07:00
|
|
|
std::vector<u8> vec(file1.size());
|
|
|
|
if (file1.read(reinterpret_cast<char*>(vec.data()), vec.size()) !=
|
|
|
|
static_cast<s64>(vec.size())) {
|
|
|
|
return generator();
|
2019-04-23 06:08:38 -07:00
|
|
|
}
|
|
|
|
|
2019-05-30 19:13:38 -07:00
|
|
|
const auto data = file2.readAll();
|
|
|
|
return std::make_pair(vec, data.toStdString());
|
2019-04-23 06:08:38 -07:00
|
|
|
}
|
|
|
|
|
2018-10-09 11:22:31 -07:00
|
|
|
void GetMetadataFromControlNCA(const FileSys::PatchManager& patch_manager, const FileSys::NCA& nca,
|
|
|
|
std::vector<u8>& icon, std::string& name) {
|
2019-05-30 15:56:04 -07:00
|
|
|
std::tie(icon, name) = GetGameListCachedObject(
|
2019-04-23 06:08:38 -07:00
|
|
|
fmt::format("{:016X}", patch_manager.GetTitleID()), {}, [&patch_manager, &nca] {
|
|
|
|
const auto [nacp, icon_f] = patch_manager.ParseControlNCA(nca);
|
|
|
|
return std::make_pair(icon_f->ReadAllBytes(), nacp->GetApplicationName());
|
|
|
|
});
|
2018-09-07 13:08:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool HasSupportedFileExtension(const std::string& file_name) {
|
|
|
|
const QFileInfo file = QFileInfo(QString::fromStdString(file_name));
|
|
|
|
return GameList::supported_file_extensions.contains(file.suffix(), Qt::CaseInsensitive);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsExtractedNCAMain(const std::string& file_name) {
|
2019-05-20 12:07:56 -07:00
|
|
|
return QFileInfo(QString::fromStdString(file_name)).fileName() == QStringLiteral("main");
|
2018-09-07 13:08:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
QString FormatGameName(const std::string& physical_name) {
|
|
|
|
const QString physical_name_as_qstring = QString::fromStdString(physical_name);
|
|
|
|
const QFileInfo file_info(physical_name_as_qstring);
|
|
|
|
|
|
|
|
if (IsExtractedNCAMain(physical_name)) {
|
|
|
|
return file_info.dir().path();
|
|
|
|
}
|
|
|
|
|
|
|
|
return physical_name_as_qstring;
|
|
|
|
}
|
|
|
|
|
2018-09-25 06:21:06 -07:00
|
|
|
QString FormatPatchNameVersions(const FileSys::PatchManager& patch_manager,
|
|
|
|
Loader::AppLoader& loader, bool updatable = true) {
|
2018-09-07 13:08:08 -07:00
|
|
|
QString out;
|
2018-09-25 06:21:06 -07:00
|
|
|
FileSys::VirtualFile update_raw;
|
|
|
|
loader.ReadUpdateRaw(update_raw);
|
|
|
|
for (const auto& kv : patch_manager.GetPatchVersionNames(update_raw)) {
|
2018-12-04 10:34:46 -08:00
|
|
|
const bool is_update = kv.first == "Update" || kv.first == "[D] Update";
|
2018-10-24 08:25:55 -07:00
|
|
|
if (!updatable && is_update) {
|
2018-09-07 13:08:08 -07:00
|
|
|
continue;
|
2018-10-24 08:25:55 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
const QString type = QString::fromStdString(kv.first);
|
2018-09-07 13:08:08 -07:00
|
|
|
|
|
|
|
if (kv.second.empty()) {
|
2018-10-24 08:25:55 -07:00
|
|
|
out.append(QStringLiteral("%1\n").arg(type));
|
2018-09-07 13:08:08 -07:00
|
|
|
} else {
|
2018-09-25 11:07:13 -07:00
|
|
|
auto ver = kv.second;
|
|
|
|
|
|
|
|
// Display container name for packed updates
|
2018-10-24 08:25:55 -07:00
|
|
|
if (is_update && ver == "PACKED") {
|
2018-09-25 11:07:13 -07:00
|
|
|
ver = Loader::GetFileTypeString(loader.GetFileType());
|
2018-10-24 08:25:55 -07:00
|
|
|
}
|
2018-09-25 11:07:13 -07:00
|
|
|
|
2018-10-24 08:25:55 -07:00
|
|
|
out.append(QStringLiteral("%1 (%2)\n").arg(type, QString::fromStdString(ver)));
|
2018-09-07 13:08:08 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
out.chop(1);
|
|
|
|
return out;
|
|
|
|
}
|
2018-12-01 20:23:02 -08:00
|
|
|
|
|
|
|
QList<QStandardItem*> MakeGameListEntry(const std::string& path, const std::string& name,
|
|
|
|
const std::vector<u8>& icon, Loader::AppLoader& loader,
|
|
|
|
u64 program_id, const CompatibilityList& compatibility_list,
|
|
|
|
const FileSys::PatchManager& patch) {
|
|
|
|
const auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id);
|
|
|
|
|
|
|
|
// The game list uses this as compatibility number for untested games
|
2019-05-20 12:07:56 -07:00
|
|
|
QString compatibility{QStringLiteral("99")};
|
2018-12-01 20:23:02 -08:00
|
|
|
if (it != compatibility_list.end()) {
|
|
|
|
compatibility = it->second.first;
|
|
|
|
}
|
|
|
|
|
2018-12-05 14:47:03 -08:00
|
|
|
const auto file_type = loader.GetFileType();
|
|
|
|
const auto file_type_string = QString::fromStdString(Loader::GetFileTypeString(file_type));
|
|
|
|
|
2018-12-01 20:23:02 -08:00
|
|
|
QList<QStandardItem*> list{
|
2018-12-05 14:47:03 -08:00
|
|
|
new GameListItemPath(FormatGameName(path), icon, QString::fromStdString(name),
|
|
|
|
file_type_string, program_id),
|
2018-12-01 20:23:02 -08:00
|
|
|
new GameListItemCompat(compatibility),
|
2018-12-05 14:47:03 -08:00
|
|
|
new GameListItem(file_type_string),
|
2020-08-15 05:33:16 -07:00
|
|
|
new GameListItemSize(Common::FS::GetSize(path)),
|
2018-12-01 20:23:02 -08:00
|
|
|
};
|
|
|
|
|
2021-06-01 22:27:08 -07:00
|
|
|
const auto patch_versions = GetGameListCachedObject(
|
|
|
|
fmt::format("{:016X}", patch.GetTitleID()), "pv.txt", [&patch, &loader] {
|
|
|
|
return FormatPatchNameVersions(patch, loader, loader.IsRomFSUpdatable());
|
|
|
|
});
|
|
|
|
list.insert(2, new GameListItem(patch_versions));
|
2018-12-01 20:23:02 -08:00
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
2018-09-07 13:08:08 -07:00
|
|
|
} // Anonymous namespace
|
|
|
|
|
2019-03-04 09:40:53 -08:00
|
|
|
GameListWorker::GameListWorker(FileSys::VirtualFilesystem vfs,
|
2019-05-01 14:21:04 -07:00
|
|
|
FileSys::ManualContentProvider* provider,
|
2019-06-07 15:51:58 -07:00
|
|
|
QVector<UISettings::GameDir>& game_dirs,
|
2019-05-01 14:21:04 -07:00
|
|
|
const CompatibilityList& compatibility_list)
|
|
|
|
: vfs(std::move(vfs)), provider(provider), game_dirs(game_dirs),
|
2018-09-07 13:08:08 -07:00
|
|
|
compatibility_list(compatibility_list) {}
|
|
|
|
|
|
|
|
GameListWorker::~GameListWorker() = default;
|
|
|
|
|
2019-05-01 14:21:04 -07:00
|
|
|
void GameListWorker::AddTitlesToGameList(GameListDir* parent_dir) {
|
|
|
|
using namespace FileSys;
|
|
|
|
|
2020-11-18 04:53:10 -08:00
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
const auto& cache = dynamic_cast<ContentProviderUnion&>(system.GetContentProvider());
|
2019-05-01 14:21:04 -07:00
|
|
|
|
2020-11-18 04:53:10 -08:00
|
|
|
auto installed_games = cache.ListEntriesFilterOrigin(std::nullopt, TitleType::Application,
|
|
|
|
ContentRecordType::Program);
|
2019-05-04 18:07:09 -07:00
|
|
|
|
|
|
|
if (parent_dir->type() == static_cast<int>(GameListItemType::SdmcDir)) {
|
2019-05-01 14:21:04 -07:00
|
|
|
installed_games = cache.ListEntriesFilterOrigin(
|
|
|
|
ContentProviderUnionSlot::SDMC, TitleType::Application, ContentRecordType::Program);
|
2019-05-04 18:07:09 -07:00
|
|
|
} else if (parent_dir->type() == static_cast<int>(GameListItemType::UserNandDir)) {
|
|
|
|
installed_games = cache.ListEntriesFilterOrigin(
|
|
|
|
ContentProviderUnionSlot::UserNAND, TitleType::Application, ContentRecordType::Program);
|
|
|
|
} else if (parent_dir->type() == static_cast<int>(GameListItemType::SysNandDir)) {
|
2019-05-01 14:21:04 -07:00
|
|
|
installed_games = cache.ListEntriesFilterOrigin(
|
|
|
|
ContentProviderUnionSlot::SysNAND, TitleType::Application, ContentRecordType::Program);
|
|
|
|
}
|
2018-09-07 13:08:08 -07:00
|
|
|
|
2019-03-04 09:40:53 -08:00
|
|
|
for (const auto& [slot, game] : installed_games) {
|
2020-11-18 04:53:10 -08:00
|
|
|
if (slot == ContentProviderUnionSlot::FrontendManual) {
|
2019-03-04 09:40:53 -08:00
|
|
|
continue;
|
2020-11-18 04:53:10 -08:00
|
|
|
}
|
2019-03-04 09:40:53 -08:00
|
|
|
|
|
|
|
const auto file = cache.GetEntryUnparsed(game.title_id, game.type);
|
2020-11-18 04:53:10 -08:00
|
|
|
std::unique_ptr<Loader::AppLoader> loader = Loader::GetLoader(system, file);
|
|
|
|
if (!loader) {
|
2018-09-07 13:08:08 -07:00
|
|
|
continue;
|
2020-11-18 04:53:10 -08:00
|
|
|
}
|
2018-09-07 13:08:08 -07:00
|
|
|
|
|
|
|
std::vector<u8> icon;
|
|
|
|
std::string name;
|
|
|
|
u64 program_id = 0;
|
|
|
|
loader->ReadProgramId(program_id);
|
|
|
|
|
2020-11-18 04:53:10 -08:00
|
|
|
const PatchManager patch{program_id, system.GetFileSystemController(),
|
|
|
|
system.GetContentProvider()};
|
2019-05-01 14:21:04 -07:00
|
|
|
const auto control = cache.GetEntry(game.title_id, ContentRecordType::Control);
|
2020-11-18 04:53:10 -08:00
|
|
|
if (control != nullptr) {
|
2018-10-09 11:22:31 -07:00
|
|
|
GetMetadataFromControlNCA(patch, *control, icon, name);
|
2020-11-18 04:53:10 -08:00
|
|
|
}
|
2018-09-07 13:08:08 -07:00
|
|
|
|
2018-12-01 20:23:02 -08:00
|
|
|
emit EntryReady(MakeGameListEntry(file->GetFullPath(), name, icon, *loader, program_id,
|
2019-05-01 14:21:04 -07:00
|
|
|
compatibility_list, patch),
|
|
|
|
parent_dir);
|
2018-09-07 13:08:08 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-25 16:32:56 -07:00
|
|
|
void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_path, bool deep_scan,
|
|
|
|
GameListDir* parent_dir) {
|
2020-11-18 04:53:10 -08:00
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
|
2021-05-25 16:32:56 -07:00
|
|
|
const auto callback = [this, target, parent_dir,
|
|
|
|
&system](const std::filesystem::path& path) -> bool {
|
2018-12-04 15:39:32 -08:00
|
|
|
if (stop_processing) {
|
|
|
|
// Breaks the callback loop.
|
|
|
|
return false;
|
|
|
|
}
|
2018-09-07 13:08:08 -07:00
|
|
|
|
2021-05-25 16:32:56 -07:00
|
|
|
const auto physical_name = Common::FS::PathToUTF8String(path);
|
|
|
|
const auto is_dir = Common::FS::IsDir(path);
|
|
|
|
|
2018-09-07 13:08:08 -07:00
|
|
|
if (!is_dir &&
|
|
|
|
(HasSupportedFileExtension(physical_name) || IsExtractedNCAMain(physical_name))) {
|
2019-03-04 09:40:53 -08:00
|
|
|
const auto file = vfs->OpenFile(physical_name, FileSys::Mode::Read);
|
2021-05-25 16:32:56 -07:00
|
|
|
if (!file) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-11-18 04:53:10 -08:00
|
|
|
auto loader = Loader::GetLoader(system, file);
|
2018-12-05 14:58:11 -08:00
|
|
|
if (!loader) {
|
2018-09-07 13:08:08 -07:00
|
|
|
return true;
|
2018-12-05 14:58:11 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
const auto file_type = loader->GetFileType();
|
2020-02-09 08:30:02 -08:00
|
|
|
if (file_type == Loader::FileType::Unknown || file_type == Loader::FileType::Error) {
|
2018-12-05 14:58:11 -08:00
|
|
|
return true;
|
|
|
|
}
|
2018-09-07 13:08:08 -07:00
|
|
|
|
|
|
|
u64 program_id = 0;
|
|
|
|
const auto res2 = loader->ReadProgramId(program_id);
|
|
|
|
|
2019-03-04 09:40:53 -08:00
|
|
|
if (target == ScanTarget::FillManualContentProvider) {
|
|
|
|
if (res2 == Loader::ResultStatus::Success && file_type == Loader::FileType::NCA) {
|
|
|
|
provider->AddEntry(FileSys::TitleType::Application,
|
|
|
|
FileSys::GetCRTypeFromNCAType(FileSys::NCA{file}.GetType()),
|
|
|
|
program_id, file);
|
|
|
|
} else if (res2 == Loader::ResultStatus::Success &&
|
|
|
|
(file_type == Loader::FileType::XCI ||
|
|
|
|
file_type == Loader::FileType::NSP)) {
|
|
|
|
const auto nsp = file_type == Loader::FileType::NSP
|
|
|
|
? std::make_shared<FileSys::NSP>(file)
|
|
|
|
: FileSys::XCI{file}.GetSecurePartitionNSP();
|
|
|
|
for (const auto& title : nsp->GetNCAs()) {
|
|
|
|
for (const auto& entry : title.second) {
|
|
|
|
provider->AddEntry(entry.first.first, entry.first.second, title.first,
|
|
|
|
entry.second->GetBaseFile());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2021-07-19 22:10:05 -07:00
|
|
|
std::vector<u64> program_ids;
|
|
|
|
loader->ReadProgramIds(program_ids);
|
|
|
|
|
|
|
|
if (res2 == Loader::ResultStatus::Success && program_ids.size() > 1 &&
|
|
|
|
(file_type == Loader::FileType::XCI || file_type == Loader::FileType::NSP)) {
|
|
|
|
for (const auto id : program_ids) {
|
|
|
|
loader = Loader::GetLoader(system, file, id);
|
|
|
|
if (!loader) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<u8> icon;
|
|
|
|
[[maybe_unused]] const auto res1 = loader->ReadIcon(icon);
|
2018-09-07 13:08:08 -07:00
|
|
|
|
2021-07-19 22:10:05 -07:00
|
|
|
std::string name = " ";
|
|
|
|
[[maybe_unused]] const auto res3 = loader->ReadTitle(name);
|
2018-09-07 13:08:08 -07:00
|
|
|
|
2021-07-19 22:10:05 -07:00
|
|
|
const FileSys::PatchManager patch{id, system.GetFileSystemController(),
|
|
|
|
system.GetContentProvider()};
|
|
|
|
|
|
|
|
emit EntryReady(MakeGameListEntry(physical_name, name, icon, *loader, id,
|
|
|
|
compatibility_list, patch),
|
|
|
|
parent_dir);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
std::vector<u8> icon;
|
|
|
|
[[maybe_unused]] const auto res1 = loader->ReadIcon(icon);
|
2018-09-07 13:08:08 -07:00
|
|
|
|
2021-07-19 22:10:05 -07:00
|
|
|
std::string name = " ";
|
|
|
|
[[maybe_unused]] const auto res3 = loader->ReadTitle(name);
|
|
|
|
|
|
|
|
const FileSys::PatchManager patch{program_id, system.GetFileSystemController(),
|
|
|
|
system.GetContentProvider()};
|
|
|
|
|
|
|
|
emit EntryReady(MakeGameListEntry(physical_name, name, icon, *loader,
|
|
|
|
program_id, compatibility_list, patch),
|
|
|
|
parent_dir);
|
|
|
|
}
|
2019-03-04 09:40:53 -08:00
|
|
|
}
|
2021-05-25 16:32:56 -07:00
|
|
|
} else if (is_dir) {
|
2018-09-07 13:08:08 -07:00
|
|
|
watch_list.append(QString::fromStdString(physical_name));
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
2021-05-25 16:32:56 -07:00
|
|
|
if (deep_scan) {
|
|
|
|
Common::FS::IterateDirEntriesRecursively(dir_path, callback,
|
|
|
|
Common::FS::DirEntryFilter::All);
|
|
|
|
} else {
|
|
|
|
Common::FS::IterateDirEntries(dir_path, callback, Common::FS::DirEntryFilter::File);
|
|
|
|
}
|
2018-09-07 13:08:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void GameListWorker::run() {
|
|
|
|
stop_processing = false;
|
2020-07-29 04:51:42 -07:00
|
|
|
provider->ClearAllEntries();
|
2019-05-01 14:21:04 -07:00
|
|
|
|
|
|
|
for (UISettings::GameDir& game_dir : game_dirs) {
|
2019-05-04 18:07:09 -07:00
|
|
|
if (game_dir.path == QStringLiteral("SDMC")) {
|
|
|
|
auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::SdmcDir);
|
2019-10-04 16:41:02 -07:00
|
|
|
emit DirEntryReady(game_list_dir);
|
2019-05-04 18:07:09 -07:00
|
|
|
AddTitlesToGameList(game_list_dir);
|
|
|
|
} else if (game_dir.path == QStringLiteral("UserNAND")) {
|
|
|
|
auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::UserNandDir);
|
2019-10-04 16:41:02 -07:00
|
|
|
emit DirEntryReady(game_list_dir);
|
2019-05-01 14:21:04 -07:00
|
|
|
AddTitlesToGameList(game_list_dir);
|
2019-05-04 18:07:09 -07:00
|
|
|
} else if (game_dir.path == QStringLiteral("SysNAND")) {
|
|
|
|
auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::SysNandDir);
|
2019-10-04 16:41:02 -07:00
|
|
|
emit DirEntryReady(game_list_dir);
|
2019-05-01 14:21:04 -07:00
|
|
|
AddTitlesToGameList(game_list_dir);
|
|
|
|
} else {
|
|
|
|
watch_list.append(game_dir.path);
|
2019-05-03 10:21:57 -07:00
|
|
|
auto* const game_list_dir = new GameListDir(game_dir);
|
2019-10-04 16:41:02 -07:00
|
|
|
emit DirEntryReady(game_list_dir);
|
2020-07-29 06:21:51 -07:00
|
|
|
ScanFileSystem(ScanTarget::FillManualContentProvider, game_dir.path.toStdString(),
|
2021-05-25 16:32:56 -07:00
|
|
|
game_dir.deep_scan, game_list_dir);
|
2019-05-01 14:21:04 -07:00
|
|
|
ScanFileSystem(ScanTarget::PopulateGameList, game_dir.path.toStdString(),
|
2021-05-25 16:32:56 -07:00
|
|
|
game_dir.deep_scan, game_list_dir);
|
2019-05-01 14:21:04 -07:00
|
|
|
}
|
2020-08-15 08:14:09 -07:00
|
|
|
}
|
2019-05-01 14:21:04 -07:00
|
|
|
|
2018-09-07 13:08:08 -07:00
|
|
|
emit Finished(watch_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameListWorker::Cancel() {
|
|
|
|
this->disconnect();
|
|
|
|
stop_processing = true;
|
|
|
|
}
|