diff options
Diffstat (limited to 'src/core/hle/kernel/archive.cpp')
| -rw-r--r-- | src/core/hle/kernel/archive.cpp | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/src/core/hle/kernel/archive.cpp b/src/core/hle/kernel/archive.cpp index ddc09e13b..0e3eb4564 100644 --- a/src/core/hle/kernel/archive.cpp +++ b/src/core/hle/kernel/archive.cpp | |||
| @@ -2,6 +2,8 @@ | |||
| 2 | // Licensed under GPLv2 | 2 | // Licensed under GPLv2 |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <map> | ||
| 6 | |||
| 5 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 6 | #include "common/file_util.h" | 8 | #include "common/file_util.h" |
| 7 | #include "common/math_util.h" | 9 | #include "common/math_util.h" |
| @@ -10,8 +12,8 @@ | |||
| 10 | #include "core/file_sys/archive_sdmc.h" | 12 | #include "core/file_sys/archive_sdmc.h" |
| 11 | #include "core/file_sys/directory.h" | 13 | #include "core/file_sys/directory.h" |
| 12 | #include "core/hle/kernel/archive.h" | 14 | #include "core/hle/kernel/archive.h" |
| 15 | #include "core/hle/kernel/session.h" | ||
| 13 | #include "core/hle/result.h" | 16 | #include "core/hle/result.h" |
| 14 | #include "core/hle/service/service.h" | ||
| 15 | 17 | ||
| 16 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 18 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 17 | // Kernel namespace | 19 | // Kernel namespace |
| @@ -41,19 +43,15 @@ enum class DirectoryCommand : u32 { | |||
| 41 | Close = 0x08020000, | 43 | Close = 0x08020000, |
| 42 | }; | 44 | }; |
| 43 | 45 | ||
| 44 | class Archive : public Object { | 46 | class Archive : public Kernel::Session { |
| 45 | public: | 47 | public: |
| 46 | std::string GetTypeName() const override { return "Archive"; } | 48 | std::string GetName() const override { return "Archive: " + name; } |
| 47 | std::string GetName() const override { return name; } | ||
| 48 | |||
| 49 | static Kernel::HandleType GetStaticHandleType() { return HandleType::Archive; } | ||
| 50 | Kernel::HandleType GetHandleType() const override { return HandleType::Archive; } | ||
| 51 | 49 | ||
| 52 | std::string name; ///< Name of archive (optional) | 50 | std::string name; ///< Name of archive (optional) |
| 53 | FileSys::Archive* backend; ///< Archive backend interface | 51 | FileSys::Archive* backend; ///< Archive backend interface |
| 54 | 52 | ||
| 55 | ResultVal<bool> SyncRequest() override { | 53 | ResultVal<bool> SyncRequest() override { |
| 56 | u32* cmd_buff = Service::GetCommandBuffer(); | 54 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 57 | FileCommand cmd = static_cast<FileCommand>(cmd_buff[0]); | 55 | FileCommand cmd = static_cast<FileCommand>(cmd_buff[0]); |
| 58 | 56 | ||
| 59 | switch (cmd) { | 57 | switch (cmd) { |
| @@ -102,7 +100,8 @@ public: | |||
| 102 | default: | 100 | default: |
| 103 | { | 101 | { |
| 104 | LOG_ERROR(Service_FS, "Unknown command=0x%08X", cmd); | 102 | LOG_ERROR(Service_FS, "Unknown command=0x%08X", cmd); |
| 105 | return UnimplementedFunction(ErrorModule::FS); | 103 | cmd_buff[0] = UnimplementedFunction(ErrorModule::FS).raw; |
| 104 | return MakeResult<bool>(false); | ||
| 106 | } | 105 | } |
| 107 | } | 106 | } |
| 108 | cmd_buff[1] = 0; // No error | 107 | cmd_buff[1] = 0; // No error |
| @@ -110,19 +109,15 @@ public: | |||
| 110 | } | 109 | } |
| 111 | }; | 110 | }; |
| 112 | 111 | ||
| 113 | class File : public Object { | 112 | class File : public Kernel::Session { |
| 114 | public: | 113 | public: |
| 115 | std::string GetTypeName() const override { return "File"; } | 114 | std::string GetName() const override { return "Path: " + path.DebugStr(); } |
| 116 | std::string GetName() const override { return path.DebugStr(); } | ||
| 117 | |||
| 118 | static Kernel::HandleType GetStaticHandleType() { return HandleType::File; } | ||
| 119 | Kernel::HandleType GetHandleType() const override { return HandleType::File; } | ||
| 120 | 115 | ||
| 121 | FileSys::Path path; ///< Path of the file | 116 | FileSys::Path path; ///< Path of the file |
| 122 | std::unique_ptr<FileSys::File> backend; ///< File backend interface | 117 | std::unique_ptr<FileSys::File> backend; ///< File backend interface |
| 123 | 118 | ||
| 124 | ResultVal<bool> SyncRequest() override { | 119 | ResultVal<bool> SyncRequest() override { |
| 125 | u32* cmd_buff = Service::GetCommandBuffer(); | 120 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 126 | FileCommand cmd = static_cast<FileCommand>(cmd_buff[0]); | 121 | FileCommand cmd = static_cast<FileCommand>(cmd_buff[0]); |
| 127 | switch (cmd) { | 122 | switch (cmd) { |
| 128 | 123 | ||
| @@ -188,19 +183,15 @@ public: | |||
| 188 | } | 183 | } |
| 189 | }; | 184 | }; |
| 190 | 185 | ||
| 191 | class Directory : public Object { | 186 | class Directory : public Kernel::Session { |
| 192 | public: | 187 | public: |
| 193 | std::string GetTypeName() const override { return "Directory"; } | 188 | std::string GetName() const override { return "Directory: " + path.DebugStr(); } |
| 194 | std::string GetName() const override { return path.DebugStr(); } | ||
| 195 | |||
| 196 | static Kernel::HandleType GetStaticHandleType() { return HandleType::Directory; } | ||
| 197 | Kernel::HandleType GetHandleType() const override { return HandleType::Directory; } | ||
| 198 | 189 | ||
| 199 | FileSys::Path path; ///< Path of the directory | 190 | FileSys::Path path; ///< Path of the directory |
| 200 | std::unique_ptr<FileSys::Directory> backend; ///< File backend interface | 191 | std::unique_ptr<FileSys::Directory> backend; ///< File backend interface |
| 201 | 192 | ||
| 202 | ResultVal<bool> SyncRequest() override { | 193 | ResultVal<bool> SyncRequest() override { |
| 203 | u32* cmd_buff = Service::GetCommandBuffer(); | 194 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 204 | DirectoryCommand cmd = static_cast<DirectoryCommand>(cmd_buff[0]); | 195 | DirectoryCommand cmd = static_cast<DirectoryCommand>(cmd_buff[0]); |
| 205 | switch (cmd) { | 196 | switch (cmd) { |
| 206 | 197 | ||
| @@ -230,7 +221,7 @@ public: | |||
| 230 | LOG_ERROR(Service_FS, "Unknown command=0x%08X!", cmd); | 221 | LOG_ERROR(Service_FS, "Unknown command=0x%08X!", cmd); |
| 231 | ResultCode error = UnimplementedFunction(ErrorModule::FS); | 222 | ResultCode error = UnimplementedFunction(ErrorModule::FS); |
| 232 | cmd_buff[1] = error.raw; // TODO(Link Mauve): use the correct error code for that. | 223 | cmd_buff[1] = error.raw; // TODO(Link Mauve): use the correct error code for that. |
| 233 | return error; | 224 | return MakeResult<bool>(false); |
| 234 | } | 225 | } |
| 235 | cmd_buff[1] = 0; // No error | 226 | cmd_buff[1] = 0; // No error |
| 236 | return MakeResult<bool>(false); | 227 | return MakeResult<bool>(false); |