2020-04-30 00:58:19 -04:00
|
|
|
using LibHac;
|
|
|
|
using LibHac.Bcat;
|
|
|
|
using System.Runtime.InteropServices;
|
2019-09-10 05:55:28 -04:00
|
|
|
|
2019-09-18 20:45:11 -04:00
|
|
|
namespace Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator
|
2018-07-23 10:20:16 -04:00
|
|
|
{
|
2021-06-29 13:37:13 -04:00
|
|
|
class IDeliveryCacheStorageService : DisposableIpcService
|
2018-07-23 10:20:16 -04:00
|
|
|
{
|
2020-04-30 00:58:19 -04:00
|
|
|
private LibHac.Bcat.Detail.Ipc.IDeliveryCacheStorageService _base;
|
2019-09-10 05:55:28 -04:00
|
|
|
|
2020-04-30 00:58:19 -04:00
|
|
|
public IDeliveryCacheStorageService(ServiceCtx context, LibHac.Bcat.Detail.Ipc.IDeliveryCacheStorageService baseService)
|
|
|
|
{
|
|
|
|
_base = baseService;
|
|
|
|
}
|
2019-09-10 05:55:28 -04:00
|
|
|
|
2021-04-13 18:01:24 -04:00
|
|
|
[CommandHipc(0)]
|
2020-04-30 00:58:19 -04:00
|
|
|
// CreateFileService() -> object<nn::bcat::detail::ipc::IDeliveryCacheFileService>
|
|
|
|
public ResultCode CreateFileService(ServiceCtx context)
|
2019-09-10 05:55:28 -04:00
|
|
|
{
|
2020-04-30 00:58:19 -04:00
|
|
|
Result result = _base.CreateFileService(out LibHac.Bcat.Detail.Ipc.IDeliveryCacheFileService service);
|
|
|
|
|
|
|
|
if (result.IsSuccess())
|
|
|
|
{
|
|
|
|
MakeObject(context, new IDeliveryCacheFileService(service));
|
|
|
|
}
|
|
|
|
|
|
|
|
return (ResultCode)result.Value;
|
|
|
|
}
|
|
|
|
|
2021-04-13 18:01:24 -04:00
|
|
|
[CommandHipc(1)]
|
2020-04-30 00:58:19 -04:00
|
|
|
// CreateDirectoryService() -> object<nn::bcat::detail::ipc::IDeliveryCacheDirectoryService>
|
|
|
|
public ResultCode CreateDirectoryService(ServiceCtx context)
|
|
|
|
{
|
|
|
|
Result result = _base.CreateDirectoryService(out LibHac.Bcat.Detail.Ipc.IDeliveryCacheDirectoryService service);
|
|
|
|
|
|
|
|
if (result.IsSuccess())
|
|
|
|
{
|
|
|
|
MakeObject(context, new IDeliveryCacheDirectoryService(service));
|
|
|
|
}
|
|
|
|
|
|
|
|
return (ResultCode)result.Value;
|
2019-09-10 05:55:28 -04:00
|
|
|
}
|
|
|
|
|
2021-04-13 18:01:24 -04:00
|
|
|
[CommandHipc(10)]
|
2019-09-10 05:55:28 -04:00
|
|
|
// EnumerateDeliveryCacheDirectory() -> (u32, buffer<nn::bcat::DirectoryName, 6>)
|
|
|
|
public ResultCode EnumerateDeliveryCacheDirectory(ServiceCtx context)
|
|
|
|
{
|
2021-04-24 06:16:01 -04:00
|
|
|
ulong position = context.Request.ReceiveBuff[0].Position;
|
|
|
|
ulong size = context.Request.ReceiveBuff[0].Size;
|
2019-09-10 05:55:28 -04:00
|
|
|
|
2020-04-30 00:58:19 -04:00
|
|
|
byte[] data = new byte[size];
|
2019-09-10 05:55:28 -04:00
|
|
|
|
2020-04-30 00:58:19 -04:00
|
|
|
Result result = _base.EnumerateDeliveryCacheDirectory(out int count, MemoryMarshal.Cast<byte, DirectoryName>(data));
|
2019-09-10 05:55:28 -04:00
|
|
|
|
2021-04-24 06:16:01 -04:00
|
|
|
context.Memory.Write(position, data);
|
2019-09-10 05:55:28 -04:00
|
|
|
|
2020-04-30 00:58:19 -04:00
|
|
|
context.ResponseData.Write(count);
|
2019-09-10 05:55:28 -04:00
|
|
|
|
2020-04-30 00:58:19 -04:00
|
|
|
return (ResultCode)result.Value;
|
|
|
|
}
|
2019-09-10 05:55:28 -04:00
|
|
|
|
2021-06-29 13:37:13 -04:00
|
|
|
protected override void Dispose(bool isDisposing)
|
2020-04-30 00:58:19 -04:00
|
|
|
{
|
2021-06-29 13:37:13 -04:00
|
|
|
if (isDisposing)
|
|
|
|
{
|
|
|
|
_base?.Dispose();
|
|
|
|
}
|
2019-09-10 05:55:28 -04:00
|
|
|
}
|
2018-07-23 10:20:16 -04:00
|
|
|
}
|
2020-04-30 00:58:19 -04:00
|
|
|
}
|