diff options
| author | 2018-07-18 21:07:11 -0400 | |
|---|---|---|
| committer | 2018-07-18 18:07:11 -0700 | |
| commit | 29aff8d5ab46c8d0199aa4bfa7eeff5d4fa2d7ef (patch) | |
| tree | 3202e2ce55ab6387a4ca366a509eccdd963434c3 /src/core/loader/loader.h | |
| parent | Merge pull request #683 from DarkLordZach/touch (diff) | |
| download | yuzu-29aff8d5ab46c8d0199aa4bfa7eeff5d4fa2d7ef.tar.gz yuzu-29aff8d5ab46c8d0199aa4bfa7eeff5d4fa2d7ef.tar.xz yuzu-29aff8d5ab46c8d0199aa4bfa7eeff5d4fa2d7ef.zip | |
Virtual Filesystem 2: Electric Boogaloo (#676)
* Virtual Filesystem
* Fix delete bug and documentate
* Review fixes + other stuff
* Fix puyo regression
Diffstat (limited to 'src/core/loader/loader.h')
| -rw-r--r-- | src/core/loader/loader.h | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h index b76f7b13d..1da9e8099 100644 --- a/src/core/loader/loader.h +++ b/src/core/loader/loader.h | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | #include <boost/optional.hpp> | 13 | #include <boost/optional.hpp> |
| 14 | #include "common/common_types.h" | 14 | #include "common/common_types.h" |
| 15 | #include "common/file_util.h" | 15 | #include "common/file_util.h" |
| 16 | #include "core/file_sys/vfs.h" | ||
| 16 | #include "core/hle/kernel/kernel.h" | 17 | #include "core/hle/kernel/kernel.h" |
| 17 | 18 | ||
| 18 | namespace Kernel { | 19 | namespace Kernel { |
| @@ -36,10 +37,9 @@ enum class FileType { | |||
| 36 | /** | 37 | /** |
| 37 | * Identifies the type of a bootable file based on the magic value in its header. | 38 | * Identifies the type of a bootable file based on the magic value in its header. |
| 38 | * @param file open file | 39 | * @param file open file |
| 39 | * @param filepath Path of the file that we are opening. | ||
| 40 | * @return FileType of file | 40 | * @return FileType of file |
| 41 | */ | 41 | */ |
| 42 | FileType IdentifyFile(FileUtil::IOFile& file, const std::string& filepath); | 42 | FileType IdentifyFile(FileSys::VirtualFile file); |
| 43 | 43 | ||
| 44 | /** | 44 | /** |
| 45 | * Identifies the type of a bootable file based on the magic value in its header. | 45 | * Identifies the type of a bootable file based on the magic value in its header. |
| @@ -50,12 +50,12 @@ FileType IdentifyFile(FileUtil::IOFile& file, const std::string& filepath); | |||
| 50 | FileType IdentifyFile(const std::string& file_name); | 50 | FileType IdentifyFile(const std::string& file_name); |
| 51 | 51 | ||
| 52 | /** | 52 | /** |
| 53 | * Guess the type of a bootable file from its extension | 53 | * Guess the type of a bootable file from its name |
| 54 | * @param extension String extension of bootable file | 54 | * @param name String name of bootable file |
| 55 | * @return FileType of file. Note: this will return FileType::Unknown if it is unable to determine | 55 | * @return FileType of file. Note: this will return FileType::Unknown if it is unable to determine |
| 56 | * a filetype, and will never return FileType::Error. | 56 | * a filetype, and will never return FileType::Error. |
| 57 | */ | 57 | */ |
| 58 | FileType GuessFromExtension(const std::string& extension); | 58 | FileType GuessFromFilename(const std::string& name); |
| 59 | 59 | ||
| 60 | /** | 60 | /** |
| 61 | * Convert a FileType into a string which can be displayed to the user. | 61 | * Convert a FileType into a string which can be displayed to the user. |
| @@ -79,7 +79,7 @@ enum class ResultStatus { | |||
| 79 | /// Interface for loading an application | 79 | /// Interface for loading an application |
| 80 | class AppLoader : NonCopyable { | 80 | class AppLoader : NonCopyable { |
| 81 | public: | 81 | public: |
| 82 | AppLoader(FileUtil::IOFile&& file) : file(std::move(file)) {} | 82 | AppLoader(FileSys::VirtualFile file) : file(std::move(file)) {} |
| 83 | virtual ~AppLoader() {} | 83 | virtual ~AppLoader() {} |
| 84 | 84 | ||
| 85 | /** | 85 | /** |
| @@ -154,26 +154,20 @@ public: | |||
| 154 | /** | 154 | /** |
| 155 | * Get the RomFS of the application | 155 | * Get the RomFS of the application |
| 156 | * Since the RomFS can be huge, we return a file reference instead of copying to a buffer | 156 | * Since the RomFS can be huge, we return a file reference instead of copying to a buffer |
| 157 | * @param romfs_file The file containing the RomFS | 157 | * @param file The file containing the RomFS |
| 158 | * @param offset The offset the romfs begins on | ||
| 159 | * @param size The size of the romfs | ||
| 160 | * @return ResultStatus result of function | 158 | * @return ResultStatus result of function |
| 161 | */ | 159 | */ |
| 162 | virtual ResultStatus ReadRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset, | 160 | virtual ResultStatus ReadRomFS(FileSys::VirtualFile& dir) { |
| 163 | u64& size) { | ||
| 164 | return ResultStatus::ErrorNotImplemented; | 161 | return ResultStatus::ErrorNotImplemented; |
| 165 | } | 162 | } |
| 166 | 163 | ||
| 167 | /** | 164 | /** |
| 168 | * Get the update RomFS of the application | 165 | * Get the update RomFS of the application |
| 169 | * Since the RomFS can be huge, we return a file reference instead of copying to a buffer | 166 | * Since the RomFS can be huge, we return a file reference instead of copying to a buffer |
| 170 | * @param romfs_file The file containing the RomFS | 167 | * @param file The file containing the RomFS |
| 171 | * @param offset The offset the romfs begins on | ||
| 172 | * @param size The size of the romfs | ||
| 173 | * @return ResultStatus result of function | 168 | * @return ResultStatus result of function |
| 174 | */ | 169 | */ |
| 175 | virtual ResultStatus ReadUpdateRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset, | 170 | virtual ResultStatus ReadUpdateRomFS(FileSys::VirtualFile& file) { |
| 176 | u64& size) { | ||
| 177 | return ResultStatus::ErrorNotImplemented; | 171 | return ResultStatus::ErrorNotImplemented; |
| 178 | } | 172 | } |
| 179 | 173 | ||
| @@ -187,7 +181,7 @@ public: | |||
| 187 | } | 181 | } |
| 188 | 182 | ||
| 189 | protected: | 183 | protected: |
| 190 | FileUtil::IOFile file; | 184 | FileSys::VirtualFile file; |
| 191 | bool is_loaded = false; | 185 | bool is_loaded = false; |
| 192 | }; | 186 | }; |
| 193 | 187 | ||
| @@ -202,6 +196,6 @@ extern const std::initializer_list<Kernel::AddressMapping> default_address_mappi | |||
| 202 | * @param filename String filename of bootable file | 196 | * @param filename String filename of bootable file |
| 203 | * @return best loader for this file | 197 | * @return best loader for this file |
| 204 | */ | 198 | */ |
| 205 | std::unique_ptr<AppLoader> GetLoader(const std::string& filename); | 199 | std::unique_ptr<AppLoader> GetLoader(FileSys::VirtualFile file); |
| 206 | 200 | ||
| 207 | } // namespace Loader | 201 | } // namespace Loader |