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
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
using LibHac;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.NcaUtils;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.FsSystem.NcaUtils;
|
||||
using LibHac.Spl;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
using Ryujinx.HLE.Utilities;
|
||||
@ -25,7 +27,14 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
try
|
||||
{
|
||||
LocalFileSystem fileSystem = new LocalFileSystem(savePath);
|
||||
LibHac.Fs.IFileSystem saveFileSystem = new DirectorySaveDataFileSystem(fileSystem);
|
||||
|
||||
Result result = DirectorySaveDataFileSystem.CreateNew(out DirectorySaveDataFileSystem dirFileSystem, fileSystem);
|
||||
if (result.IsFailure())
|
||||
{
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
|
||||
LibHac.Fs.IFileSystem saveFileSystem = dirFileSystem;
|
||||
|
||||
if (readOnly)
|
||||
{
|
||||
@ -111,13 +120,16 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
PartitionFileSystem nsp = new PartitionFileSystem(pfsFile.AsStorage());
|
||||
|
||||
ImportTitleKeysFromNsp(nsp, context.Device.System.KeySet);
|
||||
|
||||
|
||||
string filename = fullPath.Replace(archivePath.FullName, string.Empty).TrimStart('\\');
|
||||
|
||||
if (nsp.FileExists(filename))
|
||||
Result result = nsp.OpenFile(out LibHac.Fs.IFile ncaFile, filename, OpenMode.Read);
|
||||
if (result.IsFailure())
|
||||
{
|
||||
return OpenNcaFs(context, fullPath, nsp.OpenFile(filename, OpenMode.Read).AsStorage(), out openedFileSystem);
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
|
||||
return OpenNcaFs(context, fullPath, ncaFile.AsStorage(), out openedFileSystem);
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
@ -130,15 +142,17 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
|
||||
public static void ImportTitleKeysFromNsp(LibHac.Fs.IFileSystem nsp, Keyset keySet)
|
||||
{
|
||||
foreach (DirectoryEntry ticketEntry in nsp.EnumerateEntries("*.tik"))
|
||||
foreach (DirectoryEntryEx ticketEntry in nsp.EnumerateEntries("/", "*.tik"))
|
||||
{
|
||||
Ticket ticket = new Ticket(nsp.OpenFile(ticketEntry.FullPath, OpenMode.Read).AsStream());
|
||||
Result result = nsp.OpenFile(out LibHac.Fs.IFile ticketFile, ticketEntry.FullPath, OpenMode.Read);
|
||||
|
||||
if (!keySet.TitleKeys.ContainsKey(ticket.RightsId))
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
keySet.TitleKeys.Add(ticket.RightsId, ticket.GetTitleKey(keySet));
|
||||
Ticket ticket = new Ticket(ticketFile.AsStream());
|
||||
|
||||
keySet.ExternalKeySet.Add(new RightsId(ticket.RightsId), new AccessKey(ticket.GetTitleKey(keySet)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,17 @@
|
||||
using LibHac;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using LibHac.Fs;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
{
|
||||
class IDirectory : IpcService
|
||||
{
|
||||
private const int DirectoryEntrySize = 0x310;
|
||||
|
||||
private IEnumerator<LibHac.Fs.DirectoryEntry> _enumerator;
|
||||
|
||||
private LibHac.Fs.IDirectory _baseDirectory;
|
||||
|
||||
public IDirectory(LibHac.Fs.IDirectory directory)
|
||||
{
|
||||
_baseDirectory = directory;
|
||||
_enumerator = directory.Read().GetEnumerator();
|
||||
}
|
||||
|
||||
[Command(0)]
|
||||
@ -25,60 +21,26 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
long bufferPosition = context.Request.ReceiveBuff[0].Position;
|
||||
long bufferLen = context.Request.ReceiveBuff[0].Size;
|
||||
|
||||
int maxReadCount = (int)(bufferLen / DirectoryEntrySize);
|
||||
int readCount = 0;
|
||||
byte[] entriesBytes = new byte[bufferLen];
|
||||
Span<DirectoryEntry> entries = MemoryMarshal.Cast<byte, DirectoryEntry>(entriesBytes);
|
||||
|
||||
try
|
||||
{
|
||||
while (readCount < maxReadCount && _enumerator.MoveNext())
|
||||
{
|
||||
long position = bufferPosition + readCount * DirectoryEntrySize;
|
||||
Result result = _baseDirectory.Read(out long entriesRead, entries);
|
||||
|
||||
WriteDirectoryEntry(context, position, _enumerator.Current);
|
||||
context.Memory.WriteBytes(bufferPosition, entriesBytes);
|
||||
context.ResponseData.Write(entriesRead);
|
||||
|
||||
readCount++;
|
||||
}
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
context.ResponseData.Write((long)readCount);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
private void WriteDirectoryEntry(ServiceCtx context, long position, LibHac.Fs.DirectoryEntry entry)
|
||||
{
|
||||
for (int offset = 0; offset < 0x300; offset += 8)
|
||||
{
|
||||
context.Memory.WriteInt64(position + offset, 0);
|
||||
}
|
||||
|
||||
byte[] nameBuffer = Encoding.UTF8.GetBytes(entry.Name);
|
||||
|
||||
context.Memory.WriteBytes(position, nameBuffer);
|
||||
|
||||
context.Memory.WriteInt32(position + 0x300, (int)entry.Attributes);
|
||||
context.Memory.WriteInt32(position + 0x304, (byte)entry.Type);
|
||||
context.Memory.WriteInt64(position + 0x308, entry.Size);
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
|
||||
[Command(1)]
|
||||
// GetEntryCount() -> u64
|
||||
public ResultCode GetEntryCount(ServiceCtx context)
|
||||
{
|
||||
try
|
||||
{
|
||||
context.ResponseData.Write((long)_baseDirectory.GetEntryCount());
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
Result result = _baseDirectory.GetEntryCount(out long entryCount);
|
||||
|
||||
return ResultCode.Success;
|
||||
context.ResponseData.Write(entryCount);
|
||||
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,22 +26,14 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
long size = context.RequestData.ReadInt64();
|
||||
|
||||
byte[] data = new byte[size];
|
||||
int readSize;
|
||||
|
||||
try
|
||||
{
|
||||
readSize = _baseFile.Read(data, offset, readOption);
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
Result result = _baseFile.Read(out long bytesRead, offset, data, readOption);
|
||||
|
||||
context.Memory.WriteBytes(position, data);
|
||||
|
||||
context.ResponseData.Write((long)readSize);
|
||||
context.ResponseData.Write(bytesRead);
|
||||
|
||||
return ResultCode.Success;
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
|
||||
[Command(1)]
|
||||
@ -58,66 +50,34 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
|
||||
byte[] data = context.Memory.ReadBytes(position, size);
|
||||
|
||||
try
|
||||
{
|
||||
_baseFile.Write(data, offset, writeOption);
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return ResultCode.Success;
|
||||
return (ResultCode)_baseFile.Write(offset, data, writeOption).Value;
|
||||
}
|
||||
|
||||
[Command(2)]
|
||||
// Flush()
|
||||
public ResultCode Flush(ServiceCtx context)
|
||||
{
|
||||
try
|
||||
{
|
||||
_baseFile.Flush();
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return ResultCode.Success;
|
||||
return (ResultCode)_baseFile.Flush().Value;
|
||||
}
|
||||
|
||||
[Command(3)]
|
||||
// SetSize(u64 size)
|
||||
public ResultCode SetSize(ServiceCtx context)
|
||||
{
|
||||
try
|
||||
{
|
||||
long size = context.RequestData.ReadInt64();
|
||||
long size = context.RequestData.ReadInt64();
|
||||
|
||||
_baseFile.SetSize(size);
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return ResultCode.Success;
|
||||
return (ResultCode)_baseFile.SetSize(size).Value;
|
||||
}
|
||||
|
||||
[Command(4)]
|
||||
// GetSize() -> u64 fileSize
|
||||
public ResultCode GetSize(ServiceCtx context)
|
||||
{
|
||||
try
|
||||
{
|
||||
context.ResponseData.Write(_baseFile.GetSize());
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
Result result = _baseFile.GetSize(out long size);
|
||||
|
||||
return ResultCode.Success;
|
||||
context.ResponseData.Write(size);
|
||||
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
@ -25,16 +25,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
|
||||
long size = context.RequestData.ReadInt64();
|
||||
|
||||
try
|
||||
{
|
||||
_fileSystem.CreateFile(name, size, createOption);
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return ResultCode.Success;
|
||||
return (ResultCode)_fileSystem.CreateFile(name, size, createOption).Value;
|
||||
}
|
||||
|
||||
[Command(1)]
|
||||
@ -43,16 +34,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
{
|
||||
string name = ReadUtf8String(context);
|
||||
|
||||
try
|
||||
{
|
||||
_fileSystem.DeleteFile(name);
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return ResultCode.Success;
|
||||
return (ResultCode)_fileSystem.DeleteFile(name).Value;
|
||||
}
|
||||
|
||||
[Command(2)]
|
||||
@ -61,16 +43,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
{
|
||||
string name = ReadUtf8String(context);
|
||||
|
||||
try
|
||||
{
|
||||
_fileSystem.CreateDirectory(name);
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return ResultCode.Success;
|
||||
return (ResultCode)_fileSystem.CreateDirectory(name).Value;
|
||||
}
|
||||
|
||||
[Command(3)]
|
||||
@ -79,16 +52,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
{
|
||||
string name = ReadUtf8String(context);
|
||||
|
||||
try
|
||||
{
|
||||
_fileSystem.DeleteDirectory(name);
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return ResultCode.Success;
|
||||
return (ResultCode)_fileSystem.DeleteDirectory(name).Value;
|
||||
}
|
||||
|
||||
[Command(4)]
|
||||
@ -97,16 +61,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
{
|
||||
string name = ReadUtf8String(context);
|
||||
|
||||
try
|
||||
{
|
||||
_fileSystem.DeleteDirectoryRecursively(name);
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return ResultCode.Success;
|
||||
return (ResultCode)_fileSystem.DeleteDirectoryRecursively(name).Value;
|
||||
}
|
||||
|
||||
[Command(5)]
|
||||
@ -116,16 +71,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
string oldName = ReadUtf8String(context, 0);
|
||||
string newName = ReadUtf8String(context, 1);
|
||||
|
||||
try
|
||||
{
|
||||
_fileSystem.RenameFile(oldName, newName);
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return ResultCode.Success;
|
||||
return (ResultCode)_fileSystem.RenameFile(oldName, newName).Value;
|
||||
}
|
||||
|
||||
[Command(6)]
|
||||
@ -135,16 +81,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
string oldName = ReadUtf8String(context, 0);
|
||||
string newName = ReadUtf8String(context, 1);
|
||||
|
||||
try
|
||||
{
|
||||
_fileSystem.RenameDirectory(oldName, newName);
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return ResultCode.Success;
|
||||
return (ResultCode)_fileSystem.RenameDirectory(oldName, newName).Value;
|
||||
}
|
||||
|
||||
[Command(7)]
|
||||
@ -153,25 +90,11 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
{
|
||||
string name = ReadUtf8String(context);
|
||||
|
||||
try
|
||||
{
|
||||
DirectoryEntryType entryType = _fileSystem.GetEntryType(name);
|
||||
Result result = _fileSystem.GetEntryType(out DirectoryEntryType entryType, name);
|
||||
|
||||
if (entryType == DirectoryEntryType.Directory || entryType == DirectoryEntryType.File)
|
||||
{
|
||||
context.ResponseData.Write((int)entryType);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ResultCode.PathDoesNotExist;
|
||||
}
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
context.ResponseData.Write((int)entryType);
|
||||
|
||||
return ResultCode.Success;
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
|
||||
[Command(8)]
|
||||
@ -182,20 +105,16 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
|
||||
string name = ReadUtf8String(context);
|
||||
|
||||
try
|
||||
{
|
||||
LibHac.Fs.IFile file = _fileSystem.OpenFile(name, mode);
|
||||
Result result = _fileSystem.OpenFile(out LibHac.Fs.IFile file, name, mode);
|
||||
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
IFile fileInterface = new IFile(file);
|
||||
|
||||
MakeObject(context, fileInterface);
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return ResultCode.Success;
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
|
||||
[Command(9)]
|
||||
@ -206,36 +125,23 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
|
||||
string name = ReadUtf8String(context);
|
||||
|
||||
try
|
||||
{
|
||||
LibHac.Fs.IDirectory dir = _fileSystem.OpenDirectory(name, mode);
|
||||
Result result = _fileSystem.OpenDirectory(out LibHac.Fs.IDirectory dir, name, mode);
|
||||
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
IDirectory dirInterface = new IDirectory(dir);
|
||||
|
||||
MakeObject(context, dirInterface);
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return ResultCode.Success;
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
|
||||
[Command(10)]
|
||||
// Commit()
|
||||
public ResultCode Commit(ServiceCtx context)
|
||||
{
|
||||
try
|
||||
{
|
||||
_fileSystem.Commit();
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return ResultCode.Success;
|
||||
return (ResultCode)_fileSystem.Commit().Value;
|
||||
}
|
||||
|
||||
[Command(11)]
|
||||
@ -244,16 +150,11 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
{
|
||||
string name = ReadUtf8String(context);
|
||||
|
||||
try
|
||||
{
|
||||
context.ResponseData.Write(_fileSystem.GetFreeSpaceSize(name));
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
Result result = _fileSystem.GetFreeSpaceSize(out long size, name);
|
||||
|
||||
return ResultCode.Success;
|
||||
context.ResponseData.Write(size);
|
||||
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
|
||||
[Command(12)]
|
||||
@ -262,16 +163,11 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
{
|
||||
string name = ReadUtf8String(context);
|
||||
|
||||
try
|
||||
{
|
||||
context.ResponseData.Write(_fileSystem.GetTotalSpaceSize(name));
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
Result result = _fileSystem.GetTotalSpaceSize(out long size, name);
|
||||
|
||||
return ResultCode.Success;
|
||||
context.ResponseData.Write(size);
|
||||
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
|
||||
[Command(13)]
|
||||
@ -280,16 +176,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
{
|
||||
string name = ReadUtf8String(context);
|
||||
|
||||
try
|
||||
{
|
||||
_fileSystem.CleanDirectoryRecursively(name);
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return ResultCode.Success;
|
||||
return (ResultCode)_fileSystem.CleanDirectoryRecursively(name).Value;
|
||||
}
|
||||
|
||||
[Command(14)]
|
||||
@ -298,27 +185,20 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
{
|
||||
string name = ReadUtf8String(context);
|
||||
|
||||
try
|
||||
{
|
||||
FileTimeStampRaw timestamp = _fileSystem.GetFileTimeStampRaw(name);
|
||||
Result result = _fileSystem.GetFileTimeStampRaw(out FileTimeStampRaw timestamp, name);
|
||||
|
||||
context.ResponseData.Write(timestamp.Created);
|
||||
context.ResponseData.Write(timestamp.Modified);
|
||||
context.ResponseData.Write(timestamp.Accessed);
|
||||
context.ResponseData.Write(timestamp.Created);
|
||||
context.ResponseData.Write(timestamp.Modified);
|
||||
context.ResponseData.Write(timestamp.Accessed);
|
||||
|
||||
byte[] data = new byte[8];
|
||||
byte[] data = new byte[8];
|
||||
|
||||
// is valid?
|
||||
data[0] = 1;
|
||||
// is valid?
|
||||
data[0] = 1;
|
||||
|
||||
context.ResponseData.Write(data);
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
context.ResponseData.Write(data);
|
||||
|
||||
return ResultCode.Success;
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
}
|
||||
}
|
@ -31,16 +31,11 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
|
||||
byte[] data = new byte[size];
|
||||
|
||||
try
|
||||
{
|
||||
_baseStorage.Read(data, offset);
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
Result result = _baseStorage.Read(offset, data);
|
||||
|
||||
context.Memory.WriteBytes(buffDesc.Position, data);
|
||||
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
|
||||
return ResultCode.Success;
|
||||
@ -50,16 +45,11 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
// GetSize() -> u64 size
|
||||
public ResultCode GetSize(ServiceCtx context)
|
||||
{
|
||||
try
|
||||
{
|
||||
context.ResponseData.Write(_baseStorage.GetSize());
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
Result result = _baseStorage.GetSize(out long size);
|
||||
|
||||
return ResultCode.Success;
|
||||
context.ResponseData.Write(size);
|
||||
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
}
|
||||
}
|
37
Ryujinx.HLE/HOS/Services/Fs/IDeviceOperator.cs
Normal file
37
Ryujinx.HLE/HOS/Services/Fs/IDeviceOperator.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using LibHac;
|
||||
using LibHac.FsService;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Fs
|
||||
{
|
||||
class IDeviceOperator : IpcService
|
||||
{
|
||||
private LibHac.FsService.IDeviceOperator _baseOperator;
|
||||
|
||||
public IDeviceOperator(LibHac.FsService.IDeviceOperator baseOperator)
|
||||
{
|
||||
_baseOperator = baseOperator;
|
||||
}
|
||||
|
||||
[Command(200)]
|
||||
// IsGameCardInserted() -> b8 is_inserted
|
||||
public ResultCode IsGameCardInserted(ServiceCtx context)
|
||||
{
|
||||
Result result = _baseOperator.IsGameCardInserted(out bool isInserted);
|
||||
|
||||
context.ResponseData.Write(isInserted);
|
||||
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
|
||||
[Command(202)]
|
||||
// GetGameCardHandle() -> u32 gamecard_handle
|
||||
public ResultCode GetGameCardHandle(ServiceCtx context)
|
||||
{
|
||||
Result result = _baseOperator.GetGameCardHandle(out GameCardHandle handle);
|
||||
|
||||
context.ResponseData.Write(handle.Value);
|
||||
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
using LibHac;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.NcaUtils;
|
||||
using LibHac.FsService;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.FsSystem.NcaUtils;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
using Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy;
|
||||
@ -14,7 +16,12 @@ namespace Ryujinx.HLE.HOS.Services.Fs
|
||||
[Service("fsp-srv")]
|
||||
class IFileSystemProxy : IpcService
|
||||
{
|
||||
public IFileSystemProxy(ServiceCtx context) { }
|
||||
private LibHac.FsService.IFileSystemProxy _baseFileSystemProxy;
|
||||
|
||||
public IFileSystemProxy(ServiceCtx context)
|
||||
{
|
||||
_baseFileSystemProxy = context.Device.System.FsServer.CreateFileSystemProxyService();
|
||||
}
|
||||
|
||||
[Command(1)]
|
||||
// Initialize(u64, pid)
|
||||
@ -125,6 +132,23 @@ namespace Ryujinx.HLE.HOS.Services.Fs
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[Command(30)]
|
||||
// OpenGameCardStorage(u32, u32) -> object<nn::fssrv::sf::IStorage>
|
||||
public ResultCode OpenGameCardStorage(ServiceCtx context)
|
||||
{
|
||||
GameCardHandle handle = new GameCardHandle(context.RequestData.ReadInt32());
|
||||
GameCardPartitionRaw partitionId = (GameCardPartitionRaw)context.RequestData.ReadInt32();
|
||||
|
||||
Result result = _baseFileSystemProxy.OpenGameCardStorage(out LibHac.Fs.IStorage storage, handle, partitionId);
|
||||
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
MakeObject(context, new FileSystemProxy.IStorage(storage));
|
||||
}
|
||||
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
|
||||
[Command(51)]
|
||||
// OpenSaveDataFileSystem(u8 save_data_space_id, nn::fssrv::sf::SaveStruct saveStruct) -> object<nn::fssrv::sf::IFileSystem> saveDataFs
|
||||
public ResultCode OpenSaveDataFileSystem(ServiceCtx context)
|
||||
@ -184,14 +208,14 @@ namespace Ryujinx.HLE.HOS.Services.Fs
|
||||
byte[] padding = context.RequestData.ReadBytes(7);
|
||||
long titleId = context.RequestData.ReadInt64();
|
||||
|
||||
ContentType contentType = ContentType.Data;
|
||||
NcaContentType contentType = NcaContentType.Data;
|
||||
|
||||
StorageId installedStorage =
|
||||
context.Device.System.ContentManager.GetInstalledStorage(titleId, contentType, storageId);
|
||||
|
||||
if (installedStorage == StorageId.None)
|
||||
{
|
||||
contentType = ContentType.PublicData;
|
||||
contentType = NcaContentType.PublicData;
|
||||
|
||||
installedStorage =
|
||||
context.Device.System.ContentManager.GetInstalledStorage(titleId, contentType, storageId);
|
||||
@ -246,6 +270,20 @@ namespace Ryujinx.HLE.HOS.Services.Fs
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[Command(400)]
|
||||
// OpenDataStorageByCurrentProcess() -> object<nn::fssrv::sf::IStorage> dataStorage
|
||||
public ResultCode OpenDeviceOperator(ServiceCtx context)
|
||||
{
|
||||
Result result = _baseFileSystemProxy.OpenDeviceOperator(out LibHac.FsService.IDeviceOperator deviceOperator);
|
||||
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
MakeObject(context, new IDeviceOperator(deviceOperator));
|
||||
}
|
||||
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
|
||||
[Command(1005)]
|
||||
// GetGlobalAccessLogMode() -> u32 logMode
|
||||
public ResultCode GetGlobalAccessLogMode(ServiceCtx context)
|
||||
|
Reference in New Issue
Block a user