diff options
| author | 2018-01-20 16:26:20 -0500 | |
|---|---|---|
| committer | 2018-01-20 16:26:20 -0500 | |
| commit | ff883cc56382425d4c4f572ff659ec7df6fc2cec (patch) | |
| tree | 3b7e44f33dac0384d412fed61de3c5ad40db137d /src/core/loader/loader.cpp | |
| parent | Port citra #3352 to yuzu (#103) (diff) | |
| parent | loader: Clean up ctors and includes. (diff) | |
| download | yuzu-ff883cc56382425d4c4f572ff659ec7df6fc2cec.tar.gz yuzu-ff883cc56382425d4c4f572ff659ec7df6fc2cec.tar.xz yuzu-ff883cc56382425d4c4f572ff659ec7df6fc2cec.zip | |
Merge pull request #119 from bunnei/desconstucted-loader
Separate NSO loading from DesconstuctedRomLoader
Diffstat (limited to 'src/core/loader/loader.cpp')
| -rw-r--r-- | src/core/loader/loader.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp index 92defd381..2ec08506d 100644 --- a/src/core/loader/loader.cpp +++ b/src/core/loader/loader.cpp | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | 1 | // Copyright 2018 yuzu emulator team |
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| @@ -7,12 +7,11 @@ | |||
| 7 | #include "common/logging/log.h" | 7 | #include "common/logging/log.h" |
| 8 | #include "common/string_util.h" | 8 | #include "common/string_util.h" |
| 9 | #include "core/hle/kernel/process.h" | 9 | #include "core/hle/kernel/process.h" |
| 10 | #include "core/loader/deconstructed_rom_directory.h" | ||
| 10 | #include "core/loader/elf.h" | 11 | #include "core/loader/elf.h" |
| 11 | #include "core/loader/nro.h" | 12 | #include "core/loader/nro.h" |
| 12 | #include "core/loader/nso.h" | 13 | #include "core/loader/nso.h" |
| 13 | 14 | ||
| 14 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 15 | |||
| 16 | namespace Loader { | 15 | namespace Loader { |
| 17 | 16 | ||
| 18 | const std::initializer_list<Kernel::AddressMapping> default_address_mappings = { | 17 | const std::initializer_list<Kernel::AddressMapping> default_address_mappings = { |
| @@ -21,14 +20,15 @@ const std::initializer_list<Kernel::AddressMapping> default_address_mappings = { | |||
| 21 | {0x1F000000, 0x600000, false}, // entire VRAM | 20 | {0x1F000000, 0x600000, false}, // entire VRAM |
| 22 | }; | 21 | }; |
| 23 | 22 | ||
| 24 | FileType IdentifyFile(FileUtil::IOFile& file) { | 23 | FileType IdentifyFile(FileUtil::IOFile& file, const std::string& filepath) { |
| 25 | FileType type; | 24 | FileType type; |
| 26 | 25 | ||
| 27 | #define CHECK_TYPE(loader) \ | 26 | #define CHECK_TYPE(loader) \ |
| 28 | type = AppLoader_##loader::IdentifyType(file); \ | 27 | type = AppLoader_##loader::IdentifyType(file, filepath); \ |
| 29 | if (FileType::Error != type) \ | 28 | if (FileType::Error != type) \ |
| 30 | return type; | 29 | return type; |
| 31 | 30 | ||
| 31 | CHECK_TYPE(DeconstructedRomDirectory) | ||
| 32 | CHECK_TYPE(ELF) | 32 | CHECK_TYPE(ELF) |
| 33 | CHECK_TYPE(NSO) | 33 | CHECK_TYPE(NSO) |
| 34 | CHECK_TYPE(NRO) | 34 | CHECK_TYPE(NRO) |
| @@ -45,13 +45,13 @@ FileType IdentifyFile(const std::string& file_name) { | |||
| 45 | return FileType::Unknown; | 45 | return FileType::Unknown; |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | return IdentifyFile(file); | 48 | return IdentifyFile(file, file_name); |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | FileType GuessFromExtension(const std::string& extension_) { | 51 | FileType GuessFromExtension(const std::string& extension_) { |
| 52 | std::string extension = Common::ToLower(extension_); | 52 | std::string extension = Common::ToLower(extension_); |
| 53 | 53 | ||
| 54 | if (extension == ".elf" || extension == ".axf") | 54 | if (extension == ".elf") |
| 55 | return FileType::ELF; | 55 | return FileType::ELF; |
| 56 | else if (extension == ".nro") | 56 | else if (extension == ".nro") |
| 57 | return FileType::NRO; | 57 | return FileType::NRO; |
| @@ -69,6 +69,8 @@ const char* GetFileTypeString(FileType type) { | |||
| 69 | return "NRO"; | 69 | return "NRO"; |
| 70 | case FileType::NSO: | 70 | case FileType::NSO: |
| 71 | return "NSO"; | 71 | return "NSO"; |
| 72 | case FileType::DeconstructedRomDirectory: | ||
| 73 | return "Directory"; | ||
| 72 | case FileType::Error: | 74 | case FileType::Error: |
| 73 | case FileType::Unknown: | 75 | case FileType::Unknown: |
| 74 | break; | 76 | break; |
| @@ -102,6 +104,10 @@ static std::unique_ptr<AppLoader> GetFileLoader(FileUtil::IOFile&& file, FileTyp | |||
| 102 | case FileType::NRO: | 104 | case FileType::NRO: |
| 103 | return std::make_unique<AppLoader_NRO>(std::move(file), filepath); | 105 | return std::make_unique<AppLoader_NRO>(std::move(file), filepath); |
| 104 | 106 | ||
| 107 | // NX deconstructed ROM directory. | ||
| 108 | case FileType::DeconstructedRomDirectory: | ||
| 109 | return std::make_unique<AppLoader_DeconstructedRomDirectory>(std::move(file), filepath); | ||
| 110 | |||
| 105 | default: | 111 | default: |
| 106 | return nullptr; | 112 | return nullptr; |
| 107 | } | 113 | } |
| @@ -117,7 +123,7 @@ std::unique_ptr<AppLoader> GetLoader(const std::string& filename) { | |||
| 117 | std::string filename_filename, filename_extension; | 123 | std::string filename_filename, filename_extension; |
| 118 | Common::SplitPath(filename, nullptr, &filename_filename, &filename_extension); | 124 | Common::SplitPath(filename, nullptr, &filename_filename, &filename_extension); |
| 119 | 125 | ||
| 120 | FileType type = IdentifyFile(file); | 126 | FileType type = IdentifyFile(file, filename); |
| 121 | FileType filename_type = GuessFromExtension(filename_extension); | 127 | FileType filename_type = GuessFromExtension(filename_extension); |
| 122 | 128 | ||
| 123 | if (type != filename_type) { | 129 | if (type != filename_type) { |