summaryrefslogtreecommitdiff
path: root/src/core/loader/xci.cpp
diff options
context:
space:
mode:
authorGravatar Zach Hilman2018-08-06 23:13:37 -0400
committerGravatar Zach Hilman2018-08-06 23:13:42 -0400
commit91cfe70301bec23099ae27ad70e3da525a573cfe (patch)
treefa8fbde6661373f7d835f814b09f54f132b99aeb /src/core/loader/xci.cpp
parentFix missing qjpeg DLL (diff)
downloadyuzu-91cfe70301bec23099ae27ad70e3da525a573cfe.tar.gz
yuzu-91cfe70301bec23099ae27ad70e3da525a573cfe.tar.xz
yuzu-91cfe70301bec23099ae27ad70e3da525a573cfe.zip
loader: Add icon and title support to XCI
Diffstat (limited to 'src/core/loader/xci.cpp')
-rw-r--r--src/core/loader/xci.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/core/loader/xci.cpp b/src/core/loader/xci.cpp
index eb4dee2c2..d3fe24419 100644
--- a/src/core/loader/xci.cpp
+++ b/src/core/loader/xci.cpp
@@ -26,7 +26,25 @@ namespace Loader {
26AppLoader_XCI::AppLoader_XCI(FileSys::VirtualFile file) 26AppLoader_XCI::AppLoader_XCI(FileSys::VirtualFile file)
27 : AppLoader(file), xci(std::make_unique<FileSys::XCI>(file)), 27 : AppLoader(file), xci(std::make_unique<FileSys::XCI>(file)),
28 nca_loader(std::make_unique<AppLoader_NCA>( 28 nca_loader(std::make_unique<AppLoader_NCA>(
29 xci->GetNCAFileByType(FileSys::NCAContentType::Program))) {} 29 xci->GetNCAFileByType(FileSys::NCAContentType::Program))) {
30 if (xci->GetStatus() != ResultStatus::Success)
31 return;
32 const auto control_nca = xci->GetNCAByType(FileSys::NCAContentType::Control);
33 if (control_nca == nullptr || control_nca->GetStatus() != ResultStatus::Success)
34 return;
35 const auto romfs = FileSys::ExtractRomFS(control_nca->GetRomFS());
36 if (romfs == nullptr)
37 return;
38 for (const auto& language : FileSys::LANGUAGE_NAMES) {
39 icon_file = romfs->GetFile("icon_" + std::string(language) + ".dat");
40 if (icon_file != nullptr)
41 break;
42 }
43 const auto nacp_raw = romfs->GetFile("control.nacp");
44 if (nacp_raw == nullptr)
45 return;
46 nacp_file = std::make_shared<FileSys::NACP>(nacp_raw);
47}
30 48
31AppLoader_XCI::~AppLoader_XCI() = default; 49AppLoader_XCI::~AppLoader_XCI() = default;
32 50
@@ -71,4 +89,17 @@ ResultStatus AppLoader_XCI::ReadProgramId(u64& out_program_id) {
71 return nca_loader->ReadProgramId(out_program_id); 89 return nca_loader->ReadProgramId(out_program_id);
72} 90}
73 91
92ResultStatus AppLoader_XCI::ReadIcon(std::vector<u8>& buffer) {
93 if (icon_file == nullptr)
94 return ResultStatus::ErrorInvalidFormat;
95 buffer = icon_file->ReadAllBytes();
96 return ResultStatus::Success;
97}
98
99ResultStatus AppLoader_XCI::ReadTitle(std::string& title) {
100 if (nacp_file == nullptr)
101 return ResultStatus::ErrorInvalidFormat;
102 title = nacp_file->GetApplicationName();
103 return ResultStatus::Success;
104}
74} // namespace Loader 105} // namespace Loader