mirror of
https://github.com/yuzu-emu/yuzu-android
synced 2024-12-26 06:01:20 -08:00
Loader: Refactored use of const.
This commit is contained in:
parent
a8c4648520
commit
62b444cd17
@ -342,7 +342,7 @@ bool ElfReader::LoadSymbols() {
|
|||||||
namespace Loader {
|
namespace Loader {
|
||||||
|
|
||||||
/// AppLoader_ELF constructor
|
/// AppLoader_ELF constructor
|
||||||
AppLoader_ELF::AppLoader_ELF(std::string& filename) : is_loaded(false) {
|
AppLoader_ELF::AppLoader_ELF(const std::string& filename) : is_loaded(false) {
|
||||||
this->filename = filename;
|
this->filename = filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,7 +356,7 @@ AppLoader_ELF::~AppLoader_ELF() {
|
|||||||
* @todo Move NCSD parsing out of here and create a separate function for loading these
|
* @todo Move NCSD parsing out of here and create a separate function for loading these
|
||||||
* @return True on success, otherwise false
|
* @return True on success, otherwise false
|
||||||
*/
|
*/
|
||||||
const ResultStatus AppLoader_ELF::Load() {
|
ResultStatus AppLoader_ELF::Load() {
|
||||||
INFO_LOG(LOADER, "Loading ELF file %s...", filename.c_str());
|
INFO_LOG(LOADER, "Loading ELF file %s...", filename.c_str());
|
||||||
|
|
||||||
if (is_loaded)
|
if (is_loaded)
|
||||||
|
@ -15,14 +15,14 @@ namespace Loader {
|
|||||||
/// Loads an ELF/AXF file
|
/// Loads an ELF/AXF file
|
||||||
class AppLoader_ELF : public AppLoader {
|
class AppLoader_ELF : public AppLoader {
|
||||||
public:
|
public:
|
||||||
AppLoader_ELF(std::string& filename);
|
AppLoader_ELF(const std::string& filename);
|
||||||
~AppLoader_ELF();
|
~AppLoader_ELF();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the bootable file
|
* Load the bootable file
|
||||||
* @return ResultStatus result of function
|
* @return ResultStatus result of function
|
||||||
*/
|
*/
|
||||||
const ResultStatus Load();
|
ResultStatus Load();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string filename;
|
std::string filename;
|
||||||
|
@ -18,7 +18,7 @@ namespace Loader {
|
|||||||
* @todo (ShizZy) this function sucks... make it actually check file contents etc.
|
* @todo (ShizZy) this function sucks... make it actually check file contents etc.
|
||||||
* @return FileType of file
|
* @return FileType of file
|
||||||
*/
|
*/
|
||||||
const FileType IdentifyFile(const std::string &filename) {
|
FileType IdentifyFile(const std::string &filename) {
|
||||||
if (filename.size() == 0) {
|
if (filename.size() == 0) {
|
||||||
ERROR_LOG(LOADER, "invalid filename %s", filename.c_str());
|
ERROR_LOG(LOADER, "invalid filename %s", filename.c_str());
|
||||||
return FileType::Error;
|
return FileType::Error;
|
||||||
@ -45,7 +45,7 @@ const FileType IdentifyFile(const std::string &filename) {
|
|||||||
* @param filename String filename of bootable file
|
* @param filename String filename of bootable file
|
||||||
* @return ResultStatus result of function
|
* @return ResultStatus result of function
|
||||||
*/
|
*/
|
||||||
const ResultStatus LoadFile(std::string& filename) {
|
ResultStatus LoadFile(const std::string& filename) {
|
||||||
INFO_LOG(LOADER, "Loading file %s...", filename.c_str());
|
INFO_LOG(LOADER, "Loading file %s...", filename.c_str());
|
||||||
|
|
||||||
switch (IdentifyFile(filename)) {
|
switch (IdentifyFile(filename)) {
|
||||||
|
@ -44,7 +44,7 @@ public:
|
|||||||
* Load the application
|
* Load the application
|
||||||
* @return ResultStatus result of function
|
* @return ResultStatus result of function
|
||||||
*/
|
*/
|
||||||
virtual const ResultStatus Load() = 0;
|
virtual ResultStatus Load() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the code (typically .code section) of the application
|
* Get the code (typically .code section) of the application
|
||||||
@ -109,13 +109,13 @@ protected:
|
|||||||
* @param filename String filename of bootable file
|
* @param filename String filename of bootable file
|
||||||
* @return FileType of file
|
* @return FileType of file
|
||||||
*/
|
*/
|
||||||
const FileType IdentifyFile(const std::string &filename);
|
FileType IdentifyFile(const std::string &filename);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identifies and loads a bootable file
|
* Identifies and loads a bootable file
|
||||||
* @param filename String filename of bootable file
|
* @param filename String filename of bootable file
|
||||||
* @return ResultStatus result of function
|
* @return ResultStatus result of function
|
||||||
*/
|
*/
|
||||||
const ResultStatus LoadFile(std::string& filename);
|
ResultStatus LoadFile(const std::string& filename);
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -102,7 +102,7 @@ bool LZSS_Decompress(u8* compressed, u32 compressed_size, u8* decompressed, u32
|
|||||||
// AppLoader_NCCH class
|
// AppLoader_NCCH class
|
||||||
|
|
||||||
/// AppLoader_NCCH constructor
|
/// AppLoader_NCCH constructor
|
||||||
AppLoader_NCCH::AppLoader_NCCH(std::string& filename) {
|
AppLoader_NCCH::AppLoader_NCCH(const std::string& filename) {
|
||||||
this->filename = filename;
|
this->filename = filename;
|
||||||
is_loaded = false;
|
is_loaded = false;
|
||||||
is_compressed = false;
|
is_compressed = false;
|
||||||
@ -119,7 +119,7 @@ AppLoader_NCCH::~AppLoader_NCCH() {
|
|||||||
* Loads .code section into memory for booting
|
* Loads .code section into memory for booting
|
||||||
* @return ResultStatus result of function
|
* @return ResultStatus result of function
|
||||||
*/
|
*/
|
||||||
const ResultStatus AppLoader_NCCH::LoadExec() const {
|
ResultStatus AppLoader_NCCH::LoadExec() const {
|
||||||
if (!is_loaded)
|
if (!is_loaded)
|
||||||
return ResultStatus::ErrorNotLoaded;
|
return ResultStatus::ErrorNotLoaded;
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ const ResultStatus AppLoader_NCCH::LoadExec() const {
|
|||||||
* @param name Name of section to read out of NCCH file
|
* @param name Name of section to read out of NCCH file
|
||||||
* @param buffer Buffer to read section into.
|
* @param buffer Buffer to read section into.
|
||||||
*/
|
*/
|
||||||
const ResultStatus AppLoader_NCCH::LoadSectionExeFS(File::IOFile& file, const char* name,
|
ResultStatus AppLoader_NCCH::LoadSectionExeFS(File::IOFile& file, const char* name,
|
||||||
std::vector<u8>& buffer) {
|
std::vector<u8>& buffer) {
|
||||||
|
|
||||||
// Iterate through the ExeFs archive until we find the .code file...
|
// Iterate through the ExeFs archive until we find the .code file...
|
||||||
@ -183,7 +183,7 @@ const ResultStatus AppLoader_NCCH::LoadSectionExeFS(File::IOFile& file, const ch
|
|||||||
* @param file Handle to file to read from
|
* @param file Handle to file to read from
|
||||||
* @return ResultStatus result of function
|
* @return ResultStatus result of function
|
||||||
*/
|
*/
|
||||||
const ResultStatus AppLoader_NCCH::LoadRomFS(File::IOFile& file) {
|
ResultStatus AppLoader_NCCH::LoadRomFS(File::IOFile& file) {
|
||||||
// Check if the NCCH has a RomFS...
|
// Check if the NCCH has a RomFS...
|
||||||
if (ncch_header.romfs_offset != 0 && ncch_header.romfs_size != 0) {
|
if (ncch_header.romfs_offset != 0 && ncch_header.romfs_size != 0) {
|
||||||
u32 romfs_offset = ncch_offset + (ncch_header.romfs_offset * kBlockSize) + 0x1000;
|
u32 romfs_offset = ncch_offset + (ncch_header.romfs_offset * kBlockSize) + 0x1000;
|
||||||
@ -210,7 +210,7 @@ const ResultStatus AppLoader_NCCH::LoadRomFS(File::IOFile& file) {
|
|||||||
* @todo Move NCSD parsing out of here and create a separate function for loading these
|
* @todo Move NCSD parsing out of here and create a separate function for loading these
|
||||||
* @return True on success, otherwise false
|
* @return True on success, otherwise false
|
||||||
*/
|
*/
|
||||||
const ResultStatus AppLoader_NCCH::Load() {
|
ResultStatus AppLoader_NCCH::Load() {
|
||||||
INFO_LOG(LOADER, "Loading NCCH file %s...", filename.c_str());
|
INFO_LOG(LOADER, "Loading NCCH file %s...", filename.c_str());
|
||||||
|
|
||||||
if (is_loaded)
|
if (is_loaded)
|
||||||
|
@ -147,14 +147,14 @@ namespace Loader {
|
|||||||
/// Loads an NCCH file (e.g. from a CCI, or the first NCCH in a CXI)
|
/// Loads an NCCH file (e.g. from a CCI, or the first NCCH in a CXI)
|
||||||
class AppLoader_NCCH : public AppLoader {
|
class AppLoader_NCCH : public AppLoader {
|
||||||
public:
|
public:
|
||||||
AppLoader_NCCH(std::string& filename);
|
AppLoader_NCCH(const std::string& filename);
|
||||||
~AppLoader_NCCH();
|
~AppLoader_NCCH();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the application
|
* Load the application
|
||||||
* @return ResultStatus result of function
|
* @return ResultStatus result of function
|
||||||
*/
|
*/
|
||||||
const ResultStatus Load();
|
ResultStatus Load();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -165,21 +165,20 @@ private:
|
|||||||
* @param buffer Buffer to read section into.
|
* @param buffer Buffer to read section into.
|
||||||
* @return ResultStatus result of function
|
* @return ResultStatus result of function
|
||||||
*/
|
*/
|
||||||
const ResultStatus LoadSectionExeFS(File::IOFile& file, const char* name,
|
ResultStatus LoadSectionExeFS(File::IOFile& file, const char* name, std::vector<u8>& buffer);
|
||||||
std::vector<u8>& buffer);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads RomFS of an NCCH file into AppLoader
|
* Reads RomFS of an NCCH file into AppLoader
|
||||||
* @param file Handle to file to read from
|
* @param file Handle to file to read from
|
||||||
* @return ResultStatus result of function
|
* @return ResultStatus result of function
|
||||||
*/
|
*/
|
||||||
const ResultStatus LoadRomFS(File::IOFile& file);
|
ResultStatus LoadRomFS(File::IOFile& file);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads .code section into memory for booting
|
* Loads .code section into memory for booting
|
||||||
* @return ResultStatus result of function
|
* @return ResultStatus result of function
|
||||||
*/
|
*/
|
||||||
const ResultStatus LoadExec() const;
|
ResultStatus LoadExec() const;
|
||||||
|
|
||||||
std::string filename;
|
std::string filename;
|
||||||
bool is_loaded;
|
bool is_loaded;
|
||||||
|
Loading…
Reference in New Issue
Block a user