mirror of
https://github.com/PabloMK7/citra.git
synced 2024-11-25 00:44:05 +00:00
loader: Expose program title.
This commit is contained in:
parent
035716d57b
commit
f5cf9960d9
3 changed files with 31 additions and 12 deletions
|
@ -166,6 +166,15 @@ public:
|
||||||
return ResultStatus::ErrorNotImplemented;
|
return ResultStatus::ErrorNotImplemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the title of the application
|
||||||
|
* @param title Reference to store the application title into
|
||||||
|
* @return ResultStatus result of function
|
||||||
|
*/
|
||||||
|
virtual ResultStatus ReadTitle(std::string& title) {
|
||||||
|
return ResultStatus::ErrorNotImplemented;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
FileUtil::IOFile file;
|
FileUtil::IOFile file;
|
||||||
bool is_loaded = false;
|
bool is_loaded = false;
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
|
#include <codecvt>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <locale>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/string_util.h"
|
#include "common/string_util.h"
|
||||||
|
@ -420,4 +422,22 @@ ResultStatus AppLoader_NCCH::ReadRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_
|
||||||
return ResultStatus::ErrorNotUsed;
|
return ResultStatus::ErrorNotUsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ResultStatus AppLoader_NCCH::ReadTitle(std::string& title) {
|
||||||
|
std::vector<u8> data;
|
||||||
|
Loader::SMDH smdh;
|
||||||
|
ReadIcon(data);
|
||||||
|
|
||||||
|
if (!Loader::IsValidSMDH(data)) {
|
||||||
|
return ResultStatus::ErrorInvalidFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(&smdh, data.data(), sizeof(Loader::SMDH));
|
||||||
|
|
||||||
|
const auto& short_title = smdh.GetShortTitle(SMDH::TitleLanguage::English);
|
||||||
|
auto title_end = std::find(short_title.begin(), short_title.end(), u'\0');
|
||||||
|
title = Common::UTF16ToUTF8(std::u16string{short_title.begin(), title_end});
|
||||||
|
|
||||||
|
return ResultStatus::Success;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Loader
|
} // namespace Loader
|
||||||
|
|
|
@ -191,23 +191,13 @@ public:
|
||||||
|
|
||||||
ResultStatus ReadLogo(std::vector<u8>& buffer) override;
|
ResultStatus ReadLogo(std::vector<u8>& buffer) override;
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the program id of the application
|
|
||||||
* @param out_program_id Reference to store program id into
|
|
||||||
* @return ResultStatus result of function
|
|
||||||
*/
|
|
||||||
ResultStatus ReadProgramId(u64& out_program_id) override;
|
ResultStatus ReadProgramId(u64& out_program_id) override;
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the RomFS of the application
|
|
||||||
* @param romfs_file Reference to buffer to store data
|
|
||||||
* @param offset Offset in the file to the RomFS
|
|
||||||
* @param size Size of the RomFS in bytes
|
|
||||||
* @return ResultStatus result of function
|
|
||||||
*/
|
|
||||||
ResultStatus ReadRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset,
|
ResultStatus ReadRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset,
|
||||||
u64& size) override;
|
u64& size) override;
|
||||||
|
|
||||||
|
ResultStatus ReadTitle(std::string& title) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Reads an application ExeFS section of an NCCH file into AppLoader (e.g. .code, .logo, etc.)
|
* Reads an application ExeFS section of an NCCH file into AppLoader (e.g. .code, .logo, etc.)
|
||||||
|
|
Loading…
Reference in a new issue