Revert LibHac update
Users are facing save destruction on failing extra data update apparently
This commit is contained in:
parent
997380d48c
commit
208ba1dde2
32 changed files with 575 additions and 1805 deletions
|
@ -1,19 +1,21 @@
|
|||
using LibHac;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.FsSrv.Sf;
|
||||
using LibHac.Fs.Fsa;
|
||||
using static Ryujinx.HLE.Utilities.StringUtils;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
{
|
||||
class IFileSystem : DisposableIpcService
|
||||
class IFileSystem : IpcService
|
||||
{
|
||||
private ReferenceCountedDisposable<LibHac.FsSrv.Sf.IFileSystem> _fileSystem;
|
||||
private LibHac.Fs.Fsa.IFileSystem _fileSystem;
|
||||
|
||||
public IFileSystem(ReferenceCountedDisposable<LibHac.FsSrv.Sf.IFileSystem> provider)
|
||||
public IFileSystem(LibHac.Fs.Fsa.IFileSystem provider)
|
||||
{
|
||||
_fileSystem = provider;
|
||||
}
|
||||
|
||||
public ReferenceCountedDisposable<LibHac.FsSrv.Sf.IFileSystem> GetBaseFileSystem()
|
||||
public LibHac.Fs.Fsa.IFileSystem GetBaseFileSystem()
|
||||
{
|
||||
return _fileSystem;
|
||||
}
|
||||
|
@ -22,79 +24,79 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
|||
// CreateFile(u32 createOption, u64 size, buffer<bytes<0x301>, 0x19, 0x301> path)
|
||||
public ResultCode CreateFile(ServiceCtx context)
|
||||
{
|
||||
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
|
||||
U8Span name = ReadUtf8Span(context);
|
||||
|
||||
int createOption = context.RequestData.ReadInt32();
|
||||
CreateFileOptions createOption = (CreateFileOptions)context.RequestData.ReadInt32();
|
||||
context.RequestData.BaseStream.Position += 4;
|
||||
|
||||
long size = context.RequestData.ReadInt64();
|
||||
|
||||
return (ResultCode)_fileSystem.Target.CreateFile(in name, size, createOption).Value;
|
||||
return (ResultCode)_fileSystem.CreateFile(name, size, createOption).Value;
|
||||
}
|
||||
|
||||
[CommandHipc(1)]
|
||||
// DeleteFile(buffer<bytes<0x301>, 0x19, 0x301> path)
|
||||
public ResultCode DeleteFile(ServiceCtx context)
|
||||
{
|
||||
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
|
||||
U8Span name = ReadUtf8Span(context);
|
||||
|
||||
return (ResultCode)_fileSystem.Target.DeleteFile(in name).Value;
|
||||
return (ResultCode)_fileSystem.DeleteFile(name).Value;
|
||||
}
|
||||
|
||||
[CommandHipc(2)]
|
||||
// CreateDirectory(buffer<bytes<0x301>, 0x19, 0x301> path)
|
||||
public ResultCode CreateDirectory(ServiceCtx context)
|
||||
{
|
||||
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
|
||||
U8Span name = ReadUtf8Span(context);
|
||||
|
||||
return (ResultCode)_fileSystem.Target.CreateDirectory(in name).Value;
|
||||
return (ResultCode)_fileSystem.CreateDirectory(name).Value;
|
||||
}
|
||||
|
||||
[CommandHipc(3)]
|
||||
// DeleteDirectory(buffer<bytes<0x301>, 0x19, 0x301> path)
|
||||
public ResultCode DeleteDirectory(ServiceCtx context)
|
||||
{
|
||||
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
|
||||
U8Span name = ReadUtf8Span(context);
|
||||
|
||||
return (ResultCode)_fileSystem.Target.DeleteDirectory(in name).Value;
|
||||
return (ResultCode)_fileSystem.DeleteDirectory(name).Value;
|
||||
}
|
||||
|
||||
[CommandHipc(4)]
|
||||
// DeleteDirectoryRecursively(buffer<bytes<0x301>, 0x19, 0x301> path)
|
||||
public ResultCode DeleteDirectoryRecursively(ServiceCtx context)
|
||||
{
|
||||
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
|
||||
U8Span name = ReadUtf8Span(context);
|
||||
|
||||
return (ResultCode)_fileSystem.Target.DeleteDirectoryRecursively(in name).Value;
|
||||
return (ResultCode)_fileSystem.DeleteDirectoryRecursively(name).Value;
|
||||
}
|
||||
|
||||
[CommandHipc(5)]
|
||||
// RenameFile(buffer<bytes<0x301>, 0x19, 0x301> oldPath, buffer<bytes<0x301>, 0x19, 0x301> newPath)
|
||||
public ResultCode RenameFile(ServiceCtx context)
|
||||
{
|
||||
ref readonly Path currentName = ref FileSystemProxyHelper.GetSfPath(context, index: 0);
|
||||
ref readonly Path newName = ref FileSystemProxyHelper.GetSfPath(context, index: 1);
|
||||
U8Span oldName = ReadUtf8Span(context, 0);
|
||||
U8Span newName = ReadUtf8Span(context, 1);
|
||||
|
||||
return (ResultCode)_fileSystem.Target.RenameFile(in currentName, in newName).Value;
|
||||
return (ResultCode)_fileSystem.RenameFile(oldName, newName).Value;
|
||||
}
|
||||
|
||||
[CommandHipc(6)]
|
||||
// RenameDirectory(buffer<bytes<0x301>, 0x19, 0x301> oldPath, buffer<bytes<0x301>, 0x19, 0x301> newPath)
|
||||
public ResultCode RenameDirectory(ServiceCtx context)
|
||||
{
|
||||
ref readonly Path currentName = ref FileSystemProxyHelper.GetSfPath(context, index: 0);
|
||||
ref readonly Path newName = ref FileSystemProxyHelper.GetSfPath(context, index: 1);
|
||||
U8Span oldName = ReadUtf8Span(context, 0);
|
||||
U8Span newName = ReadUtf8Span(context, 1);
|
||||
|
||||
return (ResultCode)_fileSystem.Target.RenameDirectory(in currentName, in newName).Value;
|
||||
return (ResultCode)_fileSystem.RenameDirectory(oldName, newName).Value;
|
||||
}
|
||||
|
||||
[CommandHipc(7)]
|
||||
// GetEntryType(buffer<bytes<0x301>, 0x19, 0x301> path) -> nn::fssrv::sf::DirectoryEntryType
|
||||
public ResultCode GetEntryType(ServiceCtx context)
|
||||
{
|
||||
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
|
||||
U8Span name = ReadUtf8Span(context);
|
||||
|
||||
Result result = _fileSystem.Target.GetEntryType(out uint entryType, in name);
|
||||
Result result = _fileSystem.GetEntryType(out DirectoryEntryType entryType, name);
|
||||
|
||||
context.ResponseData.Write((int)entryType);
|
||||
|
||||
|
@ -105,11 +107,11 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
|||
// OpenFile(u32 mode, buffer<bytes<0x301>, 0x19, 0x301> path) -> object<nn::fssrv::sf::IFile> file
|
||||
public ResultCode OpenFile(ServiceCtx context)
|
||||
{
|
||||
uint mode = context.RequestData.ReadUInt32();
|
||||
OpenMode mode = (OpenMode)context.RequestData.ReadInt32();
|
||||
|
||||
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
|
||||
U8Span name = ReadUtf8Span(context);
|
||||
|
||||
Result result = _fileSystem.Target.OpenFile(out ReferenceCountedDisposable<LibHac.FsSrv.Sf.IFile> file, in name, mode);
|
||||
Result result = _fileSystem.OpenFile(out LibHac.Fs.Fsa.IFile file, name, mode);
|
||||
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
|
@ -125,11 +127,11 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
|||
// OpenDirectory(u32 filter_flags, buffer<bytes<0x301>, 0x19, 0x301> path) -> object<nn::fssrv::sf::IDirectory> directory
|
||||
public ResultCode OpenDirectory(ServiceCtx context)
|
||||
{
|
||||
uint mode = context.RequestData.ReadUInt32();
|
||||
OpenDirectoryMode mode = (OpenDirectoryMode)context.RequestData.ReadInt32();
|
||||
|
||||
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
|
||||
U8Span name = ReadUtf8Span(context);
|
||||
|
||||
Result result = _fileSystem.Target.OpenDirectory(out ReferenceCountedDisposable<LibHac.FsSrv.Sf.IDirectory> dir, name, mode);
|
||||
Result result = _fileSystem.OpenDirectory(out LibHac.Fs.Fsa.IDirectory dir, name, mode);
|
||||
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
|
@ -145,16 +147,16 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
|||
// Commit()
|
||||
public ResultCode Commit(ServiceCtx context)
|
||||
{
|
||||
return (ResultCode)_fileSystem.Target.Commit().Value;
|
||||
return (ResultCode)_fileSystem.Commit().Value;
|
||||
}
|
||||
|
||||
[CommandHipc(11)]
|
||||
// GetFreeSpaceSize(buffer<bytes<0x301>, 0x19, 0x301> path) -> u64 totalFreeSpace
|
||||
public ResultCode GetFreeSpaceSize(ServiceCtx context)
|
||||
{
|
||||
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
|
||||
U8Span name = ReadUtf8Span(context);
|
||||
|
||||
Result result = _fileSystem.Target.GetFreeSpaceSize(out long size, in name);
|
||||
Result result = _fileSystem.GetFreeSpaceSize(out long size, name);
|
||||
|
||||
context.ResponseData.Write(size);
|
||||
|
||||
|
@ -165,9 +167,9 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
|||
// GetTotalSpaceSize(buffer<bytes<0x301>, 0x19, 0x301> path) -> u64 totalSize
|
||||
public ResultCode GetTotalSpaceSize(ServiceCtx context)
|
||||
{
|
||||
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
|
||||
U8Span name = ReadUtf8Span(context);
|
||||
|
||||
Result result = _fileSystem.Target.GetTotalSpaceSize(out long size, in name);
|
||||
Result result = _fileSystem.GetTotalSpaceSize(out long size, name);
|
||||
|
||||
context.ResponseData.Write(size);
|
||||
|
||||
|
@ -178,18 +180,18 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
|||
// CleanDirectoryRecursively(buffer<bytes<0x301>, 0x19, 0x301> path)
|
||||
public ResultCode CleanDirectoryRecursively(ServiceCtx context)
|
||||
{
|
||||
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
|
||||
U8Span name = ReadUtf8Span(context);
|
||||
|
||||
return (ResultCode)_fileSystem.Target.CleanDirectoryRecursively(in name).Value;
|
||||
return (ResultCode)_fileSystem.CleanDirectoryRecursively(name).Value;
|
||||
}
|
||||
|
||||
[CommandHipc(14)]
|
||||
// GetFileTimeStampRaw(buffer<bytes<0x301>, 0x19, 0x301> path) -> bytes<0x20> timestamp
|
||||
public ResultCode GetFileTimeStampRaw(ServiceCtx context)
|
||||
{
|
||||
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
|
||||
U8Span name = ReadUtf8Span(context);
|
||||
|
||||
Result result = _fileSystem.Target.GetFileTimeStampRaw(out FileTimeStampRaw timestamp, in name);
|
||||
Result result = _fileSystem.GetFileTimeStampRaw(out FileTimeStampRaw timestamp, name);
|
||||
|
||||
context.ResponseData.Write(timestamp.Created);
|
||||
context.ResponseData.Write(timestamp.Modified);
|
||||
|
@ -204,13 +206,5 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
|||
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
if (isDisposing)
|
||||
{
|
||||
_fileSystem?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue