Download TWL titles from NUS and list them in AM. (#7162)

* Download TWL titles from NUS and list them in AM.

* Remove duplicate entries.

* Move TODO comment
This commit is contained in:
PabloMK7 2023-11-14 10:33:58 +01:00 committed by GitHub
parent 88cc6acb4d
commit 63d1830429
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 4 deletions

View file

@ -646,6 +646,8 @@ std::string GetTitleContentPath(Service::FS::MediaType media_type, u64 tid, std:
}
std::string GetTitlePath(Service::FS::MediaType media_type, u64 tid) {
// TODO(PabloMK7) TWL titles should be in TWL Nand. Assuming CTR Nand for now.
u32 high = static_cast<u32>(tid >> 32);
u32 low = static_cast<u32>(tid & 0xFFFFFFFF);
@ -698,9 +700,19 @@ void Module::ScanForTitles(Service::FS::MediaType media_type) {
if (tid_string.length() == TITLE_ID_VALID_LENGTH) {
const u64 tid = std::stoull(tid_string, nullptr, 16);
FileSys::NCCHContainer container(GetTitleContentPath(media_type, tid));
if (container.Load() == Loader::ResultStatus::Success)
am_title_list[static_cast<u32>(media_type)].push_back(tid);
if (tid & TWL_TITLE_ID_FLAG) {
// TODO(PabloMK7) Move to TWL Nand, for now only check that
// the contents exists in CTR Nand as this is a SRL file
// instead of NCCH.
if (FileUtil::Exists(GetTitleContentPath(media_type, tid))) {
am_title_list[static_cast<u32>(media_type)].push_back(tid);
}
} else {
FileSys::NCCHContainer container(GetTitleContentPath(media_type, tid));
if (container.Load() == Loader::ResultStatus::Success) {
am_title_list[static_cast<u32>(media_type)].push_back(tid);
}
}
}
}
}

View file

@ -68,6 +68,8 @@ enum class InstallStatus : u32 {
// Title ID valid length
constexpr std::size_t TITLE_ID_VALID_LENGTH = 16;
constexpr u64 TWL_TITLE_ID_FLAG = 0x0000800000000000ULL;
// Progress callback for InstallCIA, receives bytes written and total bytes
using ProgressCallback = void(std::size_t, std::size_t);