summaryrefslogtreecommitdiff
path: root/src/core/loader/nsp.cpp
diff options
context:
space:
mode:
authorGravatar Zach Hilman2018-08-25 22:42:54 -0400
committerGravatar Zach Hilman2018-09-04 14:29:19 -0400
commite4e55d064edd71fbf359dec9d6b5efad4f0d6c91 (patch)
tree2ab6e2d16084e7071d89139e6ab25b2c11a31990 /src/core/loader/nsp.cpp
parentqt: Add UI support for NSP files (diff)
downloadyuzu-e4e55d064edd71fbf359dec9d6b5efad4f0d6c91.tar.gz
yuzu-e4e55d064edd71fbf359dec9d6b5efad4f0d6c91.tar.xz
yuzu-e4e55d064edd71fbf359dec9d6b5efad4f0d6c91.zip
nsp: Comply with style and performance guidelines
Diffstat (limited to 'src/core/loader/nsp.cpp')
-rw-r--r--src/core/loader/nsp.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/core/loader/nsp.cpp b/src/core/loader/nsp.cpp
index 75d9fc1bc..b59d40052 100644
--- a/src/core/loader/nsp.cpp
+++ b/src/core/loader/nsp.cpp
@@ -21,22 +21,27 @@ namespace Loader {
21AppLoader_NSP::AppLoader_NSP(FileSys::VirtualFile file) 21AppLoader_NSP::AppLoader_NSP(FileSys::VirtualFile file)
22 : AppLoader(file), nsp(std::make_unique<FileSys::NSP>(file)), 22 : AppLoader(file), nsp(std::make_unique<FileSys::NSP>(file)),
23 title_id(nsp->GetProgramTitleID()) { 23 title_id(nsp->GetProgramTitleID()) {
24
24 if (nsp->GetStatus() != ResultStatus::Success) 25 if (nsp->GetStatus() != ResultStatus::Success)
25 return; 26 return;
26 if (nsp->IsExtractedType()) 27 if (nsp->IsExtractedType())
27 return; 28 return;
29
28 const auto control_nca = 30 const auto control_nca =
29 nsp->GetNCA(nsp->GetFirstTitleID(), FileSys::ContentRecordType::Control); 31 nsp->GetNCA(nsp->GetFirstTitleID(), FileSys::ContentRecordType::Control);
30 if (control_nca == nullptr || control_nca->GetStatus() != ResultStatus::Success) 32 if (control_nca == nullptr || control_nca->GetStatus() != ResultStatus::Success)
31 return; 33 return;
34
32 const auto romfs = FileSys::ExtractRomFS(control_nca->GetRomFS()); 35 const auto romfs = FileSys::ExtractRomFS(control_nca->GetRomFS());
33 if (romfs == nullptr) 36 if (romfs == nullptr)
34 return; 37 return;
38
35 for (const auto& language : FileSys::LANGUAGE_NAMES) { 39 for (const auto& language : FileSys::LANGUAGE_NAMES) {
36 icon_file = romfs->GetFile("icon_" + std::string(language) + ".dat"); 40 icon_file = romfs->GetFile("icon_" + std::string(language) + ".dat");
37 if (icon_file != nullptr) 41 if (icon_file != nullptr)
38 break; 42 break;
39 } 43 }
44
40 const auto nacp_raw = romfs->GetFile("control.nacp"); 45 const auto nacp_raw = romfs->GetFile("control.nacp");
41 if (nacp_raw == nullptr) 46 if (nacp_raw == nullptr)
42 return; 47 return;
@@ -51,15 +56,17 @@ FileType AppLoader_NSP::IdentifyType(const FileSys::VirtualFile& file) {
51 if (nsp.GetStatus() == ResultStatus::Success) { 56 if (nsp.GetStatus() == ResultStatus::Success) {
52 // Extracted Type case 57 // Extracted Type case
53 if (nsp.IsExtractedType() && nsp.GetExeFS() != nullptr && 58 if (nsp.IsExtractedType() && nsp.GetExeFS() != nullptr &&
54 FileSys::IsDirectoryExeFS(nsp.GetExeFS()) && nsp.GetRomFS() != nullptr) 59 FileSys::IsDirectoryExeFS(nsp.GetExeFS()) && nsp.GetRomFS() != nullptr) {
55 return FileType::NSP; 60 return FileType::NSP;
61 }
56 62
57 // Non-Ectracted Type case 63 // Non-Ectracted Type case
58 if (!nsp.IsExtractedType() && 64 if (!nsp.IsExtractedType() &&
59 nsp.GetNCA(nsp.GetFirstTitleID(), FileSys::ContentRecordType::Program) != nullptr && 65 nsp.GetNCA(nsp.GetFirstTitleID(), FileSys::ContentRecordType::Program) != nullptr &&
60 AppLoader_NCA::IdentifyType(nsp.GetNCAFile( 66 AppLoader_NCA::IdentifyType(nsp.GetNCAFile(
61 nsp.GetFirstTitleID(), FileSys::ContentRecordType::Program)) == FileType::NCA) 67 nsp.GetFirstTitleID(), FileSys::ContentRecordType::Program)) == FileType::NCA) {
62 return FileType::NSP; 68 return FileType::NSP;
69 }
63 } 70 }
64 71
65 return FileType::Error; 72 return FileType::Error;