summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Zach Hilman2019-04-28 18:53:03 -0400
committerGravatar Zach Hilman2019-09-30 17:23:26 -0400
commit862131ead9cf8e10e4ff220d01cb1be16533d208 (patch)
tree713bade62c982cb07baefbe8494943891bb10e4b /src/core
parentbcat: Add commands to create IDeliveryCacheStorageService (diff)
downloadyuzu-862131ead9cf8e10e4ff220d01cb1be16533d208.tar.gz
yuzu-862131ead9cf8e10e4ff220d01cb1be16533d208.tar.xz
yuzu-862131ead9cf8e10e4ff220d01cb1be16533d208.zip
bcat: Implement IDeliveryCacheStorageService commands
Used to create subclasses to manage files and directories and to list directories.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hle/service/bcat/module.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/core/hle/service/bcat/module.cpp b/src/core/hle/service/bcat/module.cpp
index fd742fde2..2d8341359 100644
--- a/src/core/hle/service/bcat/module.cpp
+++ b/src/core/hle/service/bcat/module.cpp
@@ -40,6 +40,64 @@ void Module::Interface::CreateBcatService(Kernel::HLERequestContext& ctx) {
40 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 40 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
41 rb.Push(RESULT_SUCCESS); 41 rb.Push(RESULT_SUCCESS);
42 rb.PushIpcInterface<IBcatService>(*backend); 42 rb.PushIpcInterface<IBcatService>(*backend);
43class IDeliveryCacheStorageService final : public ServiceFramework<IDeliveryCacheStorageService> {
44public:
45 IDeliveryCacheStorageService(FileSys::VirtualDir root_)
46 : ServiceFramework{"IDeliveryCacheStorageService"}, root(std::move(root_)) {
47 // clang-format off
48 static const FunctionInfo functions[] = {
49 {0, &IDeliveryCacheStorageService::CreateFileService, "CreateFileService"},
50 {1, &IDeliveryCacheStorageService::CreateDirectoryService, "CreateDirectoryService"},
51 {10, &IDeliveryCacheStorageService::EnumerateDeliveryCacheDirectory, "EnumerateDeliveryCacheDirectory"},
52 };
53 // clang-format on
54
55 RegisterHandlers(functions);
56
57 for (const auto& subdir : root->GetSubdirectories()) {
58 DirectoryName name{};
59 std::memcpy(name.data(), subdir->GetName().data(),
60 std::min(sizeof(DirectoryName) - 1, subdir->GetName().size()));
61 entries.push_back(name);
62 }
63 }
64
65private:
66 void CreateFileService(Kernel::HLERequestContext& ctx) {
67 LOG_DEBUG(Service_BCAT, "called");
68
69 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
70 rb.Push(RESULT_SUCCESS);
71 rb.PushIpcInterface<IDeliveryCacheFileService>(root);
72 }
73
74 void CreateDirectoryService(Kernel::HLERequestContext& ctx) {
75 LOG_DEBUG(Service_BCAT, "called");
76
77 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
78 rb.Push(RESULT_SUCCESS);
79 rb.PushIpcInterface<IDeliveryCacheDirectoryService>(root);
80 }
81
82 void EnumerateDeliveryCacheDirectory(Kernel::HLERequestContext& ctx) {
83 auto size = ctx.GetWriteBufferSize() / sizeof(DirectoryName);
84
85 LOG_DEBUG(Service_BCAT, "called, size={:016X}", size);
86
87 size = std::min(size, entries.size() - next_read_index);
88 ctx.WriteBuffer(entries.data() + next_read_index, size * sizeof(DirectoryName));
89 next_read_index += size;
90
91 IPC::ResponseBuilder rb{ctx, 3};
92 rb.Push(RESULT_SUCCESS);
93 rb.Push<u32>(size);
94 }
95
96 FileSys::VirtualDir root;
97 std::vector<DirectoryName> entries;
98 u64 next_read_index = 0;
99};
100
43void Module::Interface::CreateDeliveryCacheStorageService(Kernel::HLERequestContext& ctx) { 101void Module::Interface::CreateDeliveryCacheStorageService(Kernel::HLERequestContext& ctx) {
44 LOG_DEBUG(Service_BCAT, "called"); 102 LOG_DEBUG(Service_BCAT, "called");
45 103