IDeliveryCacheStorageService.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using Ryujinx.HLE.HOS.Services.Arp;
  2. using System;
  3. using System.Text;
  4. namespace Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator
  5. {
  6. class IDeliveryCacheStorageService : IpcService
  7. {
  8. private const int DeliveryCacheDirectoriesLimit = 100;
  9. private const int DeliveryCacheDirectoryNameLength = 32;
  10. private string[] _deliveryCacheDirectories = new string[0];
  11. public IDeliveryCacheStorageService(ServiceCtx context, ApplicationLaunchProperty applicationLaunchProperty)
  12. {
  13. // TODO: Read directories.meta file from the save data (loaded in IServiceCreator) in _deliveryCacheDirectories.
  14. }
  15. [Command(10)]
  16. // EnumerateDeliveryCacheDirectory() -> (u32, buffer<nn::bcat::DirectoryName, 6>)
  17. public ResultCode EnumerateDeliveryCacheDirectory(ServiceCtx context)
  18. {
  19. long outputPosition = context.Request.ReceiveBuff[0].Position;
  20. long outputSize = context.Request.ReceiveBuff[0].Size;
  21. for (int index = 0; index < _deliveryCacheDirectories.Length; index++)
  22. {
  23. if (index == DeliveryCacheDirectoriesLimit - 1)
  24. {
  25. break;
  26. }
  27. byte[] directoryNameBuffer = Encoding.ASCII.GetBytes(_deliveryCacheDirectories[index]);
  28. Array.Resize(ref directoryNameBuffer, DeliveryCacheDirectoryNameLength);
  29. directoryNameBuffer[DeliveryCacheDirectoryNameLength - 1] = 0x00;
  30. context.Memory.WriteBytes(outputPosition + index * DeliveryCacheDirectoryNameLength, directoryNameBuffer);
  31. }
  32. context.ResponseData.Write(_deliveryCacheDirectories.Length);
  33. return ResultCode.Success;
  34. }
  35. }
  36. }