summaryrefslogtreecommitdiff
path: root/src/core/loader/nsp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/loader/nsp.cpp')
-rw-r--r--src/core/loader/nsp.cpp36
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
117 return result; 117 return result;
118} 118}
119 119
120ResultStatus AppLoader_NSP::VerifyIntegrity(std::function<bool(size_t, size_t)> progress_callback) {
121 // Extracted-type NSPs can't be verified.
122 if (nsp->IsExtractedType()) {
123 return ResultStatus::ErrorIntegrityVerificationNotImplemented;
124 }
125
126 // Get list of all NCAs.
127 const auto ncas = nsp->GetNCAsCollapsed();
128
129 size_t total_size = 0;
130 size_t processed_size = 0;
131
132 // Loop over NCAs, collecting the total size to verify.
133 for (const auto& nca : ncas) {
134 total_size += nca->GetBaseFile()->GetSize();
135 }
136
137 // Loop over NCAs again, verifying each.
138 for (const auto& nca : ncas) {
139 AppLoader_NCA loader_nca(nca->GetBaseFile());
140
141 const auto NcaProgressCallback = [&](size_t nca_processed_size, size_t nca_total_size) {
142 return progress_callback(processed_size + nca_processed_size, total_size);
143 };
144
145 const auto verification_result = loader_nca.VerifyIntegrity(NcaProgressCallback);
146 if (verification_result != ResultStatus::Success) {
147 return verification_result;
148 }
149
150 processed_size += nca->GetBaseFile()->GetSize();
151 }
152
153 return ResultStatus::Success;
154}
155
120ResultStatus AppLoader_NSP::ReadRomFS(FileSys::VirtualFile& out_file) { 156ResultStatus AppLoader_NSP::ReadRomFS(FileSys::VirtualFile& out_file) {
121 return secondary_loader->ReadRomFS(out_file); 157 return secondary_loader->ReadRomFS(out_file);
122} 158}