diff options
| author | 2018-08-25 22:42:54 -0400 | |
|---|---|---|
| committer | 2018-09-04 14:29:19 -0400 | |
| commit | e4e55d064edd71fbf359dec9d6b5efad4f0d6c91 (patch) | |
| tree | 2ab6e2d16084e7071d89139e6ab25b2c11a31990 /src/core/loader | |
| parent | qt: Add UI support for NSP files (diff) | |
| download | yuzu-e4e55d064edd71fbf359dec9d6b5efad4f0d6c91.tar.gz yuzu-e4e55d064edd71fbf359dec9d6b5efad4f0d6c91.tar.xz yuzu-e4e55d064edd71fbf359dec9d6b5efad4f0d6c91.zip | |
nsp: Comply with style and performance guidelines
Diffstat (limited to 'src/core/loader')
| -rw-r--r-- | src/core/loader/nsp.cpp | 11 | ||||
| -rw-r--r-- | src/core/loader/nsp.h | 2 |
2 files changed, 10 insertions, 3 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 { | |||
| 21 | AppLoader_NSP::AppLoader_NSP(FileSys::VirtualFile file) | 21 | AppLoader_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; |
diff --git a/src/core/loader/nsp.h b/src/core/loader/nsp.h index 785feaf37..7ef810499 100644 --- a/src/core/loader/nsp.h +++ b/src/core/loader/nsp.h | |||
| @@ -22,7 +22,7 @@ class AppLoader_NCA; | |||
| 22 | class AppLoader_NSP final : public AppLoader { | 22 | class AppLoader_NSP final : public AppLoader { |
| 23 | public: | 23 | public: |
| 24 | explicit AppLoader_NSP(FileSys::VirtualFile file); | 24 | explicit AppLoader_NSP(FileSys::VirtualFile file); |
| 25 | ~AppLoader_NSP(); | 25 | ~AppLoader_NSP() override; |
| 26 | 26 | ||
| 27 | /** | 27 | /** |
| 28 | * Returns the type of the file | 28 | * Returns the type of the file |