Loader: Keep a reference to the file and pass it to the correct AppLoader, instead of loading it multiple times.

This commit is contained in:
Emmanuel Gil Peyrot 2015-01-06 21:30:40 +00:00
parent 2d63df90a9
commit b5237e885d
8 changed files with 130 additions and 190 deletions

View file

@ -7,6 +7,7 @@
#include <vector>
#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<FileUtil::IOFile>&& file) : file(std::move(file)) { }
virtual ~AppLoader() { }
/**
@ -93,6 +94,10 @@ public:
virtual ResultStatus ReadRomFS(std::vector<u8>& buffer) const {
return ResultStatus::ErrorNotImplemented;
}
protected:
std::unique_ptr<FileUtil::IOFile> file;
bool is_loaded = false;
};
/**