diff options
| author | 2018-03-19 23:01:47 -0500 | |
|---|---|---|
| committer | 2018-03-19 23:01:47 -0500 | |
| commit | 21bac2d7d757df18f184a8d79393ab8f91c0fc03 (patch) | |
| tree | 5d9c7889f3f48d00909f88a09c88def940f21744 /src | |
| parent | FS: Implement DiskFileSystem's OpenDirectory interface. (diff) | |
| download | yuzu-21bac2d7d757df18f184a8d79393ab8f91c0fc03.tar.gz yuzu-21bac2d7d757df18f184a8d79393ab8f91c0fc03.tar.xz yuzu-21bac2d7d757df18f184a8d79393ab8f91c0fc03.zip | |
FS: Added the IDirectory IPC interface and implemented its two functions.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/filesystem/fsp_srv.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp index 720ac9930..5536991bc 100644 --- a/src/core/hle/service/filesystem/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp_srv.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include <cinttypes> | 5 | #include <cinttypes> |
| 6 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 7 | #include "core/core.h" | 7 | #include "core/core.h" |
| 8 | #include "core/file_sys/directory.h" | ||
| 8 | #include "core/file_sys/filesystem.h" | 9 | #include "core/file_sys/filesystem.h" |
| 9 | #include "core/file_sys/storage.h" | 10 | #include "core/file_sys/storage.h" |
| 10 | #include "core/hle/ipc_helpers.h" | 11 | #include "core/hle/ipc_helpers.h" |
| @@ -151,6 +152,56 @@ private: | |||
| 151 | } | 152 | } |
| 152 | }; | 153 | }; |
| 153 | 154 | ||
| 155 | class IDirectory final : public ServiceFramework<IDirectory> { | ||
| 156 | public: | ||
| 157 | explicit IDirectory(std::unique_ptr<FileSys::DirectoryBackend>&& backend) | ||
| 158 | : ServiceFramework("IDirectory"), backend(std::move(backend)) { | ||
| 159 | static const FunctionInfo functions[] = { | ||
| 160 | {0, &IDirectory::Read, "Read"}, | ||
| 161 | {1, &IDirectory::GetEntryCount, "GetEntryCount"}, | ||
| 162 | }; | ||
| 163 | RegisterHandlers(functions); | ||
| 164 | } | ||
| 165 | |||
| 166 | private: | ||
| 167 | std::unique_ptr<FileSys::DirectoryBackend> backend; | ||
| 168 | |||
| 169 | void Read(Kernel::HLERequestContext& ctx) { | ||
| 170 | IPC::RequestParser rp{ctx}; | ||
| 171 | const u64 unk = rp.Pop<u64>(); | ||
| 172 | |||
| 173 | LOG_DEBUG(Service_FS, "called, unk=0x%llx", unk); | ||
| 174 | |||
| 175 | // Calculate how many entries we can fit in the output buffer | ||
| 176 | u64 count_entries = ctx.GetWriteBufferSize() / sizeof(FileSys::Entry); | ||
| 177 | |||
| 178 | // Read the data from the Directory backend | ||
| 179 | std::vector<FileSys::Entry> entries(count_entries); | ||
| 180 | u64 read_entries = backend->Read(count_entries, entries.data()); | ||
| 181 | |||
| 182 | // Convert the data into a byte array | ||
| 183 | std::vector<u8> output(entries.size() * sizeof(FileSys::Entry)); | ||
| 184 | std::memcpy(output.data(), entries.data(), output.size()); | ||
| 185 | |||
| 186 | // Write the data to memory | ||
| 187 | ctx.WriteBuffer(output); | ||
| 188 | |||
| 189 | IPC::ResponseBuilder rb{ctx, 4}; | ||
| 190 | rb.Push(RESULT_SUCCESS); | ||
| 191 | rb.Push(read_entries); | ||
| 192 | } | ||
| 193 | |||
| 194 | void GetEntryCount(Kernel::HLERequestContext& ctx) { | ||
| 195 | LOG_DEBUG(Service_FS, "called"); | ||
| 196 | |||
| 197 | u64 count = backend->GetEntryCount(); | ||
| 198 | |||
| 199 | IPC::ResponseBuilder rb{ctx, 4}; | ||
| 200 | rb.Push(RESULT_SUCCESS); | ||
| 201 | rb.Push(count); | ||
| 202 | } | ||
| 203 | }; | ||
| 204 | |||
| 154 | class IFileSystem final : public ServiceFramework<IFileSystem> { | 205 | class IFileSystem final : public ServiceFramework<IFileSystem> { |
| 155 | public: | 206 | public: |
| 156 | explicit IFileSystem(std::unique_ptr<FileSys::FileSystemBackend>&& backend) | 207 | explicit IFileSystem(std::unique_ptr<FileSys::FileSystemBackend>&& backend) |