Merge pull request #4563 from lioncash/rcache

registered_cache: Make use of designated initializers
This commit is contained in:
bunnei 2020-08-25 10:07:33 -04:00 committed by GitHub
commit dd828607e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -257,8 +257,7 @@ std::vector<NcaID> PlaceholderCache::List() const {
for (const auto& sdir : dir->GetSubdirectories()) { for (const auto& sdir : dir->GetSubdirectories()) {
for (const auto& file : sdir->GetFiles()) { for (const auto& file : sdir->GetFiles()) {
const auto name = file->GetName(); const auto name = file->GetName();
if (name.length() == 36 && name[32] == '.' && name[33] == 'n' && name[34] == 'c' && if (name.length() == 36 && name.ends_with(".nca")) {
name[35] == 'a') {
out.push_back(Common::HexStringToArray<0x10>(name.substr(0, 32))); out.push_back(Common::HexStringToArray<0x10>(name.substr(0, 32)));
} }
} }
@ -621,25 +620,25 @@ InstallResult RegisteredCache::InstallEntry(const NSP& nsp, bool overwrite_if_ex
InstallResult RegisteredCache::InstallEntry(const NCA& nca, TitleType type, InstallResult RegisteredCache::InstallEntry(const NCA& nca, TitleType type,
bool overwrite_if_exists, const VfsCopyFunction& copy) { bool overwrite_if_exists, const VfsCopyFunction& copy) {
CNMTHeader header{ const CNMTHeader header{
nca.GetTitleId(), // Title ID .title_id = nca.GetTitleId(),
0, // Ignore/Default title version .title_version = 0,
type, // Type .type = type,
{}, // Padding .reserved = {},
0x10, // Default table offset .table_offset = 0x10,
1, // 1 Content Entry .number_content_entries = 1,
0, // No Meta Entries .number_meta_entries = 0,
{}, // Padding .attributes = 0,
{}, // Reserved 1 .reserved2 = {},
0, // Is committed .is_committed = 0,
0, // Required download system version .required_download_system_version = 0,
{}, // Reserved 2 .reserved3 = {},
}; };
OptionalHeader opt_header{0, 0}; const OptionalHeader opt_header{0, 0};
ContentRecord c_rec{{}, {}, {}, GetCRTypeFromNCAType(nca.GetType()), {}}; ContentRecord c_rec{{}, {}, {}, GetCRTypeFromNCAType(nca.GetType()), {}};
const auto& data = nca.GetBaseFile()->ReadBytes(0x100000); const auto& data = nca.GetBaseFile()->ReadBytes(0x100000);
mbedtls_sha256_ret(data.data(), data.size(), c_rec.hash.data(), 0); mbedtls_sha256_ret(data.data(), data.size(), c_rec.hash.data(), 0);
memcpy(&c_rec.nca_id, &c_rec.hash, 16); std::memcpy(&c_rec.nca_id, &c_rec.hash, 16);
const CNMT new_cnmt(header, opt_header, {c_rec}, {}); const CNMT new_cnmt(header, opt_header, {c_rec}, {});
if (!RawInstallYuzuMeta(new_cnmt)) { if (!RawInstallYuzuMeta(new_cnmt)) {
return InstallResult::ErrorMetaFailed; return InstallResult::ErrorMetaFailed;