misc: chore: Use explicit types & fix object creation

This commit is contained in:
KeatonTheBot
2026-05-30 16:26:50 -05:00
parent 9d3fecf334
commit 76a123b81d
454 changed files with 3042 additions and 2961 deletions
@@ -26,7 +26,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
try
{
LocalStorage storage = new(pfsPath, FileAccess.Read, FileMode.Open);
var pfs = new PartitionFileSystem();
PartitionFileSystem pfs = new();
using SharedRef<LibHac.Fs.Fsa.IFileSystem> nsp = new(pfs);
pfs.Initialize(storage).ThrowIfFailure();
@@ -58,7 +58,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
}
LibHac.Fs.Fsa.IFileSystem fileSystem = nca.OpenFileSystem(NcaSectionType.Data, context.Device.System.FsIntegrityCheckLevel);
using var sharedFs = new SharedRef<LibHac.Fs.Fsa.IFileSystem>(fileSystem);
using SharedRef<LibHac.Fs.Fsa.IFileSystem> sharedFs = new(fileSystem);
using SharedRef<LibHac.FsSrv.Sf.IFileSystem> adapter = FileSystemInterfaceAdapter.CreateShared(ref sharedFs.Ref, true);
@@ -99,7 +99,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
string filename = fullPath.Replace(archivePath.FullName, string.Empty).TrimStart('\\');
using var ncaFile = new UniqueRef<LibHac.Fs.Fsa.IFile>();
using UniqueRef<LibHac.Fs.Fsa.IFile> ncaFile = new();
Result result = nsp.OpenFile(ref ncaFile.Ref, filename.ToU8Span(), OpenMode.Read);
if (result.IsFailure())
@@ -122,14 +122,14 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
foreach (DirectoryEntryEx ticketEntry in nsp.EnumerateEntries("/", "*.tik"))
{
using var ticketFile = new UniqueRef<LibHac.Fs.Fsa.IFile>();
using UniqueRef<LibHac.Fs.Fsa.IFile> ticketFile = new();
Result result = nsp.OpenFile(ref ticketFile.Ref, ticketEntry.FullPath.ToU8Span(), OpenMode.Read);
if (result.IsSuccess())
{
Ticket ticket = new(ticketFile.Get.AsStream());
var titleKey = ticket.GetTitleKey(keySet);
byte[] titleKey = ticket.GetTitleKey(keySet);
if (titleKey != null)
{
@@ -1,6 +1,7 @@
using LibHac;
using LibHac.Common;
using LibHac.Sf;
using Ryujinx.Memory;
namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
@@ -20,7 +21,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
ulong bufferAddress = context.Request.ReceiveBuff[0].Position;
ulong bufferLen = context.Request.ReceiveBuff[0].Size;
using var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true);
using WritableRegion region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true);
Result result = _baseDirectory.Get.Read(out long entriesRead, new OutBuffer(region.Memory.Span));
context.ResponseData.Write(entriesRead);
@@ -3,6 +3,7 @@ using LibHac.Common;
using LibHac.Fs;
using LibHac.Sf;
using Ryujinx.Common;
using Ryujinx.Memory;
namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
@@ -28,7 +29,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
long offset = context.RequestData.ReadInt64();
long size = context.RequestData.ReadInt64();
using var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true);
using WritableRegion region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true);
Result result = _baseFile.Get.Read(out long bytesRead, offset, new OutBuffer(region.Memory.Span), size, readOption);
context.ResponseData.Write(bytesRead);
@@ -111,7 +111,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
uint mode = context.RequestData.ReadUInt32();
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
using var file = new SharedRef<LibHac.FsSrv.Sf.IFile>();
using SharedRef<LibHac.FsSrv.Sf.IFile> file = new();
Result result = _fileSystem.Get.OpenFile(ref file.Ref, in name, mode);
@@ -132,7 +132,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
uint mode = context.RequestData.ReadUInt32();
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
using var dir = new SharedRef<LibHac.FsSrv.Sf.IDirectory>();
using SharedRef<LibHac.FsSrv.Sf.IDirectory> dir = new();
Result result = _fileSystem.Get.OpenDirectory(ref dir.Ref, in name, mode);
@@ -1,6 +1,7 @@
using LibHac;
using LibHac.Common;
using LibHac.Sf;
using Ryujinx.Memory;
namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
@@ -31,7 +32,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
size = bufferLen;
}
using var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true);
using WritableRegion region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true);
Result result = _baseStorage.Get.Read((long)offset, new OutBuffer(region.Memory.Span), (long)size);
return (ResultCode)result.Value;