IDeliveryCacheDirectoryService.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using LibHac;
  2. using LibHac.Bcat;
  3. using Ryujinx.Common;
  4. using System;
  5. using System.Runtime.InteropServices;
  6. namespace Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator
  7. {
  8. class IDeliveryCacheDirectoryService : IpcService, IDisposable
  9. {
  10. private LibHac.Bcat.Detail.Ipc.IDeliveryCacheDirectoryService _base;
  11. public IDeliveryCacheDirectoryService(LibHac.Bcat.Detail.Ipc.IDeliveryCacheDirectoryService baseService)
  12. {
  13. _base = baseService;
  14. }
  15. [Command(0)]
  16. // Open(nn::bcat::DirectoryName)
  17. public ResultCode Open(ServiceCtx context)
  18. {
  19. DirectoryName directoryName = context.RequestData.ReadStruct<DirectoryName>();
  20. Result result = _base.Open(ref directoryName);
  21. return (ResultCode)result.Value;
  22. }
  23. [Command(1)]
  24. // Read() -> (u32, buffer<nn::bcat::DeliveryCacheDirectoryEntry, 6>)
  25. public ResultCode Read(ServiceCtx context)
  26. {
  27. long position = context.Request.ReceiveBuff[0].Position;
  28. long size = context.Request.ReceiveBuff[0].Size;
  29. byte[] data = new byte[size];
  30. Result result = _base.Read(out int entriesRead, MemoryMarshal.Cast<byte, DeliveryCacheDirectoryEntry>(data));
  31. context.Memory.Write((ulong)position, data);
  32. context.ResponseData.Write(entriesRead);
  33. return (ResultCode)result.Value;
  34. }
  35. [Command(2)]
  36. // GetCount() -> u32
  37. public ResultCode GetCount(ServiceCtx context)
  38. {
  39. Result result = _base.GetCount(out int count);
  40. context.ResponseData.Write(count);
  41. return (ResultCode)result.Value;
  42. }
  43. public void Dispose()
  44. {
  45. _base?.Dispose();
  46. }
  47. }
  48. }