summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2014-06-19 17:46:05 -0400
committerGravatar bunnei2014-06-24 19:30:06 -0400
commit62b444cd17c17e6f8009d87609b620bcb51b43bd (patch)
treec99a07441b97232f8f90f9ec06a0291a1ce5c396 /src
parentNCCH: Added RomFS loading. (diff)
downloadyuzu-62b444cd17c17e6f8009d87609b620bcb51b43bd.tar.gz
yuzu-62b444cd17c17e6f8009d87609b620bcb51b43bd.tar.xz
yuzu-62b444cd17c17e6f8009d87609b620bcb51b43bd.zip
Loader: Refactored use of const.
Diffstat (limited to 'src')
-rw-r--r--src/core/loader/elf.cpp4
-rw-r--r--src/core/loader/elf.h4
-rw-r--r--src/core/loader/loader.cpp4
-rw-r--r--src/core/loader/loader.h6
-rw-r--r--src/core/loader/ncch.cpp10
-rw-r--r--src/core/loader/ncch.h11
6 files changed, 19 insertions, 20 deletions
diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp
index 065601546..d9e5e130f 100644
--- a/src/core/loader/elf.cpp
+++ b/src/core/loader/elf.cpp
@@ -342,7 +342,7 @@ bool ElfReader::LoadSymbols() {
342namespace Loader { 342namespace Loader {
343 343
344/// AppLoader_ELF constructor 344/// AppLoader_ELF constructor
345AppLoader_ELF::AppLoader_ELF(std::string& filename) : is_loaded(false) { 345AppLoader_ELF::AppLoader_ELF(const std::string& filename) : is_loaded(false) {
346 this->filename = filename; 346 this->filename = filename;
347} 347}
348 348
@@ -356,7 +356,7 @@ AppLoader_ELF::~AppLoader_ELF() {
356 * @todo Move NCSD parsing out of here and create a separate function for loading these 356 * @todo Move NCSD parsing out of here and create a separate function for loading these
357 * @return True on success, otherwise false 357 * @return True on success, otherwise false
358 */ 358 */
359const ResultStatus AppLoader_ELF::Load() { 359ResultStatus AppLoader_ELF::Load() {
360 INFO_LOG(LOADER, "Loading ELF file %s...", filename.c_str()); 360 INFO_LOG(LOADER, "Loading ELF file %s...", filename.c_str());
361 361
362 if (is_loaded) 362 if (is_loaded)
diff --git a/src/core/loader/elf.h b/src/core/loader/elf.h
index 3fb010113..d3cbf414d 100644
--- a/src/core/loader/elf.h
+++ b/src/core/loader/elf.h
@@ -15,14 +15,14 @@ namespace Loader {
15/// Loads an ELF/AXF file 15/// Loads an ELF/AXF file
16class AppLoader_ELF : public AppLoader { 16class AppLoader_ELF : public AppLoader {
17public: 17public:
18 AppLoader_ELF(std::string& filename); 18 AppLoader_ELF(const std::string& filename);
19 ~AppLoader_ELF(); 19 ~AppLoader_ELF();
20 20
21 /** 21 /**
22 * Load the bootable file 22 * Load the bootable file
23 * @return ResultStatus result of function 23 * @return ResultStatus result of function
24 */ 24 */
25 const ResultStatus Load(); 25 ResultStatus Load();
26 26
27private: 27private:
28 std::string filename; 28 std::string filename;
diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp
index dd0863ff3..96cb81de0 100644
--- a/src/core/loader/loader.cpp
+++ b/src/core/loader/loader.cpp
@@ -18,7 +18,7 @@ namespace Loader {
18 * @todo (ShizZy) this function sucks... make it actually check file contents etc. 18 * @todo (ShizZy) this function sucks... make it actually check file contents etc.
19 * @return FileType of file 19 * @return FileType of file
20 */ 20 */
21const FileType IdentifyFile(const std::string &filename) { 21FileType IdentifyFile(const std::string &filename) {
22 if (filename.size() == 0) { 22 if (filename.size() == 0) {
23 ERROR_LOG(LOADER, "invalid filename %s", filename.c_str()); 23 ERROR_LOG(LOADER, "invalid filename %s", filename.c_str());
24 return FileType::Error; 24 return FileType::Error;
@@ -45,7 +45,7 @@ const FileType IdentifyFile(const std::string &filename) {
45 * @param filename String filename of bootable file 45 * @param filename String filename of bootable file
46 * @return ResultStatus result of function 46 * @return ResultStatus result of function
47 */ 47 */
48const ResultStatus LoadFile(std::string& filename) { 48ResultStatus LoadFile(const std::string& filename) {
49 INFO_LOG(LOADER, "Loading file %s...", filename.c_str()); 49 INFO_LOG(LOADER, "Loading file %s...", filename.c_str());
50 50
51 switch (IdentifyFile(filename)) { 51 switch (IdentifyFile(filename)) {
diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h
index 38b3d4c99..002af1f60 100644
--- a/src/core/loader/loader.h
+++ b/src/core/loader/loader.h
@@ -44,7 +44,7 @@ public:
44 * Load the application 44 * Load the application
45 * @return ResultStatus result of function 45 * @return ResultStatus result of function
46 */ 46 */
47 virtual const ResultStatus Load() = 0; 47 virtual ResultStatus Load() = 0;
48 48
49 /** 49 /**
50 * Get the code (typically .code section) of the application 50 * Get the code (typically .code section) of the application
@@ -109,13 +109,13 @@ protected:
109 * @param filename String filename of bootable file 109 * @param filename String filename of bootable file
110 * @return FileType of file 110 * @return FileType of file
111 */ 111 */
112const FileType IdentifyFile(const std::string &filename); 112FileType IdentifyFile(const std::string &filename);
113 113
114/** 114/**
115 * Identifies and loads a bootable file 115 * Identifies and loads a bootable file
116 * @param filename String filename of bootable file 116 * @param filename String filename of bootable file
117 * @return ResultStatus result of function 117 * @return ResultStatus result of function
118 */ 118 */
119const ResultStatus LoadFile(std::string& filename); 119ResultStatus LoadFile(const std::string& filename);
120 120
121} // namespace 121} // namespace
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp
index 6423da8f9..a4922c2c0 100644
--- a/src/core/loader/ncch.cpp
+++ b/src/core/loader/ncch.cpp
@@ -102,7 +102,7 @@ bool LZSS_Decompress(u8* compressed, u32 compressed_size, u8* decompressed, u32
102// AppLoader_NCCH class 102// AppLoader_NCCH class
103 103
104/// AppLoader_NCCH constructor 104/// AppLoader_NCCH constructor
105AppLoader_NCCH::AppLoader_NCCH(std::string& filename) { 105AppLoader_NCCH::AppLoader_NCCH(const std::string& filename) {
106 this->filename = filename; 106 this->filename = filename;
107 is_loaded = false; 107 is_loaded = false;
108 is_compressed = false; 108 is_compressed = false;
@@ -119,7 +119,7 @@ AppLoader_NCCH::~AppLoader_NCCH() {
119 * Loads .code section into memory for booting 119 * Loads .code section into memory for booting
120 * @return ResultStatus result of function 120 * @return ResultStatus result of function
121 */ 121 */
122const ResultStatus AppLoader_NCCH::LoadExec() const { 122ResultStatus AppLoader_NCCH::LoadExec() const {
123 if (!is_loaded) 123 if (!is_loaded)
124 return ResultStatus::ErrorNotLoaded; 124 return ResultStatus::ErrorNotLoaded;
125 125
@@ -137,7 +137,7 @@ const ResultStatus AppLoader_NCCH::LoadExec() const {
137 * @param name Name of section to read out of NCCH file 137 * @param name Name of section to read out of NCCH file
138 * @param buffer Buffer to read section into. 138 * @param buffer Buffer to read section into.
139 */ 139 */
140const ResultStatus AppLoader_NCCH::LoadSectionExeFS(File::IOFile& file, const char* name, 140ResultStatus AppLoader_NCCH::LoadSectionExeFS(File::IOFile& file, const char* name,
141 std::vector<u8>& buffer) { 141 std::vector<u8>& buffer) {
142 142
143 // Iterate through the ExeFs archive until we find the .code file... 143 // 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
183 * @param file Handle to file to read from 183 * @param file Handle to file to read from
184 * @return ResultStatus result of function 184 * @return ResultStatus result of function
185 */ 185 */
186const ResultStatus AppLoader_NCCH::LoadRomFS(File::IOFile& file) { 186ResultStatus AppLoader_NCCH::LoadRomFS(File::IOFile& file) {
187 // Check if the NCCH has a RomFS... 187 // Check if the NCCH has a RomFS...
188 if (ncch_header.romfs_offset != 0 && ncch_header.romfs_size != 0) { 188 if (ncch_header.romfs_offset != 0 && ncch_header.romfs_size != 0) {
189 u32 romfs_offset = ncch_offset + (ncch_header.romfs_offset * kBlockSize) + 0x1000; 189 u32 romfs_offset = ncch_offset + (ncch_header.romfs_offset * kBlockSize) + 0x1000;
@@ -210,7 +210,7 @@ const ResultStatus AppLoader_NCCH::LoadRomFS(File::IOFile& file) {
210 * @todo Move NCSD parsing out of here and create a separate function for loading these 210 * @todo Move NCSD parsing out of here and create a separate function for loading these
211 * @return True on success, otherwise false 211 * @return True on success, otherwise false
212 */ 212 */
213const ResultStatus AppLoader_NCCH::Load() { 213ResultStatus AppLoader_NCCH::Load() {
214 INFO_LOG(LOADER, "Loading NCCH file %s...", filename.c_str()); 214 INFO_LOG(LOADER, "Loading NCCH file %s...", filename.c_str());
215 215
216 if (is_loaded) 216 if (is_loaded)
diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h
index 939b144a6..126eb4c80 100644
--- a/src/core/loader/ncch.h
+++ b/src/core/loader/ncch.h
@@ -147,14 +147,14 @@ namespace Loader {
147/// Loads an NCCH file (e.g. from a CCI, or the first NCCH in a CXI) 147/// Loads an NCCH file (e.g. from a CCI, or the first NCCH in a CXI)
148class AppLoader_NCCH : public AppLoader { 148class AppLoader_NCCH : public AppLoader {
149public: 149public:
150 AppLoader_NCCH(std::string& filename); 150 AppLoader_NCCH(const std::string& filename);
151 ~AppLoader_NCCH(); 151 ~AppLoader_NCCH();
152 152
153 /** 153 /**
154 * Load the application 154 * Load the application
155 * @return ResultStatus result of function 155 * @return ResultStatus result of function
156 */ 156 */
157 const ResultStatus Load(); 157 ResultStatus Load();
158 158
159private: 159private:
160 160
@@ -165,21 +165,20 @@ private:
165 * @param buffer Buffer to read section into. 165 * @param buffer Buffer to read section into.
166 * @return ResultStatus result of function 166 * @return ResultStatus result of function
167 */ 167 */
168 const ResultStatus LoadSectionExeFS(File::IOFile& file, const char* name, 168 ResultStatus LoadSectionExeFS(File::IOFile& file, const char* name, std::vector<u8>& buffer);
169 std::vector<u8>& buffer);
170 169
171 /** 170 /**
172 * Reads RomFS of an NCCH file into AppLoader 171 * Reads RomFS of an NCCH file into AppLoader
173 * @param file Handle to file to read from 172 * @param file Handle to file to read from
174 * @return ResultStatus result of function 173 * @return ResultStatus result of function
175 */ 174 */
176 const ResultStatus LoadRomFS(File::IOFile& file); 175 ResultStatus LoadRomFS(File::IOFile& file);
177 176
178 /** 177 /**
179 * Loads .code section into memory for booting 178 * Loads .code section into memory for booting
180 * @return ResultStatus result of function 179 * @return ResultStatus result of function
181 */ 180 */
182 const ResultStatus LoadExec() const; 181 ResultStatus LoadExec() const;
183 182
184 std::string filename; 183 std::string filename;
185 bool is_loaded; 184 bool is_loaded;