diff options
| author | 2015-01-06 21:30:40 +0000 | |
|---|---|---|
| committer | 2015-01-15 21:21:26 +0000 | |
| commit | b5237e885df72f6c37532fc8af9573966e7b07e5 (patch) | |
| tree | fdfd4da299cc2779f35fcc30e770b85b9e710166 /src/core/loader/loader.cpp | |
| parent | Loader: Initialize the default NCCH values in the class declaration, not in t... (diff) | |
| download | yuzu-b5237e885df72f6c37532fc8af9573966e7b07e5.tar.gz yuzu-b5237e885df72f6c37532fc8af9573966e7b07e5.tar.xz yuzu-b5237e885df72f6c37532fc8af9573966e7b07e5.zip | |
Loader: Keep a reference to the file and pass it to the correct AppLoader, instead of loading it multiple times.
Diffstat (limited to 'src/core/loader/loader.cpp')
| -rw-r--r-- | src/core/loader/loader.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp index 32196a1dc..fd32b7b20 100644 --- a/src/core/loader/loader.cpp +++ b/src/core/loader/loader.cpp | |||
| @@ -56,20 +56,24 @@ FileType IdentifyFile(const std::string &filename) { | |||
| 56 | ResultStatus LoadFile(const std::string& filename) { | 56 | ResultStatus LoadFile(const std::string& filename) { |
| 57 | LOG_INFO(Loader, "Loading file %s...", filename.c_str()); | 57 | LOG_INFO(Loader, "Loading file %s...", filename.c_str()); |
| 58 | 58 | ||
| 59 | std::unique_ptr<FileUtil::IOFile> file(new FileUtil::IOFile(filename, "rb")); | ||
| 60 | if (!file->IsOpen()) | ||
| 61 | return ResultStatus::Error; | ||
| 62 | |||
| 59 | switch (IdentifyFile(filename)) { | 63 | switch (IdentifyFile(filename)) { |
| 60 | 64 | ||
| 61 | //3DSX file format... | 65 | //3DSX file format... |
| 62 | case FileType::THREEDSX: | 66 | case FileType::THREEDSX: |
| 63 | return AppLoader_THREEDSX(filename).Load(); | 67 | return AppLoader_THREEDSX(std::move(file)).Load(); |
| 64 | 68 | ||
| 65 | // Standard ELF file format... | 69 | // Standard ELF file format... |
| 66 | case FileType::ELF: | 70 | case FileType::ELF: |
| 67 | return AppLoader_ELF(filename).Load(); | 71 | return AppLoader_ELF(std::move(file)).Load(); |
| 68 | 72 | ||
| 69 | // NCCH/NCSD container formats... | 73 | // NCCH/NCSD container formats... |
| 70 | case FileType::CXI: | 74 | case FileType::CXI: |
| 71 | case FileType::CCI: { | 75 | case FileType::CCI: { |
| 72 | AppLoader_NCCH app_loader(filename); | 76 | AppLoader_NCCH app_loader(std::move(file)); |
| 73 | 77 | ||
| 74 | // Load application and RomFS | 78 | // Load application and RomFS |
| 75 | if (ResultStatus::Success == app_loader.Load()) { | 79 | if (ResultStatus::Success == app_loader.Load()) { |
| @@ -83,16 +87,11 @@ ResultStatus LoadFile(const std::string& filename) { | |||
| 83 | // Raw BIN file format... | 87 | // Raw BIN file format... |
| 84 | case FileType::BIN: | 88 | case FileType::BIN: |
| 85 | { | 89 | { |
| 86 | LOG_INFO(Loader, "Loading BIN file %s...", filename.c_str()); | 90 | size_t size = (size_t)file->GetSize(); |
| 87 | 91 | if (file->ReadBytes(Memory::GetPointer(Memory::EXEFS_CODE_VADDR), size) != size) | |
| 88 | FileUtil::IOFile file(filename, "rb"); | ||
| 89 | |||
| 90 | if (file.IsOpen()) { | ||
| 91 | file.ReadBytes(Memory::GetPointer(Memory::EXEFS_CODE_VADDR), (size_t)file.GetSize()); | ||
| 92 | Kernel::LoadExec(Memory::EXEFS_CODE_VADDR); | ||
| 93 | } else { | ||
| 94 | return ResultStatus::Error; | 92 | return ResultStatus::Error; |
| 95 | } | 93 | |
| 94 | Kernel::LoadExec(Memory::EXEFS_CODE_VADDR); | ||
| 96 | return ResultStatus::Success; | 95 | return ResultStatus::Success; |
| 97 | } | 96 | } |
| 98 | 97 | ||