summaryrefslogtreecommitdiffstats
path: root/src/core/loader/loader.h
diff options
context:
space:
mode:
authorbunnei <ericbunnie@gmail.com>2014-06-19 00:58:09 +0200
committerbunnei <ericbunnie@gmail.com>2014-06-25 01:29:58 +0200
commit7889cafc76ac99b8509fa3cd1558a09f8a7e5f91 (patch)
treee6ffea9ec1c334bfca13404c47a2191fd281554c /src/core/loader/loader.h
parentNCCH: Changed decompression to load .code directly into memory rather than an intermediate buffer. (diff)
downloadyuzu-7889cafc76ac99b8509fa3cd1558a09f8a7e5f91.tar
yuzu-7889cafc76ac99b8509fa3cd1558a09f8a7e5f91.tar.gz
yuzu-7889cafc76ac99b8509fa3cd1558a09f8a7e5f91.tar.bz2
yuzu-7889cafc76ac99b8509fa3cd1558a09f8a7e5f91.tar.lz
yuzu-7889cafc76ac99b8509fa3cd1558a09f8a7e5f91.tar.xz
yuzu-7889cafc76ac99b8509fa3cd1558a09f8a7e5f91.tar.zst
yuzu-7889cafc76ac99b8509fa3cd1558a09f8a7e5f91.zip
Diffstat (limited to 'src/core/loader/loader.h')
-rw-r--r--src/core/loader/loader.h103
1 files changed, 91 insertions, 12 deletions
diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h
index 979003553..42caa29e6 100644
--- a/src/core/loader/loader.h
+++ b/src/core/loader/loader.h
@@ -4,6 +4,8 @@
#pragma once
+#include <vector>
+
#include "common/common.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -11,16 +13,94 @@
namespace Loader {
-enum FileType {
- FILETYPE_ERROR,
+/// File types supported by CTR
+enum class FileType {
+ Error,
+ Unknown,
+ CCI,
+ CXI,
+ CIA,
+ ELF,
+};
+
+/// Return type for functions in Loader namespace
+enum class ResultStatus {
+ Success,
+ Error,
+ ErrorInvalidFormat,
+ ErrorNotImplemented,
+ ErrorNotLoaded,
+ ErrorAlreadyLoaded,
+};
+
+/// Interface for loading an application
+class AppLoader : NonCopyable {
+public:
+ AppLoader() { }
+ virtual ~AppLoader() { }
+
+ /**
+ * Load the application
+ * @return ResultStatus result of function
+ */
+ virtual const ResultStatus Load() = 0;
+
+ /**
+ * Get the code (typically .code section) of the application
+ * @param error ResultStatus result of function
+ * @return Reference to code buffer
+ */
+ virtual const std::vector<u8>& GetCode(ResultStatus& error) const {
+ error = ResultStatus::ErrorNotImplemented;
+ return code;
+ }
+
+ /**
+ * Get the icon (typically .icon section) of the application
+ * @param error ResultStatus result of function
+ * @return Reference to icon buffer
+ */
+ virtual const std::vector<u8>& GetIcon(ResultStatus& error) const {
+ error = ResultStatus::ErrorNotImplemented;
+ return icon;
+ }
+
+ /**
+ * Get the banner (typically .banner section) of the application
+ * @param error ResultStatus result of function
+ * @return Reference to banner buffer
+ */
+ virtual const std::vector<u8>& GetBanner(ResultStatus& error) const {
+ error = ResultStatus::ErrorNotImplemented;
+ return banner;
+ }
+
+ /**
+ * Get the logo (typically .logo section) of the application
+ * @param error ResultStatus result of function
+ * @return Reference to logo buffer
+ */
+ virtual const std::vector<u8>& GetLogo(ResultStatus& error) const {
+ error = ResultStatus::ErrorNotImplemented;
+ return logo;
+ }
- FILETYPE_CTR_CCI,
- FILETYPE_CTR_CIA,
- FILETYPE_CTR_CXI,
- FILETYPE_CTR_ELF,
- FILETYPE_CTR_BIN,
+ /**
+ * Get the RomFs archive of the application
+ * @param error ResultStatus result of function
+ * @return Reference to RomFs archive buffer
+ */
+ virtual const std::vector<u8>& GetRomFs(ResultStatus error) const {
+ error = ResultStatus::ErrorNotImplemented;
+ return romfs;
+ }
- FILETYPE_UNKNOWN
+protected:
+ std::vector<u8> code; ///< ExeFS .code section
+ std::vector<u8> icon; ///< ExeFS .icon section
+ std::vector<u8> banner; ///< ExeFS .banner section
+ std::vector<u8> logo; ///< ExeFS .logo section
+ std::vector<u8> romfs; ///< RomFs archive
};
/**
@@ -28,14 +108,13 @@ enum FileType {
* @param filename String filename of bootable file
* @return FileType of file
*/
-FileType IdentifyFile(std::string &filename);
+const FileType IdentifyFile(const std::string &filename);
/**
* Identifies and loads a bootable file
* @param filename String filename of bootable file
- * @param error_string Point to string to put error message if an error has occurred
- * @return True on success, otherwise false
+ * @return ResultStatus result of function
*/
-bool LoadFile(std::string &filename, std::string *error_string);
+const ResultStatus LoadFile(std::string& filename);
} // namespace