summaryrefslogtreecommitdiff
path: root/src/core/loader
diff options
context:
space:
mode:
authorGravatar bunnei2017-08-01 19:51:44 -0400
committerGravatar bunnei2017-08-03 20:10:37 -0400
commitf5cf9960d9eb5ff5afb39c0356f42035e2dd1ccf (patch)
tree851abceebb8196b95583a3bde4d2e97818b96f66 /src/core/loader
parentMerge pull request #2850 from j-selby/fix_invalid_paths (diff)
downloadyuzu-f5cf9960d9eb5ff5afb39c0356f42035e2dd1ccf.tar.gz
yuzu-f5cf9960d9eb5ff5afb39c0356f42035e2dd1ccf.tar.xz
yuzu-f5cf9960d9eb5ff5afb39c0356f42035e2dd1ccf.zip
loader: Expose program title.
Diffstat (limited to 'src/core/loader')
-rw-r--r--src/core/loader/loader.h9
-rw-r--r--src/core/loader/ncch.cpp20
-rw-r--r--src/core/loader/ncch.h14
3 files changed, 31 insertions, 12 deletions
diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h
index 48bbf687d..e731888a2 100644
--- a/src/core/loader/loader.h
+++ b/src/core/loader/loader.h
@@ -166,6 +166,15 @@ public:
166 return ResultStatus::ErrorNotImplemented; 166 return ResultStatus::ErrorNotImplemented;
167 } 167 }
168 168
169 /**
170 * Get the title of the application
171 * @param title Reference to store the application title into
172 * @return ResultStatus result of function
173 */
174 virtual ResultStatus ReadTitle(std::string& title) {
175 return ResultStatus::ErrorNotImplemented;
176 }
177
169protected: 178protected:
170 FileUtil::IOFile file; 179 FileUtil::IOFile file;
171 bool is_loaded = false; 180 bool is_loaded = false;
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp
index fc4d14a59..c007069a9 100644
--- a/src/core/loader/ncch.cpp
+++ b/src/core/loader/ncch.cpp
@@ -4,7 +4,9 @@
4 4
5#include <algorithm> 5#include <algorithm>
6#include <cinttypes> 6#include <cinttypes>
7#include <codecvt>
7#include <cstring> 8#include <cstring>
9#include <locale>
8#include <memory> 10#include <memory>
9#include "common/logging/log.h" 11#include "common/logging/log.h"
10#include "common/string_util.h" 12#include "common/string_util.h"
@@ -420,4 +422,22 @@ ResultStatus AppLoader_NCCH::ReadRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_
420 return ResultStatus::ErrorNotUsed; 422 return ResultStatus::ErrorNotUsed;
421} 423}
422 424
425ResultStatus AppLoader_NCCH::ReadTitle(std::string& title) {
426 std::vector<u8> data;
427 Loader::SMDH smdh;
428 ReadIcon(data);
429
430 if (!Loader::IsValidSMDH(data)) {
431 return ResultStatus::ErrorInvalidFormat;
432 }
433
434 memcpy(&smdh, data.data(), sizeof(Loader::SMDH));
435
436 const auto& short_title = smdh.GetShortTitle(SMDH::TitleLanguage::English);
437 auto title_end = std::find(short_title.begin(), short_title.end(), u'\0');
438 title = Common::UTF16ToUTF8(std::u16string{short_title.begin(), title_end});
439
440 return ResultStatus::Success;
441}
442
423} // namespace Loader 443} // namespace Loader
diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h
index 0ebd47fd5..e40cef764 100644
--- a/src/core/loader/ncch.h
+++ b/src/core/loader/ncch.h
@@ -191,23 +191,13 @@ public:
191 191
192 ResultStatus ReadLogo(std::vector<u8>& buffer) override; 192 ResultStatus ReadLogo(std::vector<u8>& buffer) override;
193 193
194 /**
195 * Get the program id of the application
196 * @param out_program_id Reference to store program id into
197 * @return ResultStatus result of function
198 */
199 ResultStatus ReadProgramId(u64& out_program_id) override; 194 ResultStatus ReadProgramId(u64& out_program_id) override;
200 195
201 /**
202 * Get the RomFS of the application
203 * @param romfs_file Reference to buffer to store data
204 * @param offset Offset in the file to the RomFS
205 * @param size Size of the RomFS in bytes
206 * @return ResultStatus result of function
207 */
208 ResultStatus ReadRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset, 196 ResultStatus ReadRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset,
209 u64& size) override; 197 u64& size) override;
210 198
199 ResultStatus ReadTitle(std::string& title) override;
200
211private: 201private:
212 /** 202 /**
213 * Reads an application ExeFS section of an NCCH file into AppLoader (e.g. .code, .logo, etc.) 203 * Reads an application ExeFS section of an NCCH file into AppLoader (e.g. .code, .logo, etc.)