summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2020-08-25 10:07:33 -0400
committerGravatar GitHub2020-08-25 10:07:33 -0400
commitdd828607e0d8c1f25fe024bab77dafa9c9a4d62c (patch)
treed09a4074ad088a7083ebc81b55fdb0efd44349a4
parentMerge pull request #4548 from lioncash/color (diff)
parentregistered_cache: Make use of ends_with for string suffix checking (diff)
downloadyuzu-dd828607e0d8c1f25fe024bab77dafa9c9a4d62c.tar.gz
yuzu-dd828607e0d8c1f25fe024bab77dafa9c9a4d62c.tar.xz
yuzu-dd828607e0d8c1f25fe024bab77dafa9c9a4d62c.zip
Merge pull request #4563 from lioncash/rcache
registered_cache: Make use of designated initializers
Diffstat (limited to '')
-rw-r--r--src/core/file_sys/registered_cache.cpp33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp
index e42b677f7..da01002d5 100644
--- a/src/core/file_sys/registered_cache.cpp
+++ b/src/core/file_sys/registered_cache.cpp
@@ -257,8 +257,7 @@ std::vector<NcaID> PlaceholderCache::List() const {
257 for (const auto& sdir : dir->GetSubdirectories()) { 257 for (const auto& sdir : dir->GetSubdirectories()) {
258 for (const auto& file : sdir->GetFiles()) { 258 for (const auto& file : sdir->GetFiles()) {
259 const auto name = file->GetName(); 259 const auto name = file->GetName();
260 if (name.length() == 36 && name[32] == '.' && name[33] == 'n' && name[34] == 'c' && 260 if (name.length() == 36 && name.ends_with(".nca")) {
261 name[35] == 'a') {
262 out.push_back(Common::HexStringToArray<0x10>(name.substr(0, 32))); 261 out.push_back(Common::HexStringToArray<0x10>(name.substr(0, 32)));
263 } 262 }
264 } 263 }
@@ -621,25 +620,25 @@ InstallResult RegisteredCache::InstallEntry(const NSP& nsp, bool overwrite_if_ex
621 620
622InstallResult RegisteredCache::InstallEntry(const NCA& nca, TitleType type, 621InstallResult RegisteredCache::InstallEntry(const NCA& nca, TitleType type,
623 bool overwrite_if_exists, const VfsCopyFunction& copy) { 622 bool overwrite_if_exists, const VfsCopyFunction& copy) {
624 CNMTHeader header{ 623 const CNMTHeader header{
625 nca.GetTitleId(), // Title ID 624 .title_id = nca.GetTitleId(),
626 0, // Ignore/Default title version 625 .title_version = 0,
627 type, // Type 626 .type = type,
628 {}, // Padding 627 .reserved = {},
629 0x10, // Default table offset 628 .table_offset = 0x10,
630 1, // 1 Content Entry 629 .number_content_entries = 1,
631 0, // No Meta Entries 630 .number_meta_entries = 0,
632 {}, // Padding 631 .attributes = 0,
633 {}, // Reserved 1 632 .reserved2 = {},
634 0, // Is committed 633 .is_committed = 0,
635 0, // Required download system version 634 .required_download_system_version = 0,
636 {}, // Reserved 2 635 .reserved3 = {},
637 }; 636 };
638 OptionalHeader opt_header{0, 0}; 637 const OptionalHeader opt_header{0, 0};
639 ContentRecord c_rec{{}, {}, {}, GetCRTypeFromNCAType(nca.GetType()), {}}; 638 ContentRecord c_rec{{}, {}, {}, GetCRTypeFromNCAType(nca.GetType()), {}};
640 const auto& data = nca.GetBaseFile()->ReadBytes(0x100000); 639 const auto& data = nca.GetBaseFile()->ReadBytes(0x100000);
641 mbedtls_sha256_ret(data.data(), data.size(), c_rec.hash.data(), 0); 640 mbedtls_sha256_ret(data.data(), data.size(), c_rec.hash.data(), 0);
642 memcpy(&c_rec.nca_id, &c_rec.hash, 16); 641 std::memcpy(&c_rec.nca_id, &c_rec.hash, 16);
643 const CNMT new_cnmt(header, opt_header, {c_rec}, {}); 642 const CNMT new_cnmt(header, opt_header, {c_rec}, {});
644 if (!RawInstallYuzuMeta(new_cnmt)) { 643 if (!RawInstallYuzuMeta(new_cnmt)) {
645 return InstallResult::ErrorMetaFailed; 644 return InstallResult::ErrorMetaFailed;