diff options
author | Subv <subv2112@gmail.com> | 2018-03-20 05:01:47 +0100 |
---|---|---|
committer | Subv <subv2112@gmail.com> | 2018-03-20 05:01:47 +0100 |
commit | 21bac2d7d757df18f184a8d79393ab8f91c0fc03 (patch) | |
tree | 5d9c7889f3f48d00909f88a09c88def940f21744 /src/core/hle | |
parent | FS: Implement DiskFileSystem's OpenDirectory interface. (diff) | |
download | yuzu-21bac2d7d757df18f184a8d79393ab8f91c0fc03.tar yuzu-21bac2d7d757df18f184a8d79393ab8f91c0fc03.tar.gz yuzu-21bac2d7d757df18f184a8d79393ab8f91c0fc03.tar.bz2 yuzu-21bac2d7d757df18f184a8d79393ab8f91c0fc03.tar.lz yuzu-21bac2d7d757df18f184a8d79393ab8f91c0fc03.tar.xz yuzu-21bac2d7d757df18f184a8d79393ab8f91c0fc03.tar.zst yuzu-21bac2d7d757df18f184a8d79393ab8f91c0fc03.zip |
Diffstat (limited to 'src/core/hle')
-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 @@ #include <cinttypes> #include "common/logging/log.h" #include "core/core.h" +#include "core/file_sys/directory.h" #include "core/file_sys/filesystem.h" #include "core/file_sys/storage.h" #include "core/hle/ipc_helpers.h" @@ -151,6 +152,56 @@ private: } }; +class IDirectory final : public ServiceFramework<IDirectory> { +public: + explicit IDirectory(std::unique_ptr<FileSys::DirectoryBackend>&& backend) + : ServiceFramework("IDirectory"), backend(std::move(backend)) { + static const FunctionInfo functions[] = { + {0, &IDirectory::Read, "Read"}, + {1, &IDirectory::GetEntryCount, "GetEntryCount"}, + }; + RegisterHandlers(functions); + } + +private: + std::unique_ptr<FileSys::DirectoryBackend> backend; + + void Read(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + const u64 unk = rp.Pop<u64>(); + + LOG_DEBUG(Service_FS, "called, unk=0x%llx", unk); + + // Calculate how many entries we can fit in the output buffer + u64 count_entries = ctx.GetWriteBufferSize() / sizeof(FileSys::Entry); + + // Read the data from the Directory backend + std::vector<FileSys::Entry> entries(count_entries); + u64 read_entries = backend->Read(count_entries, entries.data()); + + // Convert the data into a byte array + std::vector<u8> output(entries.size() * sizeof(FileSys::Entry)); + std::memcpy(output.data(), entries.data(), output.size()); + + // Write the data to memory + ctx.WriteBuffer(output); + + IPC::ResponseBuilder rb{ctx, 4}; + rb.Push(RESULT_SUCCESS); + rb.Push(read_entries); + } + + void GetEntryCount(Kernel::HLERequestContext& ctx) { + LOG_DEBUG(Service_FS, "called"); + + u64 count = backend->GetEntryCount(); + + IPC::ResponseBuilder rb{ctx, 4}; + rb.Push(RESULT_SUCCESS); + rb.Push(count); + } +}; + class IFileSystem final : public ServiceFramework<IFileSystem> { public: explicit IFileSystem(std::unique_ptr<FileSys::FileSystemBackend>&& backend) |