summaryrefslogtreecommitdiffstats
path: root/src/core/loader/loader.cpp
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2016-05-18 00:06:33 +0200
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2016-05-21 18:09:56 +0200
commit8fc9c0312660aa8b74a1251f02dfedc84da5b96b (patch)
tree490fc1f96a96654b59c933c864aa792161399cbb /src/core/loader/loader.cpp
parentAppveyor: Restore working directory after test_script (#1835) (diff)
downloadyuzu-8fc9c0312660aa8b74a1251f02dfedc84da5b96b.tar
yuzu-8fc9c0312660aa8b74a1251f02dfedc84da5b96b.tar.gz
yuzu-8fc9c0312660aa8b74a1251f02dfedc84da5b96b.tar.bz2
yuzu-8fc9c0312660aa8b74a1251f02dfedc84da5b96b.tar.lz
yuzu-8fc9c0312660aa8b74a1251f02dfedc84da5b96b.tar.xz
yuzu-8fc9c0312660aa8b74a1251f02dfedc84da5b96b.tar.zst
yuzu-8fc9c0312660aa8b74a1251f02dfedc84da5b96b.zip
Diffstat (limited to 'src/core/loader/loader.cpp')
-rw-r--r--src/core/loader/loader.cpp50
1 files changed, 7 insertions, 43 deletions
diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp
index af3f62248..c82688026 100644
--- a/src/core/loader/loader.cpp
+++ b/src/core/loader/loader.cpp
@@ -8,9 +8,7 @@
#include "common/logging/log.h"
#include "common/string_util.h"
-#include "core/file_sys/archive_romfs.h"
#include "core/hle/kernel/process.h"
-#include "core/hle/service/fs/archive.h"
#include "core/loader/3dsx.h"
#include "core/loader/elf.h"
#include "core/loader/ncch.h"
@@ -67,6 +65,9 @@ FileType GuessFromExtension(const std::string& extension_) {
if (extension == ".3dsx")
return FileType::THREEDSX;
+ if (extension == ".cia")
+ return FileType::CIA;
+
return FileType::Unknown;
}
@@ -108,15 +109,15 @@ std::unique_ptr<AppLoader> GetLoader(FileUtil::IOFile&& file, FileType type,
return std::make_unique<AppLoader_NCCH>(std::move(file), filepath);
default:
- return std::unique_ptr<AppLoader>();
+ return nullptr;
}
}
-ResultStatus LoadFile(const std::string& filename) {
+std::unique_ptr<AppLoader> GetFileLoader(const std::string& filename) {
FileUtil::IOFile file(filename, "rb");
if (!file.IsOpen()) {
LOG_ERROR(Loader, "Failed to load file %s", filename.c_str());
- return ResultStatus::Error;
+ return nullptr;
}
std::string filename_filename, filename_extension;
@@ -133,44 +134,7 @@ ResultStatus LoadFile(const std::string& filename) {
LOG_INFO(Loader, "Loading file %s as %s...", filename.c_str(), GetFileTypeString(type));
- std::unique_ptr<AppLoader> app_loader = GetLoader(std::move(file), type, filename_filename, filename);
-
- switch (type) {
-
- // 3DSX file format...
- // or NCCH/NCSD container formats...
- case FileType::THREEDSX:
- case FileType::CXI:
- case FileType::CCI:
- {
- // Load application and RomFS
- ResultStatus result = app_loader->Load();
- if (ResultStatus::Success == result) {
- Service::FS::RegisterArchiveType(std::make_unique<FileSys::ArchiveFactory_RomFS>(*app_loader), Service::FS::ArchiveIdCode::RomFS);
- return ResultStatus::Success;
- }
- return result;
- }
-
- // Standard ELF file format...
- case FileType::ELF:
- return app_loader->Load();
-
- // CIA file format...
- case FileType::CIA:
- return ResultStatus::ErrorNotImplemented;
-
- // Error occurred durring IdentifyFile...
- case FileType::Error:
-
- // IdentifyFile could know identify file type...
- case FileType::Unknown:
- {
- LOG_CRITICAL(Loader, "File %s is of unknown type.", filename.c_str());
- return ResultStatus::ErrorInvalidFormat;
- }
- }
- return ResultStatus::Error;
+ return GetLoader(std::move(file), type, filename_filename, filename);
}
} // namespace Loader