diff options
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2015-01-06 22:30:40 +0100 |
---|---|---|
committer | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2015-01-15 22:21:26 +0100 |
commit | b5237e885df72f6c37532fc8af9573966e7b07e5 (patch) | |
tree | fdfd4da299cc2779f35fcc30e770b85b9e710166 /src/core/loader/loader.cpp | |
parent | Loader: Initialize the default NCCH values in the class declaration, not in the constructor. (diff) | |
download | yuzu-b5237e885df72f6c37532fc8af9573966e7b07e5.tar yuzu-b5237e885df72f6c37532fc8af9573966e7b07e5.tar.gz yuzu-b5237e885df72f6c37532fc8af9573966e7b07e5.tar.bz2 yuzu-b5237e885df72f6c37532fc8af9573966e7b07e5.tar.lz yuzu-b5237e885df72f6c37532fc8af9573966e7b07e5.tar.xz yuzu-b5237e885df72f6c37532fc8af9573966e7b07e5.tar.zst yuzu-b5237e885df72f6c37532fc8af9573966e7b07e5.zip |
Diffstat (limited to '')
-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) { ResultStatus LoadFile(const std::string& filename) { LOG_INFO(Loader, "Loading file %s...", filename.c_str()); + std::unique_ptr<FileUtil::IOFile> file(new FileUtil::IOFile(filename, "rb")); + if (!file->IsOpen()) + return ResultStatus::Error; + switch (IdentifyFile(filename)) { //3DSX file format... case FileType::THREEDSX: - return AppLoader_THREEDSX(filename).Load(); + return AppLoader_THREEDSX(std::move(file)).Load(); // Standard ELF file format... case FileType::ELF: - return AppLoader_ELF(filename).Load(); + return AppLoader_ELF(std::move(file)).Load(); // NCCH/NCSD container formats... case FileType::CXI: case FileType::CCI: { - AppLoader_NCCH app_loader(filename); + AppLoader_NCCH app_loader(std::move(file)); // Load application and RomFS if (ResultStatus::Success == app_loader.Load()) { @@ -83,16 +87,11 @@ ResultStatus LoadFile(const std::string& filename) { // Raw BIN file format... case FileType::BIN: { - LOG_INFO(Loader, "Loading BIN file %s...", filename.c_str()); - - FileUtil::IOFile file(filename, "rb"); - - if (file.IsOpen()) { - file.ReadBytes(Memory::GetPointer(Memory::EXEFS_CODE_VADDR), (size_t)file.GetSize()); - Kernel::LoadExec(Memory::EXEFS_CODE_VADDR); - } else { + size_t size = (size_t)file->GetSize(); + if (file->ReadBytes(Memory::GetPointer(Memory::EXEFS_CODE_VADDR), size) != size) return ResultStatus::Error; - } + + Kernel::LoadExec(Memory::EXEFS_CODE_VADDR); return ResultStatus::Success; } |