diff options
| author | 2016-05-18 22:06:50 +0100 | |
|---|---|---|
| committer | 2016-05-21 17:09:59 +0100 | |
| commit | 314ce5e505aca066ad4d0385be46d7e8de9f6dfb (patch) | |
| tree | e71b47815cf82006ea78b9820b5df5f99f8380b9 /src/core/loader/loader.cpp | |
| parent | Loader: Add a GetFileType method to get the type of a loaded file (diff) | |
| download | yuzu-314ce5e505aca066ad4d0385be46d7e8de9f6dfb.tar.gz yuzu-314ce5e505aca066ad4d0385be46d7e8de9f6dfb.tar.xz yuzu-314ce5e505aca066ad4d0385be46d7e8de9f6dfb.zip | |
CitraQt: Simplify the game list loader code
Diffstat (limited to 'src/core/loader/loader.cpp')
| -rw-r--r-- | src/core/loader/loader.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp index c82688026..9719d30d5 100644 --- a/src/core/loader/loader.cpp +++ b/src/core/loader/loader.cpp | |||
| @@ -91,7 +91,15 @@ const char* GetFileTypeString(FileType type) { | |||
| 91 | return "unknown"; | 91 | return "unknown"; |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | std::unique_ptr<AppLoader> GetLoader(FileUtil::IOFile&& file, FileType type, | 94 | /** |
| 95 | * Get a loader for a file with a specific type | ||
| 96 | * @param file The file to load | ||
| 97 | * @param type The type of the file | ||
| 98 | * @param filename the file name (without path) | ||
| 99 | * @param filepath the file full path (with name) | ||
| 100 | * @return std::unique_ptr<AppLoader> a pointer to a loader object; nullptr for unsupported type | ||
| 101 | */ | ||
| 102 | static std::unique_ptr<AppLoader> GetFileLoader(FileUtil::IOFile&& file, FileType type, | ||
| 95 | const std::string& filename, const std::string& filepath) { | 103 | const std::string& filename, const std::string& filepath) { |
| 96 | switch (type) { | 104 | switch (type) { |
| 97 | 105 | ||
| @@ -113,7 +121,7 @@ std::unique_ptr<AppLoader> GetLoader(FileUtil::IOFile&& file, FileType type, | |||
| 113 | } | 121 | } |
| 114 | } | 122 | } |
| 115 | 123 | ||
| 116 | std::unique_ptr<AppLoader> GetFileLoader(const std::string& filename) { | 124 | std::unique_ptr<AppLoader> GetLoader(const std::string& filename) { |
| 117 | FileUtil::IOFile file(filename, "rb"); | 125 | FileUtil::IOFile file(filename, "rb"); |
| 118 | if (!file.IsOpen()) { | 126 | if (!file.IsOpen()) { |
| 119 | LOG_ERROR(Loader, "Failed to load file %s", filename.c_str()); | 127 | LOG_ERROR(Loader, "Failed to load file %s", filename.c_str()); |
| @@ -134,7 +142,7 @@ std::unique_ptr<AppLoader> GetFileLoader(const std::string& filename) { | |||
| 134 | 142 | ||
| 135 | LOG_INFO(Loader, "Loading file %s as %s...", filename.c_str(), GetFileTypeString(type)); | 143 | LOG_INFO(Loader, "Loading file %s as %s...", filename.c_str(), GetFileTypeString(type)); |
| 136 | 144 | ||
| 137 | return GetLoader(std::move(file), type, filename_filename, filename); | 145 | return GetFileLoader(std::move(file), type, filename_filename, filename); |
| 138 | } | 146 | } |
| 139 | 147 | ||
| 140 | } // namespace Loader | 148 | } // namespace Loader |