IDeliveryCacheFileService.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using LibHac;
  2. using LibHac.Bcat;
  3. using LibHac.Common;
  4. using Ryujinx.Common;
  5. namespace Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator
  6. {
  7. class IDeliveryCacheFileService : DisposableIpcService
  8. {
  9. private SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheFileService> _base;
  10. public IDeliveryCacheFileService(ref SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheFileService> baseService)
  11. {
  12. _base = SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheFileService>.CreateMove(ref baseService);
  13. }
  14. protected override void Dispose(bool isDisposing)
  15. {
  16. if (isDisposing)
  17. {
  18. _base.Destroy();
  19. }
  20. }
  21. [CommandHipc(0)]
  22. // Open(nn::bcat::DirectoryName, nn::bcat::FileName)
  23. public ResultCode Open(ServiceCtx context)
  24. {
  25. DirectoryName directoryName = context.RequestData.ReadStruct<DirectoryName>();
  26. FileName fileName = context.RequestData.ReadStruct<FileName>();
  27. Result result = _base.Get.Open(ref directoryName, ref fileName);
  28. return (ResultCode)result.Value;
  29. }
  30. [CommandHipc(1)]
  31. // Read(u64) -> (u64, buffer<bytes, 6>)
  32. public ResultCode Read(ServiceCtx context)
  33. {
  34. ulong position = context.Request.ReceiveBuff[0].Position;
  35. ulong size = context.Request.ReceiveBuff[0].Size;
  36. long offset = context.RequestData.ReadInt64();
  37. byte[] data = new byte[size];
  38. Result result = _base.Get.Read(out long bytesRead, offset, data);
  39. context.Memory.Write(position, data);
  40. context.ResponseData.Write(bytesRead);
  41. return (ResultCode)result.Value;
  42. }
  43. [CommandHipc(2)]
  44. // GetSize() -> u64
  45. public ResultCode GetSize(ServiceCtx context)
  46. {
  47. Result result = _base.Get.GetSize(out long size);
  48. context.ResponseData.Write(size);
  49. return (ResultCode)result.Value;
  50. }
  51. [CommandHipc(3)]
  52. // GetDigest() -> nn::bcat::Digest
  53. public ResultCode GetDigest(ServiceCtx context)
  54. {
  55. Result result = _base.Get.GetDigest(out Digest digest);
  56. context.ResponseData.WriteStruct(digest);
  57. return (ResultCode)result.Value;
  58. }
  59. }
  60. }