Skip to content

VERY experimental Nintendo Switch 2 emulator

C++

Loader: Add a GetFileType method to get the type of a loaded file

Emmanuel Gil Peyrot85a4eea460af
diff --git a/src/core/loader/3dsx.h b/src/core/loader/3dsx.h
index 3ee6867033..90b20c61c3 100644
--- a/src/core/loader/3dsx.h
+++ b/src/core/loader/3dsx.h
@@ -27,6 +27,14 @@ public:
*/
static FileType IdentifyType(FileUtil::IOFile& file);
+ /**
+ * Returns the type of this file
+ * @return FileType corresponding to the loaded file
+ */
+ FileType GetFileType() override {
+ return IdentifyType(file);
+ }
+
/**
* Load the bootable file
* @return ResultStatus result of function
diff --git a/src/core/loader/elf.h b/src/core/loader/elf.h
index c6a5ebe991..cb3724f9d3 100644
--- a/src/core/loader/elf.h
+++ b/src/core/loader/elf.h
@@ -27,6 +27,14 @@ public:
*/
static FileType IdentifyType(FileUtil::IOFile& file);
+ /**
+ * Returns the type of this file
+ * @return FileType corresponding to the loaded file
+ */
+ FileType GetFileType() override {
+ return IdentifyType(file);
+ }
+
/**
* Load the bootable file
* @return ResultStatus result of function
diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h
index 4a4bd7c770..08bab84e5f 100644
--- a/src/core/loader/loader.h
+++ b/src/core/loader/loader.h
@@ -131,6 +131,12 @@ public:
AppLoader(FileUtil::IOFile&& file) : file(std::move(file)) { }
virtual ~AppLoader() { }
+ /**
+ * Returns the type of this file
+ * @return FileType corresponding to the loaded file
+ */
+ virtual FileType GetFileType() = 0;
+
/**
* Load the application
* @return ResultStatus result of function
diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h
index fd852c3de2..75609ee576 100644
--- a/src/core/loader/ncch.h
+++ b/src/core/loader/ncch.h
@@ -173,6 +173,14 @@ public:
*/
static FileType IdentifyType(FileUtil::IOFile& file);
+ /**
+ * Returns the type of this file
+ * @return FileType corresponding to the loaded file
+ */
+ FileType GetFileType() override {
+ return IdentifyType(file);
+ }
+
/**
* Load the application
* @return ResultStatus result of function