1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-09-22 15:03:30 +01:00
Ryujinx/Ryujinx.HLE/HOS/Services/FspSrv/IStorage.cs
Alex Barney b2b736abc2 Misc cleanup (#708)
* Fix typos

* Remove unneeded using statements

* Enforce var style more

* Remove redundant qualifiers

* Fix some indentation

* Disable naming warnings on files with external enum names

* Fix build

* Mass find & replace for comments with no spacing

* Standardize todo capitalization and for/if spacing
2019-07-02 04:39:22 +02:00

60 lines
1.6 KiB
C#

using Ryujinx.HLE.HOS.Ipc;
using System.Collections.Generic;
namespace Ryujinx.HLE.HOS.Services.FspSrv
{
class IStorage : IpcService
{
private Dictionary<int, ServiceProcessRequest> _commands;
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
private LibHac.Fs.IStorage _baseStorage;
public IStorage(LibHac.Fs.IStorage baseStorage)
{
_commands = new Dictionary<int, ServiceProcessRequest>
{
{ 0, Read },
{ 4, GetSize }
};
_baseStorage = baseStorage;
}
// Read(u64 offset, u64 length) -> buffer<u8, 0x46, 0> buffer
public long 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];
_baseStorage.Read(data, offset);
context.Memory.WriteBytes(buffDesc.Position, data);
}
return 0;
}
// GetSize() -> u64 size
public long GetSize(ServiceCtx context)
{
context.ResponseData.Write(_baseStorage.GetSize());
return 0;
}
}
}