IDeliveryCacheStorageService.cs 2.3 KB

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