IDeliveryCacheDirectoryService.cs 1.8 KB

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