diff options
author | Alex Barney <thealexbarney@gmail.com> | 2021-08-12 14:56:24 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-12 23:56:24 +0200 |
commit | dadc0e59daa89c4dd7f0c3356f302481a4e75e6d (patch) | |
tree | e39b6cd5198fef1fb2fe3461072b0961fd63502d /Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/FileSystemProxyHelper.cs | |
parent | 3977d1f72b8f091443018b68277044a840931054 (diff) |
Update to LibHac 0.13.1 (#2475)
* Update to LibHac 0.13.1
* Recreate directories for indexed saves if they're missing on emulator start
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/FileSystemProxyHelper.cs')
-rw-r--r-- | Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/FileSystemProxyHelper.cs | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/FileSystemProxyHelper.cs b/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/FileSystemProxyHelper.cs index 7774af23..1b6c84c3 100644 --- a/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/FileSystemProxyHelper.cs +++ b/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/FileSystemProxyHelper.cs @@ -1,10 +1,16 @@ using LibHac; using LibHac.Common; +using LibHac.Common.Keys; using LibHac.Fs; +using LibHac.FsSrv.Impl; +using LibHac.FsSrv.Sf; using LibHac.FsSystem; using LibHac.FsSystem.NcaUtils; using LibHac.Spl; +using System; using System.IO; +using System.Runtime.InteropServices; +using Path = System.IO.Path; namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy { @@ -16,12 +22,12 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy try { - LocalStorage storage = new LocalStorage(pfsPath, FileAccess.Read, FileMode.Open); - PartitionFileSystem nsp = new PartitionFileSystem(storage); + LocalStorage storage = new LocalStorage(pfsPath, FileAccess.Read, FileMode.Open); + ReferenceCountedDisposable<LibHac.Fs.Fsa.IFileSystem> nsp = new(new PartitionFileSystem(storage)); - ImportTitleKeysFromNsp(nsp, context.Device.System.KeySet); + ImportTitleKeysFromNsp(nsp.Target, context.Device.System.KeySet); - openedFileSystem = new IFileSystem(nsp); + openedFileSystem = new IFileSystem(FileSystemInterfaceAdapter.CreateShared(ref nsp)); } catch (HorizonResultException ex) { @@ -45,8 +51,9 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy } LibHac.Fs.Fsa.IFileSystem fileSystem = nca.OpenFileSystem(NcaSectionType.Data, context.Device.System.FsIntegrityCheckLevel); + var sharedFs = new ReferenceCountedDisposable<LibHac.Fs.Fsa.IFileSystem>(fileSystem); - openedFileSystem = new IFileSystem(fileSystem); + openedFileSystem = new IFileSystem(FileSystemInterfaceAdapter.CreateShared(ref sharedFs)); } catch (HorizonResultException ex) { @@ -99,7 +106,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy return ResultCode.PathDoesNotExist; } - public static void ImportTitleKeysFromNsp(LibHac.Fs.Fsa.IFileSystem nsp, Keyset keySet) + public static void ImportTitleKeysFromNsp(LibHac.Fs.Fsa.IFileSystem nsp, KeySet keySet) { foreach (DirectoryEntryEx ticketEntry in nsp.EnumerateEntries("/", "*.tik")) { @@ -125,5 +132,27 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy return FsPath.FromSpan(out path, pathBytes); } + + public static ref readonly FspPath GetFspPath(ServiceCtx context, int index = 0) + { + ulong position = (ulong)context.Request.PtrBuff[index].Position; + ulong size = (ulong)context.Request.PtrBuff[index].Size; + + ReadOnlySpan<byte> buffer = context.Memory.GetSpan(position, (int)size); + ReadOnlySpan<FspPath> fspBuffer = MemoryMarshal.Cast<byte, FspPath>(buffer); + + return ref fspBuffer[0]; + } + + public static ref readonly LibHac.FsSrv.Sf.Path GetSfPath(ServiceCtx context, int index = 0) + { + ulong position = (ulong)context.Request.PtrBuff[index].Position; + ulong size = (ulong)context.Request.PtrBuff[index].Size; + + ReadOnlySpan<byte> buffer = context.Memory.GetSpan(position, (int)size); + ReadOnlySpan<LibHac.FsSrv.Sf.Path> pathBuffer = MemoryMarshal.Cast<byte, LibHac.FsSrv.Sf.Path>(buffer); + + return ref pathBuffer[0]; + } } } |