summaryrefslogtreecommitdiffstats
path: root/src/core/loader
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-01-20 20:55:54 +0100
committerbunnei <bunneidev@gmail.com>2018-01-20 20:59:44 +0100
commit023aef053c96c92c9ea15d067f7d2cb7150585d6 (patch)
tree6b8a4c0dc9aae92ff172a2715969b8551e9d14b1 /src/core/loader
parentnso: Remove code specific to directory loading. (diff)
downloadyuzu-023aef053c96c92c9ea15d067f7d2cb7150585d6.tar
yuzu-023aef053c96c92c9ea15d067f7d2cb7150585d6.tar.gz
yuzu-023aef053c96c92c9ea15d067f7d2cb7150585d6.tar.bz2
yuzu-023aef053c96c92c9ea15d067f7d2cb7150585d6.tar.lz
yuzu-023aef053c96c92c9ea15d067f7d2cb7150585d6.tar.xz
yuzu-023aef053c96c92c9ea15d067f7d2cb7150585d6.tar.zst
yuzu-023aef053c96c92c9ea15d067f7d2cb7150585d6.zip
Diffstat (limited to 'src/core/loader')
-rw-r--r--src/core/loader/elf.cpp2
-rw-r--r--src/core/loader/elf.h5
-rw-r--r--src/core/loader/loader.cpp10
-rw-r--r--src/core/loader/loader.h3
-rw-r--r--src/core/loader/nro.cpp2
-rw-r--r--src/core/loader/nro.h6
-rw-r--r--src/core/loader/nso.cpp3
-rw-r--r--src/core/loader/nso.h7
8 files changed, 19 insertions, 19 deletions
diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp
index 9ba913dbe..a41d0b94a 100644
--- a/src/core/loader/elf.cpp
+++ b/src/core/loader/elf.cpp
@@ -364,7 +364,7 @@ SectionID ElfReader::GetSectionByName(const char* name, int firstSection) const
namespace Loader {
-FileType AppLoader_ELF::IdentifyType(FileUtil::IOFile& file) {
+FileType AppLoader_ELF::IdentifyType(FileUtil::IOFile& file, const std::string&) {
static constexpr u16 ELF_MACHINE_ARM{0x28};
u32 magic = 0;
diff --git a/src/core/loader/elf.h b/src/core/loader/elf.h
index 113da5917..a5158338f 100644
--- a/src/core/loader/elf.h
+++ b/src/core/loader/elf.h
@@ -22,12 +22,13 @@ public:
/**
* Returns the type of the file
* @param file FileUtil::IOFile open file
+ * @param filepath Path of the file that we are opening.
* @return FileType found, or FileType::Error if this loader doesn't know it
*/
- static FileType IdentifyType(FileUtil::IOFile& file);
+ static FileType IdentifyType(FileUtil::IOFile& file, const std::string& filepath);
FileType GetFileType() override {
- return IdentifyType(file);
+ return IdentifyType(file, filename);
}
ResultStatus Load(Kernel::SharedPtr<Kernel::Process>& process) override;
diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp
index 92defd381..2ecccdd4f 100644
--- a/src/core/loader/loader.cpp
+++ b/src/core/loader/loader.cpp
@@ -21,11 +21,11 @@ const std::initializer_list<Kernel::AddressMapping> default_address_mappings = {
{0x1F000000, 0x600000, false}, // entire VRAM
};
-FileType IdentifyFile(FileUtil::IOFile& file) {
+FileType IdentifyFile(FileUtil::IOFile& file, const std::string& filepath) {
FileType type;
#define CHECK_TYPE(loader) \
- type = AppLoader_##loader::IdentifyType(file); \
+ type = AppLoader_##loader::IdentifyType(file, filepath); \
if (FileType::Error != type) \
return type;
@@ -45,13 +45,13 @@ FileType IdentifyFile(const std::string& file_name) {
return FileType::Unknown;
}
- return IdentifyFile(file);
+ return IdentifyFile(file, file_name);
}
FileType GuessFromExtension(const std::string& extension_) {
std::string extension = Common::ToLower(extension_);
- if (extension == ".elf" || extension == ".axf")
+ if (extension == ".elf")
return FileType::ELF;
else if (extension == ".nro")
return FileType::NRO;
@@ -117,7 +117,7 @@ std::unique_ptr<AppLoader> GetLoader(const std::string& filename) {
std::string filename_filename, filename_extension;
Common::SplitPath(filename, nullptr, &filename_filename, &filename_extension);
- FileType type = IdentifyFile(file);
+ FileType type = IdentifyFile(file, filename);
FileType filename_type = GuessFromExtension(filename_extension);
if (type != filename_type) {
diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h
index dd6bb4e64..f7828b7ad 100644
--- a/src/core/loader/loader.h
+++ b/src/core/loader/loader.h
@@ -37,9 +37,10 @@ enum class FileType {
/**
* Identifies the type of a bootable file based on the magic value in its header.
* @param file open file
+ * @param filepath Path of the file that we are opening.
* @return FileType of file
*/
-FileType IdentifyFile(FileUtil::IOFile& file);
+FileType IdentifyFile(FileUtil::IOFile& file, const std::string& filepath);
/**
* Identifies the type of a bootable file based on the magic value in its header.
diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp
index 6864a1926..ac730f8a3 100644
--- a/src/core/loader/nro.cpp
+++ b/src/core/loader/nro.cpp
@@ -45,7 +45,7 @@ struct ModHeader {
};
static_assert(sizeof(ModHeader) == 0x1c, "ModHeader has incorrect size.");
-FileType AppLoader_NRO::IdentifyType(FileUtil::IOFile& file) {
+FileType AppLoader_NRO::IdentifyType(FileUtil::IOFile& file, const std::string&) {
// Read NSO header
NroHeader nro_header{};
file.Seek(0, SEEK_SET);
diff --git a/src/core/loader/nro.h b/src/core/loader/nro.h
index e20fa1555..ae4c84fb7 100644
--- a/src/core/loader/nro.h
+++ b/src/core/loader/nro.h
@@ -4,7 +4,6 @@
#pragma once
-#include <map>
#include <string>
#include "common/common_types.h"
#include "common/file_util.h"
@@ -23,12 +22,13 @@ public:
/**
* Returns the type of the file
* @param file FileUtil::IOFile open file
+ * @param filepath Path of the file that we are opening.
* @return FileType found, or FileType::Error if this loader doesn't know it
*/
- static FileType IdentifyType(FileUtil::IOFile& file);
+ static FileType IdentifyType(FileUtil::IOFile& file, const std::string& filepath);
FileType GetFileType() override {
- return IdentifyType(file);
+ return IdentifyType(file, filepath);
}
ResultStatus Load(Kernel::SharedPtr<Kernel::Process>& process) override;
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp
index 77b4f93eb..c80f2a100 100644
--- a/src/core/loader/nso.cpp
+++ b/src/core/loader/nso.cpp
@@ -4,7 +4,6 @@
#include <vector>
#include <lz4.h>
-
#include "common/common_funcs.h"
#include "common/logging/log.h"
#include "common/swap.h"
@@ -47,7 +46,7 @@ struct ModHeader {
};
static_assert(sizeof(ModHeader) == 0x1c, "ModHeader has incorrect size.");
-FileType AppLoader_NSO::IdentifyType(FileUtil::IOFile& file) {
+FileType AppLoader_NSO::IdentifyType(FileUtil::IOFile& file, const std::string&) {
u32 magic = 0;
file.Seek(0, SEEK_SET);
if (1 != file.ReadArray<u32>(&magic, 1)) {
diff --git a/src/core/loader/nso.h b/src/core/loader/nso.h
index 44d6dbbd9..f6a2b214f 100644
--- a/src/core/loader/nso.h
+++ b/src/core/loader/nso.h
@@ -4,7 +4,6 @@
#pragma once
-#include <map>
#include <string>
#include "common/common_types.h"
#include "common/file_util.h"
@@ -23,12 +22,13 @@ public:
/**
* Returns the type of the file
* @param file FileUtil::IOFile open file
+ * @param filepath Path of the file that we are opening.
* @return FileType found, or FileType::Error if this loader doesn't know it
*/
- static FileType IdentifyType(FileUtil::IOFile& file);
+ static FileType IdentifyType(FileUtil::IOFile& file, const std::string& filepath);
FileType GetFileType() override {
- return IdentifyType(file);
+ return IdentifyType(file, filepath);
}
static VAddr LoadModule(const std::string& path, VAddr load_base);
@@ -36,7 +36,6 @@ public:
ResultStatus Load(Kernel::SharedPtr<Kernel::Process>& process) override;
private:
-
std::string filepath;
};