0
0
Fork 0
This repository has been archived on 2024-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
ryujinx-final/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IStorage.cs
Alex Barney 8a8ea4c8c0 Update to LibHac 0.6.0 (#792)
* Update to LibHac 0.6.0

* Create an IFileSystemProxy object from LibHac

* Rename rc -> result

* Alignment and spacing

* Result formatting

* Spacing

* Sort usings
2019-10-17 08:17:44 +02:00

55 lines
No EOL
1.4 KiB
C#

using LibHac;
using Ryujinx.HLE.HOS.Ipc;
namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
class IStorage : IpcService
{
private LibHac.Fs.IStorage _baseStorage;
public IStorage(LibHac.Fs.IStorage baseStorage)
{
_baseStorage = baseStorage;
}
[Command(0)]
// Read(u64 offset, u64 length) -> buffer<u8, 0x46, 0> buffer
public ResultCode Read(ServiceCtx context)
{
long offset = context.RequestData.ReadInt64();
long size = context.RequestData.ReadInt64();
if (context.Request.ReceiveBuff.Count > 0)
{
IpcBuffDesc buffDesc = context.Request.ReceiveBuff[0];
// Use smaller length to avoid overflows.
if (size > buffDesc.Size)
{
size = buffDesc.Size;
}
byte[] data = new byte[size];
Result result = _baseStorage.Read(offset, data);
context.Memory.WriteBytes(buffDesc.Position, data);
return (ResultCode)result.Value;
}
return ResultCode.Success;
}
[Command(4)]
// GetSize() -> u64 size
public ResultCode GetSize(ServiceCtx context)
{
Result result = _baseStorage.GetSize(out long size);
context.ResponseData.Write(size);
return (ResultCode)result.Value;
}
}
}