Fixup ref readonly params to use in instead of ref

This commit is contained in:
Alex Barney 2024-05-07 22:23:32 -07:00
parent 6a5d03e1f3
commit 6599c5977b
59 changed files with 181 additions and 260 deletions

View file

@ -9,7 +9,6 @@ using System.Xml.Linq;
using ICSharpCode.SharpZipLib.Zip;
using Nuke.Common.IO;
using Nuke.Common.Tools.NuGet;
using static Nuke.Common.IO.FileSystemTasks;
namespace LibHacBuild;

View file

@ -36,7 +36,7 @@ public class BcatServer
using SharedRef<IServiceCreator> service = GetServiceCreator(type);
Result res = Hos.Sm.RegisterService(new BcatServiceObject(ref service.Ref), name);
Result res = Hos.Sm.RegisterService(new BcatServiceObject(in service), name);
if (res.IsFailure())
{
throw new HorizonResultException(res, "Abort");

View file

@ -661,7 +661,7 @@ public static class UserFileSystem
if (!fileSystem.HasValue)
return ResultFs.UnsupportedCommitTarget.Log();
res = commitManager.Get.Add(fileSystem.Ref);
res = commitManager.Get.Add(in fileSystem);
if (res.IsFailure()) return res.Miss();
}

View file

@ -1,5 +1,4 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.CompilerServices;
using LibHac.Diag;
using LibHac.Htc;
using LibHac.HtcFs;

View file

@ -64,8 +64,7 @@ public static class Application
Ncm.ProgramId.InvalidId.Value, FileSystemProxyType.Package);
if (res.IsFailure()) return res.Miss();
using var fileSystemAdapter =
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref));
using var fileSystemAdapter = new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
if (!fileSystemAdapter.HasValue)
return ResultFs.AllocationMemoryFailedInApplicationA.Log();

View file

@ -25,7 +25,7 @@ public static class BaseFileSystem
}
private static Result RegisterFileSystem(FileSystemClient fs, U8Span mountName,
ref SharedRef<IFileSystemSf> fileSystem)
ref readonly SharedRef<IFileSystemSf> fileSystem)
{
using var fileSystemAdapter =
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
@ -47,7 +47,7 @@ public static class BaseFileSystem
fs.Impl.AbortIfNeeded(res);
if (res.IsFailure()) return res.Miss();
res = RegisterFileSystem(fs, mountName, ref fileSystem.Ref);
res = RegisterFileSystem(fs, mountName, in fileSystem);
fs.Impl.AbortIfNeeded(res);
if (res.IsFailure()) return res.Miss();

View file

@ -67,8 +67,7 @@ public static class BcatSaveData
res = fileSystemProxy.Get.OpenSaveDataFileSystem(ref fileSystem.Ref, SaveDataSpaceId.User, in attribute);
if (res.IsFailure()) return res.Miss();
using var fileSystemAdapter =
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref));
using var fileSystemAdapter = new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
if (!fileSystemAdapter.HasValue)
return ResultFs.AllocationMemoryFailedInBcatSaveDataA.Log();

View file

@ -107,8 +107,7 @@ public static class Bis
if (!mountNameGenerator.HasValue)
return ResultFs.AllocationMemoryFailedInBisA.Log();
using var fileSystemAdapter =
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref));
using var fileSystemAdapter = new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
if (!fileSystemAdapter.HasValue)
return ResultFs.AllocationMemoryFailedInBisB.Log();
@ -174,7 +173,7 @@ public static class Bis
fs.Impl.AbortIfNeeded(res);
if (res.IsFailure()) return res.Miss();
using var storageAdapter = new UniqueRef<IStorage>(new StorageServiceObjectAdapter(ref storage.Ref));
using var storageAdapter = new UniqueRef<IStorage>(new StorageServiceObjectAdapter(in storage));
if (!storageAdapter.HasValue)
{

View file

@ -76,8 +76,7 @@ public static class Code
in sfPath, attributes, programId);
if (res.IsFailure()) return res.Miss();
using var fileSystemAdapter =
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref));
using var fileSystemAdapter = new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
if (!fileSystemAdapter.HasValue)
return ResultFs.AllocationMemoryFailedInCodeA.Log();

View file

@ -51,8 +51,7 @@ public static class Content
res = fileSystemProxy.Get.OpenFileSystemWithId(ref fileSystem.Ref, in sfPath, attributes, id, fsType);
if (res.IsFailure()) return res.Miss();
using var fileSystemAdapter =
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref));
using var fileSystemAdapter = new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
if (!fileSystemAdapter.HasValue)
return ResultFs.AllocationMemoryFailedInContentA.Log();
@ -253,8 +252,7 @@ public static class Content
res = fileSystemProxy.Get.OpenFileSystemWithPatch(ref fileSystem.Ref, programId, fsType);
if (res.IsFailure()) return res.Miss();
using var fileSystemAdapter =
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref));
using var fileSystemAdapter = new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
if (!fileSystemAdapter.HasValue)
return ResultFs.AllocationMemoryFailedInContentA.Log();

View file

@ -117,8 +117,7 @@ public static class ContentStorage
fs.Hos.Os.SleepThread(TimeSpan.FromMilliSeconds(retryInterval));
}
using var fileSystemAdapter =
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref));
using var fileSystemAdapter = new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
if (!fileSystemAdapter.HasValue)
return ResultFs.AllocationMemoryFailedInContentStorageA.Log();

View file

@ -50,8 +50,7 @@ public static class CustomStorage
res = fileSystemProxy.Get.OpenCustomStorageFileSystem(ref fileSystem.Ref, storageId);
if (res.IsFailure()) return res.Miss();
using var fileSystemAdapter =
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref));
using var fileSystemAdapter = new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
res = fs.Register(mountName, ref fileSystemAdapter.Ref);
if (res.IsFailure()) return res.Miss();

View file

@ -50,7 +50,7 @@ public static class DeviceSaveData
res = fileSystemProxy.Get.OpenSaveDataFileSystem(ref fileSystem.Ref, DeviceSaveDataSpaceId, in attribute);
if (res.IsFailure()) return res.Miss();
var fileSystemAdapterRaw = new FileSystemServiceObjectAdapter(ref fileSystem.Ref);
var fileSystemAdapterRaw = new FileSystemServiceObjectAdapter(in fileSystem);
using var fileSystemAdapter = new UniqueRef<IFileSystem>(fileSystemAdapterRaw);
if (!fileSystemAdapter.HasValue)

View file

@ -274,7 +274,7 @@ internal class FileSystemServiceObjectAdapter : IFileSystem, IMultiCommitTarget
res = _baseFs.Get.OpenDirectory(ref directoryServiceObject.Ref, in sfPath, (uint)mode);
if (res.IsFailure()) return res.Miss();
outDirectory.Reset(new DirectoryServiceObjectAdapter(ref directoryServiceObject.Ref));
outDirectory.Reset(new DirectoryServiceObjectAdapter(in directoryServiceObject));
return Result.Success;
}

View file

@ -139,8 +139,7 @@ public static class GameCard
res = fileSystemProxy.Get.OpenGameCardFileSystem(ref fileSystem.Ref, handle, partitionId);
if (res.IsFailure()) return res.Miss();
using var fileSystemAdapter =
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref));
using var fileSystemAdapter = new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
if (!fileSystemAdapter.HasValue)
return ResultFs.AllocationMemoryFailedInGameCardC.Log();
@ -181,7 +180,7 @@ public static class GameCard
fs.Impl.AbortIfNeeded(res);
if (res.IsFailure()) return res.Miss();
using var storageAdapter = new UniqueRef<IStorage>(new StorageServiceObjectAdapter(ref storage.Ref));
using var storageAdapter = new UniqueRef<IStorage>(new StorageServiceObjectAdapter(in storage));
if (!storageAdapter.HasValue)
return ResultFs.AllocationMemoryFailedInGameCardB.Log();

View file

@ -54,7 +54,7 @@ public static class Host
}
using var fileSystemAdapter =
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref));
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
if (!fileSystemAdapter.HasValue)
return ResultFs.AllocationMemoryFailedInHostA.Log();

View file

@ -59,8 +59,7 @@ public static class ImageDirectory
res = fileSystemProxy.Get.OpenImageDirectoryFileSystem(ref fileSystem.Ref, directoryId);
if (res.IsFailure()) return res.Miss();
using var fileSystemAdapter =
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref));
using var fileSystemAdapter = new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
if (!fileSystemAdapter.HasValue)
return ResultFs.AllocationMemoryFailedInImageDirectoryA.Log();

View file

@ -65,8 +65,7 @@ public static class Logo
FileSystemProxyType.Logo);
if (res.IsFailure()) return res.Miss();
using var fileSystemAdapter =
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref));
using var fileSystemAdapter = new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
if (!fileSystemAdapter.HasValue)
return ResultFs.AllocationMemoryFailedInLogoA.Log();

View file

@ -34,8 +34,7 @@ public static class SaveData
saveDataId);
if (res.IsFailure()) return res.Miss();
using var fileSystemAdapter =
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref));
using var fileSystemAdapter = new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
outFileSystem.Set(ref fileSystemAdapter.Ref);
@ -102,7 +101,7 @@ public static class SaveData
// Note: Nintendo does pass in the same object both as a unique_ptr and as a raw pointer.
// Both of these are tied to the lifetime of the created FileSystemServiceObjectAdapter so it shouldn't be an issue.
var fileSystemAdapterRaw = new FileSystemServiceObjectAdapter(ref fileSystem.Ref);
var fileSystemAdapterRaw = new FileSystemServiceObjectAdapter(in fileSystem);
using var fileSystemAdapter = new UniqueRef<IFileSystem>(fileSystemAdapterRaw);
if (!fileSystemAdapter.HasValue)

View file

@ -560,7 +560,7 @@ namespace LibHac.Fs.Shim
Result res = fileSystemProxy.Get.OpenSaveDataInfoReaderBySaveDataSpaceId(ref reader.Ref, spaceId);
if (res.IsFailure()) return res.Miss();
using var iterator = new UniqueRef<SaveDataIterator>(new SaveDataIterator(fs.Fs, ref reader.Ref));
using var iterator = new UniqueRef<SaveDataIterator>(new SaveDataIterator(fs.Fs, in reader));
if (!iterator.HasValue)
return ResultFs.AllocationMemoryFailedInSaveDataManagementA.Log();
@ -579,7 +579,7 @@ namespace LibHac.Fs.Shim
Result res = fileSystemProxy.Get.OpenSaveDataInfoReaderWithFilter(ref reader.Ref, spaceId, in filter);
if (res.IsFailure()) return res.Miss();
using var iterator = new UniqueRef<SaveDataIterator>(new SaveDataIterator(fs.Fs, ref reader.Ref));
using var iterator = new UniqueRef<SaveDataIterator>(new SaveDataIterator(fs.Fs, in reader));
if (!iterator.HasValue)
return ResultFs.AllocationMemoryFailedInSaveDataManagementA.Log();

View file

@ -178,7 +178,7 @@ public class SaveDataExporterVersion2 : ISaveDataDivisionExporter
_fsClient.Impl.AbortIfNeeded(res);
if (res.IsFailure()) return res.Miss();
outIterator.Reset(new SaveDataChunkIterator(_fsClient, ref iteratorObject.Ref));
outIterator.Reset(new SaveDataChunkIterator(_fsClient, in iteratorObject));
return Result.Success;
}
@ -190,7 +190,7 @@ public class SaveDataExporterVersion2 : ISaveDataDivisionExporter
_fsClient.Impl.AbortIfNeeded(res);
if (res.IsFailure()) return res.Miss();
outExporter.Reset(new SaveDataChunkExporter(_fsClient, ref exporterObject.Ref));
outExporter.Reset(new SaveDataChunkExporter(_fsClient, in exporterObject));
return Result.Success;
}
@ -404,7 +404,7 @@ public class SaveDataImporterVersion2 : ISaveDataDivisionImporter
_fsClient.Impl.AbortIfNeeded(res);
if (res.IsFailure()) return res.Miss();
outIterator.Reset(new SaveDataChunkIterator(_fsClient, ref iteratorObject.Ref));
outIterator.Reset(new SaveDataChunkIterator(_fsClient, in iteratorObject));
return Result.Success;
}
@ -416,7 +416,7 @@ public class SaveDataImporterVersion2 : ISaveDataDivisionImporter
_fsClient.Impl.AbortIfNeeded(res);
if (res.IsFailure()) return res.Miss();
outImporter.Reset(new SaveDataChunkImporter(_fsClient, ref importerObject.Ref));
outImporter.Reset(new SaveDataChunkImporter(_fsClient, in importerObject));
return Result.Success;
}

View file

@ -85,7 +85,7 @@ namespace LibHac.Fs
_fsClient.Impl.LogResultErrorMessage(res);
if (res.IsFailure()) return res.Miss();
outExporter.Reset(new SaveDataExporterVersion2(_fsClient, ref exporterInterface.Ref));
outExporter.Reset(new SaveDataExporterVersion2(_fsClient, in exporterInterface));
return Result.Success;
}
@ -100,7 +100,7 @@ namespace LibHac.Fs
_fsClient.Impl.LogResultErrorMessage(res);
if (res.IsFailure()) return res.Miss();
outExporter.Reset(new SaveDataExporterVersion2(_fsClient, ref exporterInterface.Ref));
outExporter.Reset(new SaveDataExporterVersion2(_fsClient, in exporterInterface));
return Result.Success;
}
@ -115,7 +115,7 @@ namespace LibHac.Fs
_fsClient.Impl.LogResultErrorMessage(res);
if (res.IsFailure()) return res.Miss();
outExporter.Reset(new SaveDataExporterVersion2(_fsClient, ref exporterInterface.Ref));
outExporter.Reset(new SaveDataExporterVersion2(_fsClient, in exporterInterface));
return Result.Success;
}
@ -130,7 +130,7 @@ namespace LibHac.Fs
_fsClient.Impl.LogResultErrorMessage(res);
if (res.IsFailure()) return res.Miss();
outImporter.Reset(new SaveDataImporterVersion2(_fsClient, ref importerInterface.Ref));
outImporter.Reset(new SaveDataImporterVersion2(_fsClient, in importerInterface));
return Result.Success;
}
@ -145,7 +145,7 @@ namespace LibHac.Fs
_fsClient.Impl.LogResultErrorMessage(res);
if (res.IsFailure()) return res.Miss();
outImporter.Reset(new SaveDataImporterVersion2(_fsClient, ref importerInterface.Ref));
outImporter.Reset(new SaveDataImporterVersion2(_fsClient, in importerInterface));
return Result.Success;
}
@ -160,7 +160,7 @@ namespace LibHac.Fs
_fsClient.Impl.LogResultErrorMessage(res);
if (res.IsFailure()) return res.Miss();
outImporter.Reset(new SaveDataImporterVersion2(_fsClient, ref importerInterface.Ref));
outImporter.Reset(new SaveDataImporterVersion2(_fsClient, in importerInterface));
return Result.Success;
}
@ -175,7 +175,7 @@ namespace LibHac.Fs
_fsClient.Impl.LogResultErrorMessage(res);
if (res.IsFailure()) return res.Miss();
outImporter.Reset(new SaveDataImporterVersion2(_fsClient, ref importerInterface.Ref));
outImporter.Reset(new SaveDataImporterVersion2(_fsClient, in importerInterface));
return Result.Success;
}
@ -196,7 +196,7 @@ namespace LibHac.Fs
_fsClient.Impl.LogResultErrorMessage(res);
if (res.IsFailure()) return res.Miss();
outImporter.Reset(new SaveDataImporterVersion2(_fsClient, ref importerInterface.Ref));
outImporter.Reset(new SaveDataImporterVersion2(_fsClient, in importerInterface));
return Result.Success;
}
@ -296,7 +296,7 @@ namespace LibHac.Fs.Shim
// Result res = fileSystemProxy.Get.OpenSaveDataTransferProhibiter(ref prohibiter.Ref, applicationId);
// if (res.IsFailure()) return res.Miss();
outProhibiter.Reset(new SaveDataTransferProhibiterForCloudBackUp(ref prohibiter.Ref));
outProhibiter.Reset(new SaveDataTransferProhibiterForCloudBackUp(in prohibiter));
return Result.Success;
}

View file

@ -56,8 +56,7 @@ public static class SdCard
private static Result RegisterFileSystem(FileSystemClient fs, U8Span mountName,
ref readonly SharedRef<IFileSystemSf> fileSystem)
{
using var fileSystemAdapter =
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
using var fileSystemAdapter = new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
if (!fileSystemAdapter.HasValue)
return ResultFs.AllocationMemoryFailedInSdCardA.Log();
@ -113,14 +112,14 @@ public static class SdCard
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
{
Tick start = fs.Hos.Os.GetSystemTick();
res = RegisterFileSystem(fs, mountName, ref fileSystem.Ref);
res = RegisterFileSystem(fs, mountName, in fileSystem);
Tick end = fs.Hos.Os.GetSystemTick();
fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(logBuffer));
}
else
{
res = RegisterFileSystem(fs, mountName, ref fileSystem.Ref);
res = RegisterFileSystem(fs, mountName, in fileSystem);
}
fs.Impl.AbortIfNeeded(res);
@ -180,14 +179,14 @@ public static class SdCard
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
{
Tick start = fs.Hos.Os.GetSystemTick();
res = RegisterFileSystem(fs, mountName, ref fileSystem.Ref);
res = RegisterFileSystem(fs, mountName, in fileSystem);
Tick end = fs.Hos.Os.GetSystemTick();
fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(logBuffer));
}
else
{
res = RegisterFileSystem(fs, mountName, ref fileSystem.Ref);
res = RegisterFileSystem(fs, mountName, in fileSystem);
}
fs.Impl.AbortIfNeeded(res);
@ -208,7 +207,7 @@ public static class SdCard
fs.Impl.LogResultErrorMessage(res);
Abort.DoAbortUnless(res.IsSuccess());
res = CheckIfInserted(fs, ref deviceOperator.Ref, out bool isInserted);
res = CheckIfInserted(fs, in deviceOperator, out bool isInserted);
fs.Impl.LogResultErrorMessage(res);
Abort.DoAbortUnless(res.IsSuccess());

View file

@ -87,7 +87,7 @@ public static class SystemSaveData
res = fileSystemProxy.Get.OpenSaveDataFileSystemBySystemSaveDataId(ref fileSystem.Ref, spaceId, in attribute);
if (res.IsFailure()) return res.Miss();
var fileSystemAdapterRaw = new FileSystemServiceObjectAdapter(ref fileSystem.Ref);
var fileSystemAdapterRaw = new FileSystemServiceObjectAdapter(in fileSystem);
using var fileSystemAdapter = new UniqueRef<IFileSystem>(fileSystemAdapterRaw);
if (!fileSystemAdapter.HasValue)

View file

@ -1,5 +1,4 @@
using System;
using LibHac.Common;
using LibHac.Common;
using LibHac.Fs;
using LibHac.FsSrv.Impl;
using LibHac.FsSrv.Sf;
@ -69,8 +68,7 @@ public readonly struct BaseFileSystemService
if (res.IsFailure()) return res.Miss();
// Create an SF adapter for the file system
using SharedRef<IFileSystemSf> fileSystemAdapter =
FileSystemInterfaceAdapter.CreateShared(ref fileSystem.Ref, false);
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(in fileSystem, false);
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
@ -131,19 +129,13 @@ public readonly struct BaseFileSystemService
if (res.IsFailure()) return res.Miss();
using var subDirFileSystem = new SharedRef<IFileSystem>();
res = Utility.CreateSubDirectoryFileSystem(ref subDirFileSystem.Ref, ref fileSystem.Ref,
in pathNormalized);
res = Utility.CreateSubDirectoryFileSystem(ref subDirFileSystem.Ref, in fileSystem, in pathNormalized);
if (res.IsFailure()) return res.Miss();
// Add all the file system wrappers
using var typeSetFileSystem =
new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(ref subDirFileSystem.Ref, storageFlag));
using var asyncFileSystem =
new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(ref typeSetFileSystem.Ref));
using SharedRef<IFileSystemSf> fileSystemAdapter =
FileSystemInterfaceAdapter.CreateShared(ref asyncFileSystem.Ref, false);
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(in subDirFileSystem, storageFlag));
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(in typeSetFileSystem));
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(in asyncFileSystem, allowAllOperations: false);
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
@ -193,10 +185,10 @@ public readonly struct BaseFileSystemService
if (res.IsFailure()) return res.Miss();
using var asyncFileSystem =
new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(ref fileSystem.Ref));
new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(in fileSystem));
using SharedRef<IFileSystemSf> fileSystemAdapter =
FileSystemInterfaceAdapter.CreateShared(ref asyncFileSystem.Ref, false);
FileSystemInterfaceAdapter.CreateShared(in asyncFileSystem, false);
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
@ -221,14 +213,9 @@ public readonly struct BaseFileSystemService
if (res.IsFailure()) return res.Miss();
// Add all the file system wrappers
using var typeSetFileSystem =
new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(ref fileSystem.Ref, storageFlag));
using var asyncFileSystem =
new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(ref typeSetFileSystem.Ref));
using SharedRef<IFileSystemSf> fileSystemAdapter =
FileSystemInterfaceAdapter.CreateShared(ref asyncFileSystem.Ref, false);
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(in fileSystem, storageFlag));
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(in typeSetFileSystem));
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(in asyncFileSystem, allowAllOperations: false);
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
@ -293,7 +280,7 @@ public readonly struct BaseFileSystemService
if (res.IsFailure()) return res.Miss();
using SharedRef<IFileSystemSf> fileSystemAdapter =
FileSystemInterfaceAdapter.CreateShared(ref baseFileSystem.Ref, false);
FileSystemInterfaceAdapter.CreateShared(in baseFileSystem, false);
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);

View file

@ -79,13 +79,9 @@ public readonly struct BaseStorageService
res = _serviceImpl.OpenBisStorage(ref storage.Ref, id);
if (res.IsFailure()) return res.Miss();
using var typeSetStorage =
new SharedRef<IStorage>(new StorageLayoutTypeSetStorage(ref storage.Ref, storageFlag));
using var typeSetStorage = new SharedRef<IStorage>(new StorageLayoutTypeSetStorage(in storage, storageFlag));
// Todo: Async storage
using var storageAdapter =
new SharedRef<IStorageSf>(new StorageInterfaceAdapter(ref typeSetStorage.Ref));
using var storageAdapter = new SharedRef<IStorageSf>(new StorageInterfaceAdapter(in typeSetStorage));
outStorage.SetByMove(ref storageAdapter.Ref);
@ -122,9 +118,7 @@ public readonly struct BaseStorageService
if (res.IsFailure()) return res.Miss();
// Todo: Async storage
using var storageAdapter =
new SharedRef<IStorageSf>(new StorageInterfaceAdapter(ref storage.Ref));
using var storageAdapter = new SharedRef<IStorageSf>(new StorageInterfaceAdapter(in storage));
outStorage.SetByMove(ref storageAdapter.Ref);

View file

@ -31,8 +31,6 @@ public class DefaultFsServerObjects
var gcStorageCreator = new GameCardStorageCreator(fsServer);
using var sharedRootFileSystem = new SharedRef<IFileSystem>(rootFileSystem);
using SharedRef<IFileSystem> sharedRootFileSystemCopy =
SharedRef<IFileSystem>.CreateCopy(in sharedRootFileSystem);
var memoryResource = new ArrayPoolMemoryResource();
IBufferManager bufferManager = null;
@ -47,8 +45,8 @@ public class DefaultFsServerObjects
creators.GameCardStorageCreator = gcStorageCreator;
creators.GameCardFileSystemCreator = new GameCardFileSystemCreator(memoryResource, gcStorageCreator, fsServer);
creators.EncryptedFileSystemCreator = new EncryptedFileSystemCreator(keySet);
creators.BuiltInStorageFileSystemCreator = new EmulatedBisFileSystemCreator(ref sharedRootFileSystem.Ref);
creators.SdCardFileSystemCreator = new EmulatedSdCardFileSystemCreator(sdmmcNew, ref sharedRootFileSystemCopy.Ref);
creators.BuiltInStorageFileSystemCreator = new EmulatedBisFileSystemCreator(in sharedRootFileSystem);
creators.SdCardFileSystemCreator = new EmulatedSdCardFileSystemCreator(sdmmcNew, in sharedRootFileSystem);
var storageDeviceManagerFactory = new EmulatedStorageDeviceManagerFactory(fsServer, sdmmcNew, gameCardNew, hasGameCard: true);

View file

@ -46,7 +46,7 @@ public class FileSystemProxyCoreImpl
if (res.IsFailure()) return res.Miss();
using SharedRef<IFileSystem> tempFs = SharedRef<IFileSystem>.CreateMove(ref fileSystem.Ref);
res = Utility.WrapSubDirectory(ref fileSystem.Ref, ref tempFs.Ref, in path, createIfMissing: true);
res = Utility.WrapSubDirectory(ref fileSystem.Ref, in tempFs, in path, createIfMissing: true);
if (res.IsFailure()) return res.Miss();
}
else if (storageId == CustomStorageId.SdCard)
@ -61,7 +61,7 @@ public class FileSystemProxyCoreImpl
if (res.IsFailure()) return res.Miss();
using SharedRef<IFileSystem> tempFs = SharedRef<IFileSystem>.CreateMove(ref fileSystem.Ref);
res = Utility.WrapSubDirectory(ref fileSystem.Ref, ref tempFs.Ref, in path, createIfMissing: true);
res = Utility.WrapSubDirectory(ref fileSystem.Ref, in tempFs, in path, createIfMissing: true);
if (res.IsFailure()) return res.Miss();
tempFs.SetByMove(ref fileSystem.Ref);

View file

@ -848,14 +848,9 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
if (res.IsFailure()) return res.Miss();
// Add all the file system wrappers
using var typeSetFileSystem =
new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(ref fileSystem.Ref, storageFlag));
using var asyncFileSystem =
new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(ref typeSetFileSystem.Ref));
using SharedRef<IFileSystemSf> fileSystemAdapter =
FileSystemInterfaceAdapter.CreateShared(ref asyncFileSystem.Ref, allowAllOperations: false);
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(in fileSystem, storageFlag));
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(in typeSetFileSystem));
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(in asyncFileSystem, allowAllOperations: false);
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);

View file

@ -45,7 +45,7 @@ public static class FileSystemServerInitializer
ulong processId = client.Os.GetCurrentProcessId().Value;
fileSystemProxy.Get.SetCurrentProcess(processId).IgnoreResult();
client.Fs.Impl.InitializeDfcFileSystemProxyServiceObject(ref fileSystemProxy.Ref);
client.Fs.Impl.InitializeDfcFileSystemProxyServiceObject(in fileSystemProxy);
InitializeFileSystemProxyServer(client, server);

View file

@ -83,7 +83,7 @@ public class EmulatedBisFileSystemCreator : IBuiltInStorageFileSystemCreator
if (res.IsFailure()) return res.Miss();
using var partitionFileSystem = new SharedRef<IFileSystem>();
res = Utility.WrapSubDirectory(ref partitionFileSystem.Ref, ref rootFileSystem.Ref, in bisRootPath, true);
res = Utility.WrapSubDirectory(ref partitionFileSystem.Ref, in rootFileSystem, in bisRootPath, true);
if (res.IsFailure()) return res.Miss();
outFileSystem.SetByMove(ref partitionFileSystem.Ref);

View file

@ -69,7 +69,7 @@ public class EmulatedSdCardFileSystemCreator : ISdCardProxyFileSystemCreator, ID
// Todo: Add ProxyFileSystem?
using SharedRef<IFileSystem> fileSystem = SharedRef<IFileSystem>.CreateCopy(in _rootFileSystem);
res = Utility.WrapSubDirectory(ref _sdCardFileSystem, ref fileSystem.Ref, in sdCardPath, true);
res = Utility.WrapSubDirectory(ref _sdCardFileSystem, in fileSystem, in sdCardPath, true);
if (res.IsFailure()) return res.Miss();
outFileSystem.SetByCopy(in _sdCardFileSystem);

View file

@ -280,7 +280,7 @@ public class GameCardFileSystemCreator : IGameCardFileSystemCreator
res = rootPartitionFsMeta.Get.Initialize(rootFsStorage.Get, _allocator, status.PartitionFsHeaderHash, salt);
if (res.IsFailure()) return res.Miss();
_rootPartition.Reset(new GameCardRootPartition(handle, ref rootFsStorage.Ref, _gameCardStorageCreator,
_rootPartition.Reset(new GameCardRootPartition(handle, in rootFsStorage, _gameCardStorageCreator,
ref rootPartitionFsMeta.Ref, _fsServer));
if (!_rootPartition.HasValue)

View file

@ -413,7 +413,7 @@ public class SaveDataFileSystemCreator : ISaveDataFileSystemCreator
// Wrap the save FS in a result convert FS and set it as the output FS
using var resultConvertFs = new SharedRef<SaveDataResultConvertFileSystem>(
new SaveDataResultConvertFileSystem(ref saveDataFs.Ref, isReconstructible));
new SaveDataResultConvertFileSystem(in saveDataFs, isReconstructible));
outFileSystem.SetByMove(ref resultConvertFs.Ref);
return Result.Success;
@ -450,7 +450,7 @@ public class SaveDataFileSystemCreator : ISaveDataFileSystemCreator
}
using var resultConvertFs = new SharedRef<SaveDataResultConvertFileSystem>(
new SaveDataResultConvertFileSystem(ref saveDataFs.Ref, isReconstructible));
new SaveDataResultConvertFileSystem(in saveDataFs, isReconstructible));
outExtraDataAccessor.SetByMove(ref resultConvertFs.Ref);
return Result.Success;
@ -507,7 +507,7 @@ public class SaveDataFileSystemCreator : ISaveDataFileSystemCreator
using SharedRef<ISaveDataFileSystem> tempSaveFs = SharedRef<ISaveDataFileSystem>.CreateMove(ref saveFs.Ref);
using var resultConvertFs = new SharedRef<SaveDataResultConvertFileSystem>(
new SaveDataResultConvertFileSystem(ref tempSaveFs.Ref, isReconstructible));
new SaveDataResultConvertFileSystem(in tempSaveFs, isReconstructible));
outFileSystem.SetByMove(ref resultConvertFs.Ref);
return Result.Success;

View file

@ -22,7 +22,7 @@ public class DeepRetryFileSystem : ForwardingFileSystem
using var retryFileSystem = new SharedRef<DeepRetryFileSystem>(
new DeepRetryFileSystem(in baseFileSystem, in accessFailureManager));
retryFileSystem.Get._selfReference.Set(in retryFileSystem.Ref);
retryFileSystem.Get._selfReference.Set(in retryFileSystem);
return SharedRef<IFileSystem>.CreateMove(ref retryFileSystem.Ref);
}

View file

@ -1,6 +1,5 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using LibHac.Common;
using LibHac.Fs;
using LibHac.Fs.Fsa;
@ -251,8 +250,7 @@ public class FileSystemInterfaceAdapter : IFileSystemSf
// creating files and directories. We don't have an ISharedObject, so a self-reference is used instead.
private WeakRef<FileSystemInterfaceAdapter> _selfReference;
private FileSystemInterfaceAdapter(ref readonly SharedRef<IFileSystem> fileSystem,
bool allowAllOperations)
private FileSystemInterfaceAdapter(ref readonly SharedRef<IFileSystem> fileSystem, bool allowAllOperations)
{
_baseFileSystem = SharedRef<IFileSystem>.CreateCopy(in fileSystem);
_allowAllOperations = allowAllOperations;
@ -506,7 +504,7 @@ public class FileSystemInterfaceAdapter : IFileSystemSf
using SharedRef<FileSystemInterfaceAdapter> selfReference =
SharedRef<FileSystemInterfaceAdapter>.Create(in _selfReference);
var adapter = new FileInterfaceAdapter(ref file.Ref, ref selfReference.Ref, _allowAllOperations);
var adapter = new FileInterfaceAdapter(ref file.Ref, in selfReference, _allowAllOperations);
outFile.Reset(adapter);
return Result.Success;
@ -537,7 +535,7 @@ public class FileSystemInterfaceAdapter : IFileSystemSf
using SharedRef<FileSystemInterfaceAdapter> selfReference =
SharedRef<FileSystemInterfaceAdapter>.Create(in _selfReference);
var adapter = new DirectoryInterfaceAdapter(ref directory.Ref, ref selfReference.Ref);
var adapter = new DirectoryInterfaceAdapter(ref directory.Ref, in selfReference);
outDirectory.Reset(adapter);
return Result.Success;

View file

@ -142,7 +142,7 @@ public class SaveDataFileSystemCacheManager : IDisposable
{
using ScopedLock<SdkRecursiveMutexType> scopedLock = ScopedLock.Lock(ref _mutex);
_cachedFileSystems[_nextCacheIndex].Register(ref fileSystem, spaceId, saveDataId);
_cachedFileSystems[_nextCacheIndex].Register(in fileSystem, spaceId, saveDataId);
_nextCacheIndex = (_nextCacheIndex + 1) % _maxCachedFileSystemCount;
}
}

View file

@ -170,11 +170,12 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
}
// Add all the file system wrappers
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(ref fileSystem.Ref, storageFlag));
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(ref typeSetFileSystem.Ref));
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(in fileSystem, storageFlag));
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(in typeSetFileSystem));
using SharedRef<IRomFileSystemAccessFailureManager> accessFailureManager = SharedRef<IRomFileSystemAccessFailureManager>.Create(in _selfReference);
using SharedRef<IFileSystem> retryFileSystem = DeepRetryFileSystem.CreateShared(ref asyncFileSystem.Ref, ref accessFailureManager.Ref);
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(ref retryFileSystem.Ref, false);
using SharedRef<IFileSystem> retryFileSystem = DeepRetryFileSystem.CreateShared(in asyncFileSystem, in accessFailureManager);
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(in retryFileSystem, false);
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
@ -211,9 +212,9 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
if (res.IsFailure()) return res.Miss();
// Add all the file system wrappers
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(ref fileSystem.Ref, storageFlag));
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(ref typeSetFileSystem.Ref));
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(ref asyncFileSystem.Ref, allowAllOperations: false);
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(in fileSystem, storageFlag));
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(in typeSetFileSystem));
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(in asyncFileSystem, allowAllOperations: false);
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
@ -237,11 +238,11 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
}
else
{
asyncFileSystem.Reset(new AsynchronousAccessFileSystem(ref fileSystem.Ref));
asyncFileSystem.Reset(new AsynchronousAccessFileSystem(in fileSystem));
}
using SharedRef<IFileSystemSf> fileSystemAdapter =
FileSystemInterfaceAdapter.CreateShared(ref asyncFileSystem.Ref, allowAllOperations: false);
FileSystemInterfaceAdapter.CreateShared(in asyncFileSystem, allowAllOperations: false);
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
@ -415,8 +416,8 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
in accessFailureManager, ref romDivisionSizeUnitCountSemaphore.Ref, in digest, programInfo.ProgramIdValue,
storageId, _serviceImpl.FsServer));
using var typeSetStorage = new SharedRef<IStorage>(new StorageLayoutTypeSetStorage(ref retryStorage.Ref, storageFlag));
using var storageAdapter = new SharedRef<IStorageSf>(new StorageInterfaceAdapter(ref typeSetStorage.Ref));
using var typeSetStorage = new SharedRef<IStorage>(new StorageLayoutTypeSetStorage(in retryStorage, storageFlag));
using var storageAdapter = new SharedRef<IStorageSf>(new StorageInterfaceAdapter(in typeSetStorage));
outStorage.SetByMove(ref storageAdapter.Ref);
@ -467,8 +468,8 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
in accessFailureManager, ref romDivisionSizeUnitCountSemaphore.Ref, in digest, ProgramId.InvalidId.Value,
StorageId.None, _serviceImpl.FsServer));
using var typeSetStorage = new SharedRef<IStorage>(new StorageLayoutTypeSetStorage(ref retryStorage.Ref, storageFlag));
using var storageAdapter = new SharedRef<IStorageSf>(new StorageInterfaceAdapter(ref typeSetStorage.Ref));
using var typeSetStorage = new SharedRef<IStorage>(new StorageLayoutTypeSetStorage(in retryStorage, storageFlag));
using var storageAdapter = new SharedRef<IStorageSf>(new StorageInterfaceAdapter(in typeSetStorage));
outStorage.SetByMove(ref storageAdapter.Ref);
@ -511,8 +512,8 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
in accessFailureManager, ref romDivisionSizeUnitCountSemaphore.Ref, in digest, programId.Value,
programInfo.StorageId, _serviceImpl.FsServer));
using var typeSetStorage = new SharedRef<IStorage>(new StorageLayoutTypeSetStorage(ref retryStorage.Ref, storageFlag));
using var storageAdapter = new SharedRef<IStorageSf>(new StorageInterfaceAdapter(ref typeSetStorage.Ref));
using var typeSetStorage = new SharedRef<IStorage>(new StorageLayoutTypeSetStorage(in retryStorage, storageFlag));
using var storageAdapter = new SharedRef<IStorageSf>(new StorageInterfaceAdapter(in typeSetStorage));
outStorage.SetByMove(ref storageAdapter.Ref);
@ -589,14 +590,9 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
if (res.IsFailure()) return res.Miss();
// Add all the wrappers for the file system
using var typeSetFileSystem =
new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(ref fileSystem.Ref, storageFlag));
using var asyncFileSystem =
new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(ref fileSystem.Ref));
using SharedRef<IFileSystemSf> fileSystemAdapter =
FileSystemInterfaceAdapter.CreateShared(ref asyncFileSystem.Ref, allowAllOperations: false);
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(in fileSystem, storageFlag));
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(in typeSetFileSystem));
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(in asyncFileSystem, allowAllOperations: false);
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
@ -618,10 +614,10 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
if (!properProgramInfo.AccessControl.HasContentOwnerId(programId.Value))
return ResultFs.PermissionDenied.Log();
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(ref fileSystem.Ref));
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(in fileSystem));
using SharedRef<IFileSystemSf> fileSystemAdapter =
FileSystemInterfaceAdapter.CreateShared(ref asyncFileSystem.Ref, allowAllOperations: false);
FileSystemInterfaceAdapter.CreateShared(in asyncFileSystem, allowAllOperations: false);
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
@ -694,8 +690,8 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
using var retryStorage = new SharedRef<IStorage>(new DeepRetryStorage(in storage, in storageAccessSplitter,
in accessFailureManager, ref mountCountSemaphore.Ref, deepRetryEnabled: isAoc, _serviceImpl.FsServer));
using var typeSetStorage = new SharedRef<IStorage>(new StorageLayoutTypeSetStorage(ref retryStorage.Ref, storageFlag));
using var storageAdapter = new SharedRef<IStorageSf>(new StorageInterfaceAdapter(ref typeSetStorage.Ref));
using var typeSetStorage = new SharedRef<IStorage>(new StorageLayoutTypeSetStorage(in retryStorage, storageFlag));
using var storageAdapter = new SharedRef<IStorageSf>(new StorageInterfaceAdapter(in typeSetStorage));
outStorage.SetByMove(ref storageAdapter.Ref);
@ -742,8 +738,8 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
return res.Miss();
}
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(ref fileSystem.Ref, storageFlag));
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(ref typeSetFileSystem.Ref, allowAllOperations: false);
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(in fileSystem, storageFlag));
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(in typeSetFileSystem, allowAllOperations: false);
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
@ -777,8 +773,8 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
}
// Add all the file system wrappers
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(ref fileSystem.Ref));
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(ref asyncFileSystem.Ref, allowAllOperations: false);
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(in fileSystem));
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(in asyncFileSystem, allowAllOperations: false);
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
@ -822,8 +818,8 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
in accessFailureManager, ref romDivisionSizeUnitCountSemaphore.Ref, in digest, targetProgramId.Value,
programInfo.StorageId, _serviceImpl.FsServer));
using var typeSetStorage = new SharedRef<IStorage>(new StorageLayoutTypeSetStorage(ref retryStorage.Ref, storageFlag));
using var storageAdapter = new SharedRef<IStorageSf>(new StorageInterfaceAdapter(ref typeSetStorage.Ref));
using var typeSetStorage = new SharedRef<IStorage>(new StorageLayoutTypeSetStorage(in retryStorage, storageFlag));
using var storageAdapter = new SharedRef<IStorageSf>(new StorageInterfaceAdapter(in typeSetStorage));
outStorage.SetByMove(ref storageAdapter.Ref);
@ -949,7 +945,7 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
if (res.IsFailure()) return res.Miss();
// Add all the file system wrappers
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(ref fileSystem.Ref, storageFlag));
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(in fileSystem, storageFlag));
outFileSystem.SetByMove(ref typeSetFileSystem.Ref);
@ -975,10 +971,10 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
if (res.IsFailure()) return res.Miss();
// Add all the file system wrappers
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(ref fileSystem.Ref, storageFlag));
using var alignmentMatchableFileSystem = new SharedRef<IFileSystem>(new AlignmentMatchableFileSystem(ref fileSystem.Ref));
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(ref alignmentMatchableFileSystem.Ref));
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(ref asyncFileSystem.Ref, allowAllOperations: false);
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(in fileSystem, storageFlag));
using var alignmentMatchableFileSystem = new SharedRef<IFileSystem>(new AlignmentMatchableFileSystem(in typeSetFileSystem));
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(in alignmentMatchableFileSystem));
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(in asyncFileSystem, allowAllOperations: false);
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
@ -1054,14 +1050,9 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
if (res.IsFailure()) return res.Miss();
// Add all the file system wrappers
using var typeSetFileSystem =
new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(ref fileSystem.Ref, storageFlag));
using var asyncFileSystem =
new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(ref typeSetFileSystem.Ref));
using SharedRef<IFileSystemSf> fileSystemAdapter =
FileSystemInterfaceAdapter.CreateShared(ref asyncFileSystem.Ref, allowAllOperations: false);
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(in fileSystem, storageFlag));
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(in typeSetFileSystem));
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(in asyncFileSystem, allowAllOperations: false);
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
@ -1131,7 +1122,7 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
pathFlags.AllowWindowsPath();
using SharedRef<IFileSystemSf> fileSystemAdapter =
FileSystemInterfaceAdapter.CreateShared(ref fileSystem.Ref, pathFlags, allowAllOperations: false);
FileSystemInterfaceAdapter.CreateShared(in fileSystem, pathFlags, allowAllOperations: false);
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);

View file

@ -382,7 +382,7 @@ public class NcaFileSystemServiceImpl : IDisposable
using var ncaReader = new SharedRef<NcaReader>();
ulong openProgramId = mountInfo.IsHostOrLocalFs() ? ulong.MaxValue : id;
res = ParseNca(ref ncaReader.Ref, ref baseFileSystem.Ref, currentPath, attributes, openProgramId);
res = ParseNca(ref ncaReader.Ref, in baseFileSystem, currentPath, attributes, openProgramId);
if (res.IsFailure()) return res.Miss();
using var storage = new SharedRef<IStorage>();

View file

@ -42,9 +42,9 @@ file class SaveDataOpenCountAdapter : IEntryOpenCountSemaphoreManager
{
private SharedRef<SaveDataFileSystemService> _saveService;
public SaveDataOpenCountAdapter(ref SharedRef<SaveDataFileSystemService> saveService)
public SaveDataOpenCountAdapter(ref readonly SharedRef<SaveDataFileSystemService> saveService)
{
_saveService = SharedRef<SaveDataFileSystemService>.CreateMove(ref saveService);
_saveService = SharedRef<SaveDataFileSystemService>.CreateCopy(in saveService);
}
public void Dispose()
@ -1752,14 +1752,12 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
if (res.IsFailure()) return res.Miss();
// Add all the wrappers for the file system
using var typeSetFileSystem =
new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(ref fileSystem.Ref, storageFlag));
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(in fileSystem, storageFlag));
using var asyncFileSystem = new SharedRef<IFileSystem>();
if (useAsyncFileSystem)
{
asyncFileSystem.Reset(new AsynchronousAccessFileSystem(ref typeSetFileSystem.Ref));
asyncFileSystem.Reset(new AsynchronousAccessFileSystem(in typeSetFileSystem));
}
else
{
@ -1768,17 +1766,17 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
using SharedRef<SaveDataFileSystemService> saveService = GetSharedFromThis();
using var openEntryCountAdapter =
new SharedRef<IEntryOpenCountSemaphoreManager>(new SaveDataOpenCountAdapter(ref saveService.Ref));
new SharedRef<IEntryOpenCountSemaphoreManager>(new SaveDataOpenCountAdapter(in saveService));
using var openCountFileSystem = new SharedRef<IFileSystem>(new OpenCountFileSystem(ref asyncFileSystem.Ref,
ref openEntryCountAdapter.Ref, ref mountCountSemaphore.Ref));
using var openCountFileSystem = new SharedRef<IFileSystem>(new OpenCountFileSystem(in asyncFileSystem,
in openEntryCountAdapter, ref mountCountSemaphore.Ref));
PathFlags pathFlags = FileSystemInterfaceAdapter.GetDefaultPathFlags();
pathFlags.AllowBackslash();
pathFlags.AllowInvalidCharacter();
using SharedRef<IFileSystemSf> fileSystemAdapter =
FileSystemInterfaceAdapter.CreateShared(ref openCountFileSystem.Ref, pathFlags, false);
FileSystemInterfaceAdapter.CreateShared(in openCountFileSystem, pathFlags, allowAllOperations: false);
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
return Result.Success;
@ -1879,14 +1877,12 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
if (res.IsFailure()) return res.Miss();
// Add all the wrappers for the file system
using var typeSetFileSystem =
new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(ref fileSystem.Ref, storageFlag));
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(in fileSystem, storageFlag));
using var asyncFileSystem = new SharedRef<IFileSystem>();
if (useAsyncFileSystem)
{
asyncFileSystem.Reset(new AsynchronousAccessFileSystem(ref typeSetFileSystem.Ref));
asyncFileSystem.Reset(new AsynchronousAccessFileSystem(in typeSetFileSystem));
}
else
{
@ -1895,17 +1891,17 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
using SharedRef<SaveDataFileSystemService> saveService = GetSharedFromThis();
using var openEntryCountAdapter =
new SharedRef<IEntryOpenCountSemaphoreManager>(new SaveDataOpenCountAdapter(ref saveService.Ref));
new SharedRef<IEntryOpenCountSemaphoreManager>(new SaveDataOpenCountAdapter(in saveService));
using var openCountFileSystem = new SharedRef<IFileSystem>(
new OpenCountFileSystem(ref asyncFileSystem.Ref, ref openEntryCountAdapter.Ref));
new OpenCountFileSystem(in asyncFileSystem, in openEntryCountAdapter));
PathFlags pathFlags = FileSystemInterfaceAdapter.GetDefaultPathFlags();
pathFlags.AllowBackslash();
pathFlags.AllowInvalidCharacter();
using SharedRef<IFileSystemSf> fileSystemAdapter =
FileSystemInterfaceAdapter.CreateShared(ref openCountFileSystem.Ref, pathFlags, allowAllOperations: false);
FileSystemInterfaceAdapter.CreateShared(in openCountFileSystem, pathFlags, allowAllOperations: false);
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
return Result.Success;
@ -2257,14 +2253,13 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
if (res.IsFailure()) return res.Miss();
using var reader = new SharedRef<SaveDataInfoReaderImpl>();
res = accessor.Get.GetInterface().OpenSaveDataInfoReader(ref reader.Ref);
if (res.IsFailure()) return res.Miss();
var filter = new SaveDataInfoFilter(ConvertToRealSpaceId(spaceId), programId: default,
saveDataType: default, userId: default, saveDataId: default, index: default, (int)SaveDataRank.Primary);
filterReader.Reset(new SaveDataInfoFilterReader(ref reader.Ref, in filter));
filterReader.Reset(new SaveDataInfoFilterReader(in reader, in filter));
}
outInfoReader.Set(ref filterReader.Ref);
@ -2300,7 +2295,7 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
var infoFilter = new SaveDataInfoFilter(ConvertToRealSpaceId(spaceId), in filter);
filterReader.Reset(new SaveDataInfoFilterReader(ref reader.Ref, in infoFilter));
filterReader.Reset(new SaveDataInfoFilterReader(in reader, in infoFilter));
}
outInfoReader.Set(ref filterReader.Ref);
@ -2323,7 +2318,7 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
if (res.IsFailure()) return res.Miss();
using var filterReader =
new UniqueRef<SaveDataInfoFilterReader>(new SaveDataInfoFilterReader(ref reader.Ref, in infoFilter));
new UniqueRef<SaveDataInfoFilterReader>(new SaveDataInfoFilterReader(in reader, in infoFilter));
return filterReader.Get.Read(out count, new OutBuffer(SpanHelpers.AsByteSpan(ref info))).Ret();
}
@ -2427,9 +2422,7 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
in saveDataRootPath, isTemporaryTransferSave, isReconstructible);
if (res.IsFailure()) return res.Miss();
using var typeSetFileSystem =
new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(ref fileSystem.Ref, storageFlag));
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(in fileSystem, storageFlag));
outFileSystem.SetByMove(ref typeSetFileSystem.Ref);
return Result.Success;
}
@ -2476,17 +2469,17 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
if (res.IsFailure()) return res.Miss();
// Add all the wrappers for the file system
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(ref fileSystem.Ref));
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(in fileSystem));
using SharedRef<SaveDataFileSystemService> saveService = GetSharedFromThis();
using var openEntryCountAdapter =
new SharedRef<IEntryOpenCountSemaphoreManager>(new SaveDataOpenCountAdapter(ref saveService.Ref));
new SharedRef<IEntryOpenCountSemaphoreManager>(new SaveDataOpenCountAdapter(in saveService));
using var openCountFileSystem = new SharedRef<IFileSystem>(new OpenCountFileSystem(ref asyncFileSystem.Ref,
ref openEntryCountAdapter.Ref, ref mountCountSemaphore.Ref));
using var openCountFileSystem = new SharedRef<IFileSystem>(new OpenCountFileSystem(in asyncFileSystem,
in openEntryCountAdapter, ref mountCountSemaphore.Ref));
using SharedRef<IFileSystemSf> fileSystemAdapter =
FileSystemInterfaceAdapter.CreateShared(ref openCountFileSystem.Ref, allowAllOperations: false);
FileSystemInterfaceAdapter.CreateShared(in openCountFileSystem, allowAllOperations: false);
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
return Result.Success;
@ -2599,7 +2592,7 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
var filter = new SaveDataInfoFilter(ConvertToRealSpaceId(spaceId), resolvedProgramId, SaveDataType.Cache,
userId: default, saveDataId: default, index: default, (int)SaveDataRank.Primary);
filterReader.Reset(new SaveDataInfoFilterReader(ref reader.Ref, in filter));
filterReader.Reset(new SaveDataInfoFilterReader(in reader, in filter));
}
outInfoReader.Set(ref filterReader.Ref);
@ -2617,8 +2610,7 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
Result res = _serviceImpl.OpenSaveDataMetaDirectoryFileSystem(ref fileSystem.Ref, spaceId, saveDataId);
if (res.IsFailure()) return res.Miss();
using var typeSetFileSystem =
new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(ref fileSystem.Ref, storageFlag));
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(in fileSystem, storageFlag));
Unsafe.SkipInit(out Array15<byte> pathMetaBuffer);
@ -2681,13 +2673,9 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
res = _serviceImpl.OpenSaveDataMetaDirectoryFileSystem(ref tmpFileSystem.Ref, spaceId, targetSaveDataId);
if (res.IsFailure()) return res.Miss();
using var typeSetFileSystem =
new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(ref tmpFileSystem.Ref, storageFlag));
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(ref typeSetFileSystem.Ref));
using SharedRef<IFileSystemSf> fileSystem =
FileSystemInterfaceAdapter.CreateShared(ref asyncFileSystem.Ref, allowAllOperations: false);
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(in tmpFileSystem, storageFlag));
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(in typeSetFileSystem));
using SharedRef<IFileSystemSf> fileSystem = FileSystemInterfaceAdapter.CreateShared(in asyncFileSystem, allowAllOperations: false);
Unsafe.SkipInit(out Sf.Path sfPath);
var sb = new U8StringBuilder(SpanHelpers.AsByteSpan(ref sfPath));
@ -2847,8 +2835,7 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
using SharedRef<ISaveDataTransferCoreInterface> transferInterface = GetSaveDataTransferCoreInterfaceFromThis();
using var manager = new SharedRef<ISaveDataTransferManager>(
new SaveDataTransferManager(_serviceImpl.GetSaveDataTransferCryptoConfiguration(),
in transferInterface.Ref));
new SaveDataTransferManager(_serviceImpl.GetSaveDataTransferCryptoConfiguration(), in transferInterface));
if (!manager.HasValue)
return ResultFs.AllocationMemoryFailedInFileSystemProxyImplA.Log();
@ -2896,7 +2883,7 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
using SharedRef<ISaveDataTransferCoreInterface> transferInterface = GetSaveDataTransferCoreInterfaceFromThis();
using var manager = new SharedRef<ISaveDataTransferManagerForSaveDataRepair>(
new SaveDataTransferManagerForSaveDataRepair<SaveDataTransferManagerForSaveDataRepairPolicyV0>(
_serviceImpl.GetSaveDataTransferCryptoConfiguration(), in transferInterface.Ref,
_serviceImpl.GetSaveDataTransferCryptoConfiguration(), in transferInterface,
_serviceImpl.GetSaveDataPorterManager(), isOpenPorterWithKeyEnabled));
if (!manager.HasValue)
@ -2919,7 +2906,7 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
using SharedRef<ISaveDataTransferCoreInterface> transferInterface = GetSaveDataTransferCoreInterfaceFromThis();
using var manager = new SharedRef<ISaveDataTransferManagerForRepair>(
new Impl.SaveDataTransferManagerForRepair(_serviceImpl.GetSaveDataTransferCryptoConfiguration(),
in transferInterface.Ref, _serviceImpl.GetSaveDataPorterManager()));
in transferInterface, _serviceImpl.GetSaveDataPorterManager()));
if (!manager.HasValue)
return ResultFs.AllocationMemoryFailedInFileSystemProxyImplA.Log();
@ -3318,7 +3305,7 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
{
using SharedRef<ISaveDataMultiCommitCoreInterface> commitInterface = GetSharedMultiCommitInterfaceFromThis();
outCommitManager.Reset(new MultiCommitManager(_serviceImpl.FsServer, ref commitInterface.Ref));
outCommitManager.Reset(new MultiCommitManager(_serviceImpl.FsServer, in commitInterface));
return Result.Success;
}

View file

@ -299,7 +299,7 @@ public class SaveDataFileSystemServiceImpl : IDisposable
bool openShared = SaveDataProperties.IsSharedOpenNeeded(type);
bool isReconstructible = SaveDataProperties.IsReconstructible(type, spaceId);
res = _config.SaveFsCreator.Create(ref saveDataFs.Ref, fileSystem.Ref, spaceId, saveDataId,
res = _config.SaveFsCreator.Create(ref saveDataFs.Ref, in fileSystem, spaceId, saveDataId,
isEmulatedOnHost, isDeviceUniqueMac, isJournalingSupported, isMultiCommitSupported,
openReadOnly, openShared, _timeStampGetter, isReconstructible);
if (res.IsFailure()) return res.Miss();
@ -316,7 +316,7 @@ public class SaveDataFileSystemServiceImpl : IDisposable
}
using var registerFs = new SharedRef<SaveDataFileSystemCacheRegister>(
new SaveDataFileSystemCacheRegister(ref saveDataFs.Ref, _saveFileSystemCacheManager, spaceId, saveDataId));
new SaveDataFileSystemCacheRegister(in saveDataFs, _saveFileSystemCacheManager, spaceId, saveDataId));
if (openReadOnly)
{
@ -1148,7 +1148,7 @@ public class SaveDataFileSystemServiceImpl : IDisposable
caseSensitive: true);
if (res.IsFailure()) return res.Miss();
res = Utility.WrapSubDirectory(ref outFileSystem, ref baseFileSystem.Ref, in directoryPath,
res = Utility.WrapSubDirectory(ref outFileSystem, in baseFileSystem, in directoryPath,
createIfMissing);
if (res.IsFailure()) return res.Miss();
@ -1162,8 +1162,7 @@ public class SaveDataFileSystemServiceImpl : IDisposable
caseSensitive: true);
if (res.IsFailure()) return res.Miss();
res = Utility.WrapSubDirectory(ref outFileSystem, ref baseFileSystem.Ref, in directoryPath,
createIfMissing);
res = Utility.WrapSubDirectory(ref outFileSystem, in baseFileSystem, in directoryPath, createIfMissing);
if (res.IsFailure()) return res.Miss();
break;
@ -1189,7 +1188,7 @@ public class SaveDataFileSystemServiceImpl : IDisposable
using SharedRef<IFileSystem> tempFileSystem = SharedRef<IFileSystem>.CreateMove(ref baseFileSystem.Ref);
res = Utility.WrapSubDirectory(ref baseFileSystem.Ref, ref tempFileSystem.Ref, in pathSdRoot, createIfMissing);
res = Utility.WrapSubDirectory(ref baseFileSystem.Ref, in tempFileSystem, in pathSdRoot, createIfMissing);
if (res.IsFailure()) return res.Miss();
res = _config.EncryptedFsCreator.Create(ref outFileSystem, in baseFileSystem,
@ -1205,8 +1204,7 @@ public class SaveDataFileSystemServiceImpl : IDisposable
BisPartitionId.SystemProperPartition, caseSensitive: true);
if (res.IsFailure()) return res.Miss();
res = Utility.WrapSubDirectory(ref outFileSystem, ref baseFileSystem.Ref, in directoryPath,
createIfMissing);
res = Utility.WrapSubDirectory(ref outFileSystem, in baseFileSystem, in directoryPath, createIfMissing);
if (res.IsFailure()) return res.Miss();
break;
@ -1218,8 +1216,7 @@ public class SaveDataFileSystemServiceImpl : IDisposable
caseSensitive: true);
if (res.IsFailure()) return res.Miss();
res = Utility.WrapSubDirectory(ref outFileSystem, ref baseFileSystem.Ref, in directoryPath,
createIfMissing);
res = Utility.WrapSubDirectory(ref outFileSystem, in baseFileSystem, in directoryPath, createIfMissing);
if (res.IsFailure()) return res.Miss();
break;

View file

@ -1,7 +1,6 @@
using System;
using System.Buffers.Binary;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using LibHac.Common;
using LibHac.Common.FixedArrays;
using LibHac.Diag;

View file

@ -1,5 +1,4 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using LibHac.Common;
using LibHac.Fs;
using LibHac.Os;

View file

@ -1,6 +1,5 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using LibHac.Common;
using LibHac.Fs;
using LibHac.Ncm;

View file

@ -366,24 +366,21 @@ public class SaveDataFileStorageHolder
res = baseFileStorage.Get.Initialize(in baseFileSystem, in saveImageName, mode, type.ValueRo);
if (res.IsFailure()) return res.Miss();
using SharedRef<SaveDataOpenTypeSetFileStorage> baseFileStorageCopy =
SharedRef<SaveDataOpenTypeSetFileStorage>.CreateCopy(in baseFileStorage);
res = Register(ref baseFileStorageCopy.Ref, spaceId, saveDataId);
res = Register(in baseFileStorage, spaceId, saveDataId);
if (res.IsFailure()) return res.Miss();
}
outSaveDataStorage.Reset(new SaveDataSharedFileStorage(ref baseFileStorage.Ref, type.ValueRo));
outSaveDataStorage.Reset(new SaveDataSharedFileStorage(in baseFileStorage, type.ValueRo));
return Result.Success;
}
public Result Register(ref SharedRef<SaveDataOpenTypeSetFileStorage> storage, SaveDataSpaceId spaceId,
public Result Register(ref readonly SharedRef<SaveDataOpenTypeSetFileStorage> storage, SaveDataSpaceId spaceId,
ulong saveDataId)
{
Assert.SdkRequires(Globals.Mutex.IsLockedByCurrentThread());
_entryList.AddLast(new Entry(ref storage, spaceId, saveDataId));
_entryList.AddLast(new Entry(in storage, spaceId, saveDataId));
return Result.Success;
}

View file

@ -137,7 +137,7 @@ internal static class GameCardService
using var storage = new SharedRef<IStorage>(new StorageServiceObjectAdapter(ref gameCardStorageDevice.Ref));
using var deviceEventSimulationStorage = new SharedRef<DeviceEventSimulationStorage>(
new DeviceEventSimulationStorage(ref storage.Ref, service.FsSrv.Impl.GetGameCardEventSimulator()));
new DeviceEventSimulationStorage(in storage, service.FsSrv.Impl.GetGameCardEventSimulator()));
outStorage.SetByMove(ref deviceEventSimulationStorage.Ref);

View file

@ -105,12 +105,12 @@ internal static class MmcService
res = storageDeviceManager.Get.OpenStorage(ref mmcStorage.Ref, attribute);
if (res.IsFailure()) return res.Miss();
using var storage = new SharedRef<IStorage>(new StorageServiceObjectAdapter(ref mmcStorage.Ref));
using var storage = new SharedRef<IStorage>(new StorageServiceObjectAdapter(in mmcStorage));
if (IsSpeedEmulationNeeded(partition))
{
using var emulationStorage =
new SharedRef<IStorage>(new SpeedEmulationStorage(ref storage.Ref, service.FsSrv));
new SharedRef<IStorage>(new SpeedEmulationStorage(in storage, service.FsSrv));
outStorage.SetByMove(ref emulationStorage.Ref);
return Result.Success;

View file

@ -62,14 +62,14 @@ internal static class SdCardService
res = storageDeviceManager.Get.OpenStorage(ref sdCardStorage.Ref, 0);
if (res.IsFailure()) return res.Miss();
using var storage = new SharedRef<IStorage>(new StorageServiceObjectAdapter(ref sdCardStorage.Ref));
using var storage = new SharedRef<IStorage>(new StorageServiceObjectAdapter(in sdCardStorage));
SdCardEventSimulator eventSimulator = service.FsSrv.Impl.GetSdCardEventSimulator();
using var deviceEventSimulationStorage =
new SharedRef<IStorage>(new DeviceEventSimulationStorage(ref storage.Ref, eventSimulator));
new SharedRef<IStorage>(new DeviceEventSimulationStorage(in storage, eventSimulator));
using var emulationStorage = new SharedRef<IStorage>(
new SpeedEmulationStorage(ref deviceEventSimulationStorage.Ref, service.FsSrv));
new SpeedEmulationStorage(in deviceEventSimulationStorage, service.FsSrv));
outStorage.SetByMove(ref emulationStorage.Ref);
return Result.Success;

View file

@ -1,6 +1,5 @@
using System;
using LibHac.Fs;
using LibHac.Spl;
namespace LibHac.FsSystem;

View file

@ -51,9 +51,9 @@ internal class StorageLayoutTypeSetStorage : IStorage
private SharedRef<IStorage> _baseStorage;
private StorageLayoutType _storageFlag;
public StorageLayoutTypeSetStorage(ref SharedRef<IStorage> baseStorage, StorageLayoutType storageFlag)
public StorageLayoutTypeSetStorage(ref readonly SharedRef<IStorage> baseStorage, StorageLayoutType storageFlag)
{
_baseStorage = SharedRef<IStorage>.CreateMove(ref baseStorage);
_baseStorage = SharedRef<IStorage>.CreateCopy(in baseStorage);
_storageFlag = storageFlag;
Assert.SdkAssert(StorageLayoutTypeFunctions.IsStorageFlagValid(storageFlag));

View file

@ -27,9 +27,9 @@ internal class GameCardDeviceOperator : IStorageDeviceOperator
return (uint)((ulong)byteCount / GcPageSize);
}
public GameCardDeviceOperator(ref SharedRef<GameCardStorageDevice> storageDevice, IGcApi gc)
public GameCardDeviceOperator(ref readonly SharedRef<GameCardStorageDevice> storageDevice, IGcApi gc)
{
_storageDevice = SharedRef<GameCardStorageDevice>.CreateMove(ref storageDevice);
_storageDevice = SharedRef<GameCardStorageDevice>.CreateCopy(in storageDevice);
_gc = gc;
}

View file

@ -559,14 +559,14 @@ public class GameCardManager : IStorageDeviceManager, IStorageDeviceOperator, IG
{
using SharedRef<IGameCardManager> manager = SharedRef<IGameCardManager>.Create(in _selfReference);
return new ReadOnlyGameCardStorage(ref manager.Ref, _gc);
return new ReadOnlyGameCardStorage(in manager, _gc);
}
private WriteOnlyGameCardStorage MakeWriteOnlyGameCardStorage()
{
using SharedRef<IGameCardManager> manager = SharedRef<IGameCardManager>.Create(in _selfReference);
return new WriteOnlyGameCardStorage(ref manager.Ref, _gc);
return new WriteOnlyGameCardStorage(in manager, _gc);
}
private SharedRef<IStorageDevice> CreateStorageDeviceNonSecure(ref readonly SharedRef<IStorage> baseStorage,
@ -575,7 +575,7 @@ public class GameCardManager : IStorageDeviceManager, IStorageDeviceOperator, IG
using SharedRef<IGameCardManager> manager = SharedRef<IGameCardManager>.Create(in _selfReference);
using SharedRef<GameCardStorageDevice> storageDevice =
GameCardStorageDevice.CreateShared(_gc, ref manager.Ref, in baseStorage, handle);
GameCardStorageDevice.CreateShared(_gc, in manager, in baseStorage, handle);
return SharedRef<IStorageDevice>.CreateMove(ref storageDevice.Ref);
}
@ -586,7 +586,7 @@ public class GameCardManager : IStorageDeviceManager, IStorageDeviceOperator, IG
using SharedRef<IGameCardManager> manager = SharedRef<IGameCardManager>.Create(in _selfReference);
using SharedRef<GameCardStorageDevice> storageDevice = GameCardStorageDevice.CreateShared(
_gc, ref manager.Ref, in baseStorage, handle, isSecure: true, cardDeviceId, cardImageHash);
_gc, in manager, in baseStorage, handle, isSecure: true, cardDeviceId, cardImageHash);
return SharedRef<IStorageDevice>.CreateMove(ref storageDevice.Ref);
}

View file

@ -145,7 +145,7 @@ internal class GameCardStorageDevice : GameCardStorageInterfaceAdapter, IStorage
SharedRef<GameCardStorageDevice>.Create(in _selfReference);
using var deviceOperator =
new SharedRef<GameCardDeviceOperator>(new GameCardDeviceOperator(ref storageDevice.Ref, _gc));
new SharedRef<GameCardDeviceOperator>(new GameCardDeviceOperator(in storageDevice, _gc));
if (!deviceOperator.HasValue)
return ResultFs.AllocationMemoryFailedInGameCardManagerG.Log();

View file

@ -211,7 +211,7 @@ internal class MmcManager : IStorageDeviceManager, IStorageDeviceOperator, ISdmm
using SharedRef<ISdmmcDeviceManager> manager = SharedRef<ISdmmcDeviceManager>.Create(in _selfReference);
using SharedRef<MmcUserDataPartitionStorageDevice> storageDevice =
MmcUserDataPartitionStorageDevice.CreateShared(ref manager.Ref, MmcHandle, _sdmmc);
MmcUserDataPartitionStorageDevice.CreateShared(in manager, MmcHandle, _sdmmc);
outStorageDevice.SetByMove(ref storageDevice.Ref);
}
@ -221,7 +221,7 @@ internal class MmcManager : IStorageDeviceManager, IStorageDeviceOperator, ISdmm
using SharedRef<ISdmmcDeviceManager> manager = SharedRef<ISdmmcDeviceManager>.Create(in _selfReference);
using SharedRef<MmcBootPartitionStorageDevice> storageDevice =
MmcBootPartitionStorageDevice.CreateShared(partition, ref manager.Ref, MmcHandle, _sdmmc);
MmcBootPartitionStorageDevice.CreateShared(partition, in manager, MmcHandle, _sdmmc);
outStorageDevice.SetByMove(ref storageDevice.Ref);
}

View file

@ -60,8 +60,7 @@ internal abstract class MmcPartitionStorageDevice : IDisposable
using SharedRef<MmcPartitionStorageDevice> storageDevice =
SharedRef<MmcPartitionStorageDevice>.Create(in SelfReference);
using var deviceOperator =
new SharedRef<MmcDeviceOperator>(new MmcDeviceOperator(ref storageDevice.Ref, Sdmmc));
using var deviceOperator = new SharedRef<MmcDeviceOperator>(new MmcDeviceOperator(in storageDevice, Sdmmc));
if (!deviceOperator.HasValue)
return ResultFs.AllocationMemoryFailedInSdmmcStorageServiceA.Log();

View file

@ -183,9 +183,7 @@ public class SdCardManager : IStorageDeviceManager, IStorageDeviceOperator, ISdm
if (res.IsFailure()) return res.Miss();
using SharedRef<ISdmmcDeviceManager> manager = SharedRef<ISdmmcDeviceManager>.Create(in _selfReference);
using SharedRef<SdCardStorageDevice>
storageDevice = SdCardStorageDevice.CreateShared(ref manager.Ref, handle, _sdmmc);
using SharedRef<SdCardStorageDevice> storageDevice = SdCardStorageDevice.CreateShared(in manager, handle, _sdmmc);
if (!storageDevice.HasValue)
return ResultFs.AllocationMemoryFailedInSdmmcStorageServiceA.Log();

View file

@ -73,7 +73,7 @@ internal class SdCardStorageDevice : SdmmcStorageInterfaceAdapter, IStorageDevic
using SharedRef<SdCardStorageDevice> storageDevice = SharedRef<SdCardStorageDevice>.Create(in _selfReference);
using var deviceOperator =
new SharedRef<SdCardDeviceOperator>(new SdCardDeviceOperator(ref storageDevice.Ref, _sdmmc));
new SharedRef<SdCardDeviceOperator>(new SdCardDeviceOperator(in storageDevice, _sdmmc));
if (!deviceOperator.HasValue)
return ResultFs.AllocationMemoryFailedInSdmmcStorageServiceA.Log();

View file

@ -1,5 +1,4 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using LibHac.Fs;

View file

@ -38,7 +38,7 @@ public class ReadOnlyBlockCacheStorageTests
}
using var baseStorage = new SharedRef<IStorage>(new MemoryStorage(BaseData));
CacheStorage = new ReadOnlyBlockCacheStorage(ref baseStorage.Ref, _blockSize, CacheBuffer, _cacheBlockCount);
CacheStorage = new ReadOnlyBlockCacheStorage(in baseStorage, _blockSize, CacheBuffer, _cacheBlockCount);
}
public Span<byte> GetBaseDataBlock(int index) => BaseData.AsSpan(_blockSize * index, _blockSize);