diff options
author | Liam <byteslice@airmail.cc> | 2023-09-06 07:06:03 +0200 |
---|---|---|
committer | Liam <byteslice@airmail.cc> | 2023-09-06 22:49:27 +0200 |
commit | 716e0a126a22cfdeeaad6204f236324429345d2e (patch) | |
tree | 52765c887393b85518ab99f27a07e6da12ad1e3d /src/core/loader/nsp.cpp | |
parent | core: Add support for loading NSPs with personalized tickets. (#10048) (diff) | |
download | yuzu-716e0a126a22cfdeeaad6204f236324429345d2e.tar yuzu-716e0a126a22cfdeeaad6204f236324429345d2e.tar.gz yuzu-716e0a126a22cfdeeaad6204f236324429345d2e.tar.bz2 yuzu-716e0a126a22cfdeeaad6204f236324429345d2e.tar.lz yuzu-716e0a126a22cfdeeaad6204f236324429345d2e.tar.xz yuzu-716e0a126a22cfdeeaad6204f236324429345d2e.tar.zst yuzu-716e0a126a22cfdeeaad6204f236324429345d2e.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/loader/nsp.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/core/loader/nsp.cpp b/src/core/loader/nsp.cpp index f9b2549a3..fe2af1ae6 100644 --- a/src/core/loader/nsp.cpp +++ b/src/core/loader/nsp.cpp @@ -117,6 +117,42 @@ AppLoader_NSP::LoadResult AppLoader_NSP::Load(Kernel::KProcess& process, Core::S return result; } +ResultStatus AppLoader_NSP::VerifyIntegrity(std::function<bool(size_t, size_t)> progress_callback) { + // Extracted-type NSPs can't be verified. + if (nsp->IsExtractedType()) { + return ResultStatus::ErrorIntegrityVerificationNotImplemented; + } + + // Get list of all NCAs. + const auto ncas = nsp->GetNCAsCollapsed(); + + size_t total_size = 0; + size_t processed_size = 0; + + // Loop over NCAs, collecting the total size to verify. + for (const auto& nca : ncas) { + total_size += nca->GetBaseFile()->GetSize(); + } + + // Loop over NCAs again, verifying each. + for (const auto& nca : ncas) { + AppLoader_NCA loader_nca(nca->GetBaseFile()); + + const auto NcaProgressCallback = [&](size_t nca_processed_size, size_t nca_total_size) { + return progress_callback(processed_size + nca_processed_size, total_size); + }; + + const auto verification_result = loader_nca.VerifyIntegrity(NcaProgressCallback); + if (verification_result != ResultStatus::Success) { + return verification_result; + } + + processed_size += nca->GetBaseFile()->GetSize(); + } + + return ResultStatus::Success; +} + ResultStatus AppLoader_NSP::ReadRomFS(FileSys::VirtualFile& out_file) { return secondary_loader->ReadRomFS(out_file); } |