From b5237e885df72f6c37532fc8af9573966e7b07e5 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 6 Jan 2015 21:30:40 +0000 Subject: Loader: Keep a reference to the file and pass it to the correct AppLoader, instead of loading it multiple times. --- src/core/loader/loader.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/core/loader/loader.h') diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h index ec5534d41..b4fc8636d 100644 --- a/src/core/loader/loader.h +++ b/src/core/loader/loader.h @@ -7,6 +7,7 @@ #include #include "common/common.h" +#include "common/file_util.h" //////////////////////////////////////////////////////////////////////////////////////////////////// // Loader namespace @@ -40,7 +41,7 @@ enum class ResultStatus { /// Interface for loading an application class AppLoader : NonCopyable { public: - AppLoader() { } + AppLoader(std::unique_ptr&& file) : file(std::move(file)) { } virtual ~AppLoader() { } /** @@ -93,6 +94,10 @@ public: virtual ResultStatus ReadRomFS(std::vector& buffer) const { return ResultStatus::ErrorNotImplemented; } + +protected: + std::unique_ptr file; + bool is_loaded = false; }; /** -- cgit v1.2.3 From 82ec17db7df53ed1c376d1cdaa9a6587719a546d Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 6 Jan 2015 23:10:13 +0000 Subject: Loader: Guess filetype from the magic, or fallback to the extension. --- src/core/loader/loader.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/core/loader/loader.h') diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h index b4fc8636d..7456b019b 100644 --- a/src/core/loader/loader.h +++ b/src/core/loader/loader.h @@ -38,6 +38,10 @@ enum class ResultStatus { ErrorMemoryAllocationFailed, }; +static u32 MakeMagic(char a, char b, char c, char d) { + return a | b << 8 | c << 16 | d << 24; +} + /// Interface for loading an application class AppLoader : NonCopyable { public: @@ -100,13 +104,6 @@ protected: bool is_loaded = false; }; -/** - * Identifies the type of a bootable file - * @param filename String filename of bootable file - * @return FileType of file - */ -FileType IdentifyFile(const std::string &filename); - /** * Identifies and loads a bootable file * @param filename String filename of bootable file -- cgit v1.2.3