mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Fixup ref readonly
params to use in
instead of ref
This commit is contained in:
parent
6a5d03e1f3
commit
6599c5977b
59 changed files with 181 additions and 260 deletions
|
@ -9,7 +9,6 @@ using System.Xml.Linq;
|
||||||
using ICSharpCode.SharpZipLib.Zip;
|
using ICSharpCode.SharpZipLib.Zip;
|
||||||
using Nuke.Common.IO;
|
using Nuke.Common.IO;
|
||||||
using Nuke.Common.Tools.NuGet;
|
using Nuke.Common.Tools.NuGet;
|
||||||
using static Nuke.Common.IO.FileSystemTasks;
|
|
||||||
|
|
||||||
namespace LibHacBuild;
|
namespace LibHacBuild;
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class BcatServer
|
||||||
|
|
||||||
using SharedRef<IServiceCreator> service = GetServiceCreator(type);
|
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())
|
if (res.IsFailure())
|
||||||
{
|
{
|
||||||
throw new HorizonResultException(res, "Abort");
|
throw new HorizonResultException(res, "Abort");
|
||||||
|
|
|
@ -661,7 +661,7 @@ public static class UserFileSystem
|
||||||
if (!fileSystem.HasValue)
|
if (!fileSystem.HasValue)
|
||||||
return ResultFs.UnsupportedCommitTarget.Log();
|
return ResultFs.UnsupportedCommitTarget.Log();
|
||||||
|
|
||||||
res = commitManager.Get.Add(fileSystem.Ref);
|
res = commitManager.Get.Add(in fileSystem);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using LibHac.Diag;
|
using LibHac.Diag;
|
||||||
using LibHac.Htc;
|
using LibHac.Htc;
|
||||||
using LibHac.HtcFs;
|
using LibHac.HtcFs;
|
||||||
|
|
|
@ -64,8 +64,7 @@ public static class Application
|
||||||
Ncm.ProgramId.InvalidId.Value, FileSystemProxyType.Package);
|
Ncm.ProgramId.InvalidId.Value, FileSystemProxyType.Package);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
using var fileSystemAdapter =
|
using var fileSystemAdapter = new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
|
||||||
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref));
|
|
||||||
|
|
||||||
if (!fileSystemAdapter.HasValue)
|
if (!fileSystemAdapter.HasValue)
|
||||||
return ResultFs.AllocationMemoryFailedInApplicationA.Log();
|
return ResultFs.AllocationMemoryFailedInApplicationA.Log();
|
||||||
|
|
|
@ -25,7 +25,7 @@ public static class BaseFileSystem
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Result RegisterFileSystem(FileSystemClient fs, U8Span mountName,
|
private static Result RegisterFileSystem(FileSystemClient fs, U8Span mountName,
|
||||||
ref SharedRef<IFileSystemSf> fileSystem)
|
ref readonly SharedRef<IFileSystemSf> fileSystem)
|
||||||
{
|
{
|
||||||
using var fileSystemAdapter =
|
using var fileSystemAdapter =
|
||||||
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
|
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
|
||||||
|
@ -47,7 +47,7 @@ public static class BaseFileSystem
|
||||||
fs.Impl.AbortIfNeeded(res);
|
fs.Impl.AbortIfNeeded(res);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
res = RegisterFileSystem(fs, mountName, ref fileSystem.Ref);
|
res = RegisterFileSystem(fs, mountName, in fileSystem);
|
||||||
fs.Impl.AbortIfNeeded(res);
|
fs.Impl.AbortIfNeeded(res);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
|
|
|
@ -67,8 +67,7 @@ public static class BcatSaveData
|
||||||
res = fileSystemProxy.Get.OpenSaveDataFileSystem(ref fileSystem.Ref, SaveDataSpaceId.User, in attribute);
|
res = fileSystemProxy.Get.OpenSaveDataFileSystem(ref fileSystem.Ref, SaveDataSpaceId.User, in attribute);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
using var fileSystemAdapter =
|
using var fileSystemAdapter = new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
|
||||||
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref));
|
|
||||||
|
|
||||||
if (!fileSystemAdapter.HasValue)
|
if (!fileSystemAdapter.HasValue)
|
||||||
return ResultFs.AllocationMemoryFailedInBcatSaveDataA.Log();
|
return ResultFs.AllocationMemoryFailedInBcatSaveDataA.Log();
|
||||||
|
|
|
@ -107,8 +107,7 @@ public static class Bis
|
||||||
if (!mountNameGenerator.HasValue)
|
if (!mountNameGenerator.HasValue)
|
||||||
return ResultFs.AllocationMemoryFailedInBisA.Log();
|
return ResultFs.AllocationMemoryFailedInBisA.Log();
|
||||||
|
|
||||||
using var fileSystemAdapter =
|
using var fileSystemAdapter = new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
|
||||||
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref));
|
|
||||||
|
|
||||||
if (!fileSystemAdapter.HasValue)
|
if (!fileSystemAdapter.HasValue)
|
||||||
return ResultFs.AllocationMemoryFailedInBisB.Log();
|
return ResultFs.AllocationMemoryFailedInBisB.Log();
|
||||||
|
@ -174,7 +173,7 @@ public static class Bis
|
||||||
fs.Impl.AbortIfNeeded(res);
|
fs.Impl.AbortIfNeeded(res);
|
||||||
if (res.IsFailure()) return res.Miss();
|
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)
|
if (!storageAdapter.HasValue)
|
||||||
{
|
{
|
||||||
|
|
|
@ -76,8 +76,7 @@ public static class Code
|
||||||
in sfPath, attributes, programId);
|
in sfPath, attributes, programId);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
using var fileSystemAdapter =
|
using var fileSystemAdapter = new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
|
||||||
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref));
|
|
||||||
|
|
||||||
if (!fileSystemAdapter.HasValue)
|
if (!fileSystemAdapter.HasValue)
|
||||||
return ResultFs.AllocationMemoryFailedInCodeA.Log();
|
return ResultFs.AllocationMemoryFailedInCodeA.Log();
|
||||||
|
|
|
@ -51,8 +51,7 @@ public static class Content
|
||||||
res = fileSystemProxy.Get.OpenFileSystemWithId(ref fileSystem.Ref, in sfPath, attributes, id, fsType);
|
res = fileSystemProxy.Get.OpenFileSystemWithId(ref fileSystem.Ref, in sfPath, attributes, id, fsType);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
using var fileSystemAdapter =
|
using var fileSystemAdapter = new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
|
||||||
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref));
|
|
||||||
|
|
||||||
if (!fileSystemAdapter.HasValue)
|
if (!fileSystemAdapter.HasValue)
|
||||||
return ResultFs.AllocationMemoryFailedInContentA.Log();
|
return ResultFs.AllocationMemoryFailedInContentA.Log();
|
||||||
|
@ -253,8 +252,7 @@ public static class Content
|
||||||
res = fileSystemProxy.Get.OpenFileSystemWithPatch(ref fileSystem.Ref, programId, fsType);
|
res = fileSystemProxy.Get.OpenFileSystemWithPatch(ref fileSystem.Ref, programId, fsType);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
using var fileSystemAdapter =
|
using var fileSystemAdapter = new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
|
||||||
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref));
|
|
||||||
|
|
||||||
if (!fileSystemAdapter.HasValue)
|
if (!fileSystemAdapter.HasValue)
|
||||||
return ResultFs.AllocationMemoryFailedInContentA.Log();
|
return ResultFs.AllocationMemoryFailedInContentA.Log();
|
||||||
|
|
|
@ -117,8 +117,7 @@ public static class ContentStorage
|
||||||
fs.Hos.Os.SleepThread(TimeSpan.FromMilliSeconds(retryInterval));
|
fs.Hos.Os.SleepThread(TimeSpan.FromMilliSeconds(retryInterval));
|
||||||
}
|
}
|
||||||
|
|
||||||
using var fileSystemAdapter =
|
using var fileSystemAdapter = new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
|
||||||
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref));
|
|
||||||
|
|
||||||
if (!fileSystemAdapter.HasValue)
|
if (!fileSystemAdapter.HasValue)
|
||||||
return ResultFs.AllocationMemoryFailedInContentStorageA.Log();
|
return ResultFs.AllocationMemoryFailedInContentStorageA.Log();
|
||||||
|
|
|
@ -50,8 +50,7 @@ public static class CustomStorage
|
||||||
res = fileSystemProxy.Get.OpenCustomStorageFileSystem(ref fileSystem.Ref, storageId);
|
res = fileSystemProxy.Get.OpenCustomStorageFileSystem(ref fileSystem.Ref, storageId);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
using var fileSystemAdapter =
|
using var fileSystemAdapter = new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
|
||||||
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref));
|
|
||||||
|
|
||||||
res = fs.Register(mountName, ref fileSystemAdapter.Ref);
|
res = fs.Register(mountName, ref fileSystemAdapter.Ref);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
|
@ -50,7 +50,7 @@ public static class DeviceSaveData
|
||||||
res = fileSystemProxy.Get.OpenSaveDataFileSystem(ref fileSystem.Ref, DeviceSaveDataSpaceId, in attribute);
|
res = fileSystemProxy.Get.OpenSaveDataFileSystem(ref fileSystem.Ref, DeviceSaveDataSpaceId, in attribute);
|
||||||
if (res.IsFailure()) return res.Miss();
|
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);
|
using var fileSystemAdapter = new UniqueRef<IFileSystem>(fileSystemAdapterRaw);
|
||||||
|
|
||||||
if (!fileSystemAdapter.HasValue)
|
if (!fileSystemAdapter.HasValue)
|
||||||
|
|
|
@ -274,7 +274,7 @@ internal class FileSystemServiceObjectAdapter : IFileSystem, IMultiCommitTarget
|
||||||
res = _baseFs.Get.OpenDirectory(ref directoryServiceObject.Ref, in sfPath, (uint)mode);
|
res = _baseFs.Get.OpenDirectory(ref directoryServiceObject.Ref, in sfPath, (uint)mode);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
outDirectory.Reset(new DirectoryServiceObjectAdapter(ref directoryServiceObject.Ref));
|
outDirectory.Reset(new DirectoryServiceObjectAdapter(in directoryServiceObject));
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,8 +139,7 @@ public static class GameCard
|
||||||
res = fileSystemProxy.Get.OpenGameCardFileSystem(ref fileSystem.Ref, handle, partitionId);
|
res = fileSystemProxy.Get.OpenGameCardFileSystem(ref fileSystem.Ref, handle, partitionId);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
using var fileSystemAdapter =
|
using var fileSystemAdapter = new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
|
||||||
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref));
|
|
||||||
|
|
||||||
if (!fileSystemAdapter.HasValue)
|
if (!fileSystemAdapter.HasValue)
|
||||||
return ResultFs.AllocationMemoryFailedInGameCardC.Log();
|
return ResultFs.AllocationMemoryFailedInGameCardC.Log();
|
||||||
|
@ -181,7 +180,7 @@ public static class GameCard
|
||||||
fs.Impl.AbortIfNeeded(res);
|
fs.Impl.AbortIfNeeded(res);
|
||||||
if (res.IsFailure()) return res.Miss();
|
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)
|
if (!storageAdapter.HasValue)
|
||||||
return ResultFs.AllocationMemoryFailedInGameCardB.Log();
|
return ResultFs.AllocationMemoryFailedInGameCardB.Log();
|
||||||
|
|
|
@ -54,7 +54,7 @@ public static class Host
|
||||||
}
|
}
|
||||||
|
|
||||||
using var fileSystemAdapter =
|
using var fileSystemAdapter =
|
||||||
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref));
|
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
|
||||||
|
|
||||||
if (!fileSystemAdapter.HasValue)
|
if (!fileSystemAdapter.HasValue)
|
||||||
return ResultFs.AllocationMemoryFailedInHostA.Log();
|
return ResultFs.AllocationMemoryFailedInHostA.Log();
|
||||||
|
|
|
@ -59,8 +59,7 @@ public static class ImageDirectory
|
||||||
res = fileSystemProxy.Get.OpenImageDirectoryFileSystem(ref fileSystem.Ref, directoryId);
|
res = fileSystemProxy.Get.OpenImageDirectoryFileSystem(ref fileSystem.Ref, directoryId);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
using var fileSystemAdapter =
|
using var fileSystemAdapter = new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
|
||||||
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref));
|
|
||||||
|
|
||||||
if (!fileSystemAdapter.HasValue)
|
if (!fileSystemAdapter.HasValue)
|
||||||
return ResultFs.AllocationMemoryFailedInImageDirectoryA.Log();
|
return ResultFs.AllocationMemoryFailedInImageDirectoryA.Log();
|
||||||
|
|
|
@ -65,8 +65,7 @@ public static class Logo
|
||||||
FileSystemProxyType.Logo);
|
FileSystemProxyType.Logo);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
using var fileSystemAdapter =
|
using var fileSystemAdapter = new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
|
||||||
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref));
|
|
||||||
|
|
||||||
if (!fileSystemAdapter.HasValue)
|
if (!fileSystemAdapter.HasValue)
|
||||||
return ResultFs.AllocationMemoryFailedInLogoA.Log();
|
return ResultFs.AllocationMemoryFailedInLogoA.Log();
|
||||||
|
|
|
@ -34,8 +34,7 @@ public static class SaveData
|
||||||
saveDataId);
|
saveDataId);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
using var fileSystemAdapter =
|
using var fileSystemAdapter = new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
|
||||||
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref));
|
|
||||||
|
|
||||||
outFileSystem.Set(ref fileSystemAdapter.Ref);
|
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.
|
// 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.
|
// 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);
|
using var fileSystemAdapter = new UniqueRef<IFileSystem>(fileSystemAdapterRaw);
|
||||||
|
|
||||||
if (!fileSystemAdapter.HasValue)
|
if (!fileSystemAdapter.HasValue)
|
||||||
|
|
|
@ -560,7 +560,7 @@ namespace LibHac.Fs.Shim
|
||||||
Result res = fileSystemProxy.Get.OpenSaveDataInfoReaderBySaveDataSpaceId(ref reader.Ref, spaceId);
|
Result res = fileSystemProxy.Get.OpenSaveDataInfoReaderBySaveDataSpaceId(ref reader.Ref, spaceId);
|
||||||
if (res.IsFailure()) return res.Miss();
|
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)
|
if (!iterator.HasValue)
|
||||||
return ResultFs.AllocationMemoryFailedInSaveDataManagementA.Log();
|
return ResultFs.AllocationMemoryFailedInSaveDataManagementA.Log();
|
||||||
|
@ -579,7 +579,7 @@ namespace LibHac.Fs.Shim
|
||||||
Result res = fileSystemProxy.Get.OpenSaveDataInfoReaderWithFilter(ref reader.Ref, spaceId, in filter);
|
Result res = fileSystemProxy.Get.OpenSaveDataInfoReaderWithFilter(ref reader.Ref, spaceId, in filter);
|
||||||
if (res.IsFailure()) return res.Miss();
|
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)
|
if (!iterator.HasValue)
|
||||||
return ResultFs.AllocationMemoryFailedInSaveDataManagementA.Log();
|
return ResultFs.AllocationMemoryFailedInSaveDataManagementA.Log();
|
||||||
|
|
|
@ -178,7 +178,7 @@ public class SaveDataExporterVersion2 : ISaveDataDivisionExporter
|
||||||
_fsClient.Impl.AbortIfNeeded(res);
|
_fsClient.Impl.AbortIfNeeded(res);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
outIterator.Reset(new SaveDataChunkIterator(_fsClient, ref iteratorObject.Ref));
|
outIterator.Reset(new SaveDataChunkIterator(_fsClient, in iteratorObject));
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ public class SaveDataExporterVersion2 : ISaveDataDivisionExporter
|
||||||
_fsClient.Impl.AbortIfNeeded(res);
|
_fsClient.Impl.AbortIfNeeded(res);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
outExporter.Reset(new SaveDataChunkExporter(_fsClient, ref exporterObject.Ref));
|
outExporter.Reset(new SaveDataChunkExporter(_fsClient, in exporterObject));
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,7 +404,7 @@ public class SaveDataImporterVersion2 : ISaveDataDivisionImporter
|
||||||
_fsClient.Impl.AbortIfNeeded(res);
|
_fsClient.Impl.AbortIfNeeded(res);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
outIterator.Reset(new SaveDataChunkIterator(_fsClient, ref iteratorObject.Ref));
|
outIterator.Reset(new SaveDataChunkIterator(_fsClient, in iteratorObject));
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,7 +416,7 @@ public class SaveDataImporterVersion2 : ISaveDataDivisionImporter
|
||||||
_fsClient.Impl.AbortIfNeeded(res);
|
_fsClient.Impl.AbortIfNeeded(res);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
outImporter.Reset(new SaveDataChunkImporter(_fsClient, ref importerObject.Ref));
|
outImporter.Reset(new SaveDataChunkImporter(_fsClient, in importerObject));
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ namespace LibHac.Fs
|
||||||
_fsClient.Impl.LogResultErrorMessage(res);
|
_fsClient.Impl.LogResultErrorMessage(res);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
outExporter.Reset(new SaveDataExporterVersion2(_fsClient, ref exporterInterface.Ref));
|
outExporter.Reset(new SaveDataExporterVersion2(_fsClient, in exporterInterface));
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ namespace LibHac.Fs
|
||||||
_fsClient.Impl.LogResultErrorMessage(res);
|
_fsClient.Impl.LogResultErrorMessage(res);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
outExporter.Reset(new SaveDataExporterVersion2(_fsClient, ref exporterInterface.Ref));
|
outExporter.Reset(new SaveDataExporterVersion2(_fsClient, in exporterInterface));
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ namespace LibHac.Fs
|
||||||
_fsClient.Impl.LogResultErrorMessage(res);
|
_fsClient.Impl.LogResultErrorMessage(res);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
outExporter.Reset(new SaveDataExporterVersion2(_fsClient, ref exporterInterface.Ref));
|
outExporter.Reset(new SaveDataExporterVersion2(_fsClient, in exporterInterface));
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ namespace LibHac.Fs
|
||||||
_fsClient.Impl.LogResultErrorMessage(res);
|
_fsClient.Impl.LogResultErrorMessage(res);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
outImporter.Reset(new SaveDataImporterVersion2(_fsClient, ref importerInterface.Ref));
|
outImporter.Reset(new SaveDataImporterVersion2(_fsClient, in importerInterface));
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ namespace LibHac.Fs
|
||||||
_fsClient.Impl.LogResultErrorMessage(res);
|
_fsClient.Impl.LogResultErrorMessage(res);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
outImporter.Reset(new SaveDataImporterVersion2(_fsClient, ref importerInterface.Ref));
|
outImporter.Reset(new SaveDataImporterVersion2(_fsClient, in importerInterface));
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ namespace LibHac.Fs
|
||||||
_fsClient.Impl.LogResultErrorMessage(res);
|
_fsClient.Impl.LogResultErrorMessage(res);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
outImporter.Reset(new SaveDataImporterVersion2(_fsClient, ref importerInterface.Ref));
|
outImporter.Reset(new SaveDataImporterVersion2(_fsClient, in importerInterface));
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ namespace LibHac.Fs
|
||||||
_fsClient.Impl.LogResultErrorMessage(res);
|
_fsClient.Impl.LogResultErrorMessage(res);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
outImporter.Reset(new SaveDataImporterVersion2(_fsClient, ref importerInterface.Ref));
|
outImporter.Reset(new SaveDataImporterVersion2(_fsClient, in importerInterface));
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ namespace LibHac.Fs
|
||||||
_fsClient.Impl.LogResultErrorMessage(res);
|
_fsClient.Impl.LogResultErrorMessage(res);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
outImporter.Reset(new SaveDataImporterVersion2(_fsClient, ref importerInterface.Ref));
|
outImporter.Reset(new SaveDataImporterVersion2(_fsClient, in importerInterface));
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,7 +296,7 @@ namespace LibHac.Fs.Shim
|
||||||
// Result res = fileSystemProxy.Get.OpenSaveDataTransferProhibiter(ref prohibiter.Ref, applicationId);
|
// Result res = fileSystemProxy.Get.OpenSaveDataTransferProhibiter(ref prohibiter.Ref, applicationId);
|
||||||
// if (res.IsFailure()) return res.Miss();
|
// if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
outProhibiter.Reset(new SaveDataTransferProhibiterForCloudBackUp(ref prohibiter.Ref));
|
outProhibiter.Reset(new SaveDataTransferProhibiterForCloudBackUp(in prohibiter));
|
||||||
|
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,8 +56,7 @@ public static class SdCard
|
||||||
private static Result RegisterFileSystem(FileSystemClient fs, U8Span mountName,
|
private static Result RegisterFileSystem(FileSystemClient fs, U8Span mountName,
|
||||||
ref readonly SharedRef<IFileSystemSf> fileSystem)
|
ref readonly SharedRef<IFileSystemSf> fileSystem)
|
||||||
{
|
{
|
||||||
using var fileSystemAdapter =
|
using var fileSystemAdapter = new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
|
||||||
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(in fileSystem));
|
|
||||||
|
|
||||||
if (!fileSystemAdapter.HasValue)
|
if (!fileSystemAdapter.HasValue)
|
||||||
return ResultFs.AllocationMemoryFailedInSdCardA.Log();
|
return ResultFs.AllocationMemoryFailedInSdCardA.Log();
|
||||||
|
@ -113,14 +112,14 @@ public static class SdCard
|
||||||
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
|
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
|
||||||
{
|
{
|
||||||
Tick start = fs.Hos.Os.GetSystemTick();
|
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();
|
Tick end = fs.Hos.Os.GetSystemTick();
|
||||||
|
|
||||||
fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(logBuffer));
|
fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(logBuffer));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res = RegisterFileSystem(fs, mountName, ref fileSystem.Ref);
|
res = RegisterFileSystem(fs, mountName, in fileSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.Impl.AbortIfNeeded(res);
|
fs.Impl.AbortIfNeeded(res);
|
||||||
|
@ -180,14 +179,14 @@ public static class SdCard
|
||||||
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
|
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
|
||||||
{
|
{
|
||||||
Tick start = fs.Hos.Os.GetSystemTick();
|
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();
|
Tick end = fs.Hos.Os.GetSystemTick();
|
||||||
|
|
||||||
fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(logBuffer));
|
fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(logBuffer));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res = RegisterFileSystem(fs, mountName, ref fileSystem.Ref);
|
res = RegisterFileSystem(fs, mountName, in fileSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.Impl.AbortIfNeeded(res);
|
fs.Impl.AbortIfNeeded(res);
|
||||||
|
@ -208,7 +207,7 @@ public static class SdCard
|
||||||
fs.Impl.LogResultErrorMessage(res);
|
fs.Impl.LogResultErrorMessage(res);
|
||||||
Abort.DoAbortUnless(res.IsSuccess());
|
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);
|
fs.Impl.LogResultErrorMessage(res);
|
||||||
Abort.DoAbortUnless(res.IsSuccess());
|
Abort.DoAbortUnless(res.IsSuccess());
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ public static class SystemSaveData
|
||||||
res = fileSystemProxy.Get.OpenSaveDataFileSystemBySystemSaveDataId(ref fileSystem.Ref, spaceId, in attribute);
|
res = fileSystemProxy.Get.OpenSaveDataFileSystemBySystemSaveDataId(ref fileSystem.Ref, spaceId, in attribute);
|
||||||
if (res.IsFailure()) return res.Miss();
|
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);
|
using var fileSystemAdapter = new UniqueRef<IFileSystem>(fileSystemAdapterRaw);
|
||||||
|
|
||||||
if (!fileSystemAdapter.HasValue)
|
if (!fileSystemAdapter.HasValue)
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using LibHac.Common;
|
||||||
using LibHac.Common;
|
|
||||||
using LibHac.Fs;
|
using LibHac.Fs;
|
||||||
using LibHac.FsSrv.Impl;
|
using LibHac.FsSrv.Impl;
|
||||||
using LibHac.FsSrv.Sf;
|
using LibHac.FsSrv.Sf;
|
||||||
|
@ -69,8 +68,7 @@ public readonly struct BaseFileSystemService
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
// Create an SF adapter for the file system
|
// Create an SF adapter for the file system
|
||||||
using SharedRef<IFileSystemSf> fileSystemAdapter =
|
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(in fileSystem, false);
|
||||||
FileSystemInterfaceAdapter.CreateShared(ref fileSystem.Ref, false);
|
|
||||||
|
|
||||||
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
||||||
|
|
||||||
|
@ -131,19 +129,13 @@ public readonly struct BaseFileSystemService
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
using var subDirFileSystem = new SharedRef<IFileSystem>();
|
using var subDirFileSystem = new SharedRef<IFileSystem>();
|
||||||
res = Utility.CreateSubDirectoryFileSystem(ref subDirFileSystem.Ref, ref fileSystem.Ref,
|
res = Utility.CreateSubDirectoryFileSystem(ref subDirFileSystem.Ref, in fileSystem, in pathNormalized);
|
||||||
in pathNormalized);
|
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
// Add all the file system wrappers
|
// Add all the file system wrappers
|
||||||
using var typeSetFileSystem =
|
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(in subDirFileSystem, storageFlag));
|
||||||
new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(ref subDirFileSystem.Ref, storageFlag));
|
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(in typeSetFileSystem));
|
||||||
|
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(in asyncFileSystem, allowAllOperations: false);
|
||||||
using var asyncFileSystem =
|
|
||||||
new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(ref typeSetFileSystem.Ref));
|
|
||||||
|
|
||||||
using SharedRef<IFileSystemSf> fileSystemAdapter =
|
|
||||||
FileSystemInterfaceAdapter.CreateShared(ref asyncFileSystem.Ref, false);
|
|
||||||
|
|
||||||
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
||||||
|
|
||||||
|
@ -193,10 +185,10 @@ public readonly struct BaseFileSystemService
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
using var asyncFileSystem =
|
using var asyncFileSystem =
|
||||||
new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(ref fileSystem.Ref));
|
new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(in fileSystem));
|
||||||
|
|
||||||
using SharedRef<IFileSystemSf> fileSystemAdapter =
|
using SharedRef<IFileSystemSf> fileSystemAdapter =
|
||||||
FileSystemInterfaceAdapter.CreateShared(ref asyncFileSystem.Ref, false);
|
FileSystemInterfaceAdapter.CreateShared(in asyncFileSystem, false);
|
||||||
|
|
||||||
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
||||||
|
|
||||||
|
@ -221,14 +213,9 @@ public readonly struct BaseFileSystemService
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
// Add all the file system wrappers
|
// Add all the file system wrappers
|
||||||
using var typeSetFileSystem =
|
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(in fileSystem, storageFlag));
|
||||||
new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(ref fileSystem.Ref, storageFlag));
|
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(in typeSetFileSystem));
|
||||||
|
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(in asyncFileSystem, allowAllOperations: false);
|
||||||
using var asyncFileSystem =
|
|
||||||
new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(ref typeSetFileSystem.Ref));
|
|
||||||
|
|
||||||
using SharedRef<IFileSystemSf> fileSystemAdapter =
|
|
||||||
FileSystemInterfaceAdapter.CreateShared(ref asyncFileSystem.Ref, false);
|
|
||||||
|
|
||||||
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
||||||
|
|
||||||
|
@ -293,7 +280,7 @@ public readonly struct BaseFileSystemService
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
using SharedRef<IFileSystemSf> fileSystemAdapter =
|
using SharedRef<IFileSystemSf> fileSystemAdapter =
|
||||||
FileSystemInterfaceAdapter.CreateShared(ref baseFileSystem.Ref, false);
|
FileSystemInterfaceAdapter.CreateShared(in baseFileSystem, false);
|
||||||
|
|
||||||
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
||||||
|
|
||||||
|
|
|
@ -79,13 +79,9 @@ public readonly struct BaseStorageService
|
||||||
res = _serviceImpl.OpenBisStorage(ref storage.Ref, id);
|
res = _serviceImpl.OpenBisStorage(ref storage.Ref, id);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
using var typeSetStorage =
|
using var typeSetStorage = new SharedRef<IStorage>(new StorageLayoutTypeSetStorage(in storage, storageFlag));
|
||||||
new SharedRef<IStorage>(new StorageLayoutTypeSetStorage(ref storage.Ref, storageFlag));
|
|
||||||
|
|
||||||
// Todo: Async storage
|
// Todo: Async storage
|
||||||
|
using var storageAdapter = new SharedRef<IStorageSf>(new StorageInterfaceAdapter(in typeSetStorage));
|
||||||
using var storageAdapter =
|
|
||||||
new SharedRef<IStorageSf>(new StorageInterfaceAdapter(ref typeSetStorage.Ref));
|
|
||||||
|
|
||||||
outStorage.SetByMove(ref storageAdapter.Ref);
|
outStorage.SetByMove(ref storageAdapter.Ref);
|
||||||
|
|
||||||
|
@ -122,9 +118,7 @@ public readonly struct BaseStorageService
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
// Todo: Async storage
|
// Todo: Async storage
|
||||||
|
using var storageAdapter = new SharedRef<IStorageSf>(new StorageInterfaceAdapter(in storage));
|
||||||
using var storageAdapter =
|
|
||||||
new SharedRef<IStorageSf>(new StorageInterfaceAdapter(ref storage.Ref));
|
|
||||||
|
|
||||||
outStorage.SetByMove(ref storageAdapter.Ref);
|
outStorage.SetByMove(ref storageAdapter.Ref);
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,6 @@ public class DefaultFsServerObjects
|
||||||
var gcStorageCreator = new GameCardStorageCreator(fsServer);
|
var gcStorageCreator = new GameCardStorageCreator(fsServer);
|
||||||
|
|
||||||
using var sharedRootFileSystem = new SharedRef<IFileSystem>(rootFileSystem);
|
using var sharedRootFileSystem = new SharedRef<IFileSystem>(rootFileSystem);
|
||||||
using SharedRef<IFileSystem> sharedRootFileSystemCopy =
|
|
||||||
SharedRef<IFileSystem>.CreateCopy(in sharedRootFileSystem);
|
|
||||||
|
|
||||||
var memoryResource = new ArrayPoolMemoryResource();
|
var memoryResource = new ArrayPoolMemoryResource();
|
||||||
IBufferManager bufferManager = null;
|
IBufferManager bufferManager = null;
|
||||||
|
@ -47,8 +45,8 @@ public class DefaultFsServerObjects
|
||||||
creators.GameCardStorageCreator = gcStorageCreator;
|
creators.GameCardStorageCreator = gcStorageCreator;
|
||||||
creators.GameCardFileSystemCreator = new GameCardFileSystemCreator(memoryResource, gcStorageCreator, fsServer);
|
creators.GameCardFileSystemCreator = new GameCardFileSystemCreator(memoryResource, gcStorageCreator, fsServer);
|
||||||
creators.EncryptedFileSystemCreator = new EncryptedFileSystemCreator(keySet);
|
creators.EncryptedFileSystemCreator = new EncryptedFileSystemCreator(keySet);
|
||||||
creators.BuiltInStorageFileSystemCreator = new EmulatedBisFileSystemCreator(ref sharedRootFileSystem.Ref);
|
creators.BuiltInStorageFileSystemCreator = new EmulatedBisFileSystemCreator(in sharedRootFileSystem);
|
||||||
creators.SdCardFileSystemCreator = new EmulatedSdCardFileSystemCreator(sdmmcNew, ref sharedRootFileSystemCopy.Ref);
|
creators.SdCardFileSystemCreator = new EmulatedSdCardFileSystemCreator(sdmmcNew, in sharedRootFileSystem);
|
||||||
|
|
||||||
var storageDeviceManagerFactory = new EmulatedStorageDeviceManagerFactory(fsServer, sdmmcNew, gameCardNew, hasGameCard: true);
|
var storageDeviceManagerFactory = new EmulatedStorageDeviceManagerFactory(fsServer, sdmmcNew, gameCardNew, hasGameCard: true);
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class FileSystemProxyCoreImpl
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
using SharedRef<IFileSystem> tempFs = SharedRef<IFileSystem>.CreateMove(ref fileSystem.Ref);
|
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();
|
if (res.IsFailure()) return res.Miss();
|
||||||
}
|
}
|
||||||
else if (storageId == CustomStorageId.SdCard)
|
else if (storageId == CustomStorageId.SdCard)
|
||||||
|
@ -61,7 +61,7 @@ public class FileSystemProxyCoreImpl
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
using SharedRef<IFileSystem> tempFs = SharedRef<IFileSystem>.CreateMove(ref fileSystem.Ref);
|
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();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
tempFs.SetByMove(ref fileSystem.Ref);
|
tempFs.SetByMove(ref fileSystem.Ref);
|
||||||
|
|
|
@ -848,14 +848,9 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
// Add all the file system wrappers
|
// Add all the file system wrappers
|
||||||
using var typeSetFileSystem =
|
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(in fileSystem, storageFlag));
|
||||||
new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(ref fileSystem.Ref, storageFlag));
|
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(in typeSetFileSystem));
|
||||||
|
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(in asyncFileSystem, allowAllOperations: false);
|
||||||
using var asyncFileSystem =
|
|
||||||
new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(ref typeSetFileSystem.Ref));
|
|
||||||
|
|
||||||
using SharedRef<IFileSystemSf> fileSystemAdapter =
|
|
||||||
FileSystemInterfaceAdapter.CreateShared(ref asyncFileSystem.Ref, allowAllOperations: false);
|
|
||||||
|
|
||||||
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ public static class FileSystemServerInitializer
|
||||||
ulong processId = client.Os.GetCurrentProcessId().Value;
|
ulong processId = client.Os.GetCurrentProcessId().Value;
|
||||||
fileSystemProxy.Get.SetCurrentProcess(processId).IgnoreResult();
|
fileSystemProxy.Get.SetCurrentProcess(processId).IgnoreResult();
|
||||||
|
|
||||||
client.Fs.Impl.InitializeDfcFileSystemProxyServiceObject(ref fileSystemProxy.Ref);
|
client.Fs.Impl.InitializeDfcFileSystemProxyServiceObject(in fileSystemProxy);
|
||||||
|
|
||||||
InitializeFileSystemProxyServer(client, server);
|
InitializeFileSystemProxyServer(client, server);
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class EmulatedBisFileSystemCreator : IBuiltInStorageFileSystemCreator
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
using var partitionFileSystem = new SharedRef<IFileSystem>();
|
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();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
outFileSystem.SetByMove(ref partitionFileSystem.Ref);
|
outFileSystem.SetByMove(ref partitionFileSystem.Ref);
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class EmulatedSdCardFileSystemCreator : ISdCardProxyFileSystemCreator, ID
|
||||||
// Todo: Add ProxyFileSystem?
|
// Todo: Add ProxyFileSystem?
|
||||||
|
|
||||||
using SharedRef<IFileSystem> fileSystem = SharedRef<IFileSystem>.CreateCopy(in _rootFileSystem);
|
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();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
outFileSystem.SetByCopy(in _sdCardFileSystem);
|
outFileSystem.SetByCopy(in _sdCardFileSystem);
|
||||||
|
|
|
@ -280,7 +280,7 @@ public class GameCardFileSystemCreator : IGameCardFileSystemCreator
|
||||||
res = rootPartitionFsMeta.Get.Initialize(rootFsStorage.Get, _allocator, status.PartitionFsHeaderHash, salt);
|
res = rootPartitionFsMeta.Get.Initialize(rootFsStorage.Get, _allocator, status.PartitionFsHeaderHash, salt);
|
||||||
if (res.IsFailure()) return res.Miss();
|
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));
|
ref rootPartitionFsMeta.Ref, _fsServer));
|
||||||
|
|
||||||
if (!_rootPartition.HasValue)
|
if (!_rootPartition.HasValue)
|
||||||
|
|
|
@ -413,7 +413,7 @@ public class SaveDataFileSystemCreator : ISaveDataFileSystemCreator
|
||||||
|
|
||||||
// Wrap the save FS in a result convert FS and set it as the output FS
|
// Wrap the save FS in a result convert FS and set it as the output FS
|
||||||
using var resultConvertFs = new SharedRef<SaveDataResultConvertFileSystem>(
|
using var resultConvertFs = new SharedRef<SaveDataResultConvertFileSystem>(
|
||||||
new SaveDataResultConvertFileSystem(ref saveDataFs.Ref, isReconstructible));
|
new SaveDataResultConvertFileSystem(in saveDataFs, isReconstructible));
|
||||||
|
|
||||||
outFileSystem.SetByMove(ref resultConvertFs.Ref);
|
outFileSystem.SetByMove(ref resultConvertFs.Ref);
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
|
@ -450,7 +450,7 @@ public class SaveDataFileSystemCreator : ISaveDataFileSystemCreator
|
||||||
}
|
}
|
||||||
|
|
||||||
using var resultConvertFs = new SharedRef<SaveDataResultConvertFileSystem>(
|
using var resultConvertFs = new SharedRef<SaveDataResultConvertFileSystem>(
|
||||||
new SaveDataResultConvertFileSystem(ref saveDataFs.Ref, isReconstructible));
|
new SaveDataResultConvertFileSystem(in saveDataFs, isReconstructible));
|
||||||
|
|
||||||
outExtraDataAccessor.SetByMove(ref resultConvertFs.Ref);
|
outExtraDataAccessor.SetByMove(ref resultConvertFs.Ref);
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
|
@ -507,7 +507,7 @@ public class SaveDataFileSystemCreator : ISaveDataFileSystemCreator
|
||||||
|
|
||||||
using SharedRef<ISaveDataFileSystem> tempSaveFs = SharedRef<ISaveDataFileSystem>.CreateMove(ref saveFs.Ref);
|
using SharedRef<ISaveDataFileSystem> tempSaveFs = SharedRef<ISaveDataFileSystem>.CreateMove(ref saveFs.Ref);
|
||||||
using var resultConvertFs = new SharedRef<SaveDataResultConvertFileSystem>(
|
using var resultConvertFs = new SharedRef<SaveDataResultConvertFileSystem>(
|
||||||
new SaveDataResultConvertFileSystem(ref tempSaveFs.Ref, isReconstructible));
|
new SaveDataResultConvertFileSystem(in tempSaveFs, isReconstructible));
|
||||||
|
|
||||||
outFileSystem.SetByMove(ref resultConvertFs.Ref);
|
outFileSystem.SetByMove(ref resultConvertFs.Ref);
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class DeepRetryFileSystem : ForwardingFileSystem
|
||||||
using var retryFileSystem = new SharedRef<DeepRetryFileSystem>(
|
using var retryFileSystem = new SharedRef<DeepRetryFileSystem>(
|
||||||
new DeepRetryFileSystem(in baseFileSystem, in accessFailureManager));
|
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);
|
return SharedRef<IFileSystem>.CreateMove(ref retryFileSystem.Ref);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using LibHac.Common;
|
using LibHac.Common;
|
||||||
using LibHac.Fs;
|
using LibHac.Fs;
|
||||||
using LibHac.Fs.Fsa;
|
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.
|
// creating files and directories. We don't have an ISharedObject, so a self-reference is used instead.
|
||||||
private WeakRef<FileSystemInterfaceAdapter> _selfReference;
|
private WeakRef<FileSystemInterfaceAdapter> _selfReference;
|
||||||
|
|
||||||
private FileSystemInterfaceAdapter(ref readonly SharedRef<IFileSystem> fileSystem,
|
private FileSystemInterfaceAdapter(ref readonly SharedRef<IFileSystem> fileSystem, bool allowAllOperations)
|
||||||
bool allowAllOperations)
|
|
||||||
{
|
{
|
||||||
_baseFileSystem = SharedRef<IFileSystem>.CreateCopy(in fileSystem);
|
_baseFileSystem = SharedRef<IFileSystem>.CreateCopy(in fileSystem);
|
||||||
_allowAllOperations = allowAllOperations;
|
_allowAllOperations = allowAllOperations;
|
||||||
|
@ -506,7 +504,7 @@ public class FileSystemInterfaceAdapter : IFileSystemSf
|
||||||
using SharedRef<FileSystemInterfaceAdapter> selfReference =
|
using SharedRef<FileSystemInterfaceAdapter> selfReference =
|
||||||
SharedRef<FileSystemInterfaceAdapter>.Create(in _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);
|
outFile.Reset(adapter);
|
||||||
|
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
|
@ -537,7 +535,7 @@ public class FileSystemInterfaceAdapter : IFileSystemSf
|
||||||
using SharedRef<FileSystemInterfaceAdapter> selfReference =
|
using SharedRef<FileSystemInterfaceAdapter> selfReference =
|
||||||
SharedRef<FileSystemInterfaceAdapter>.Create(in _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);
|
outDirectory.Reset(adapter);
|
||||||
|
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
|
|
|
@ -142,7 +142,7 @@ public class SaveDataFileSystemCacheManager : IDisposable
|
||||||
{
|
{
|
||||||
using ScopedLock<SdkRecursiveMutexType> scopedLock = ScopedLock.Lock(ref _mutex);
|
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;
|
_nextCacheIndex = (_nextCacheIndex + 1) % _maxCachedFileSystemCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,11 +170,12 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add all the file system wrappers
|
// 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));
|
||||||
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(ref typeSetFileSystem.Ref));
|
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(in typeSetFileSystem));
|
||||||
|
|
||||||
using SharedRef<IRomFileSystemAccessFailureManager> accessFailureManager = SharedRef<IRomFileSystemAccessFailureManager>.Create(in _selfReference);
|
using SharedRef<IRomFileSystemAccessFailureManager> accessFailureManager = SharedRef<IRomFileSystemAccessFailureManager>.Create(in _selfReference);
|
||||||
using SharedRef<IFileSystem> retryFileSystem = DeepRetryFileSystem.CreateShared(ref asyncFileSystem.Ref, ref accessFailureManager.Ref);
|
using SharedRef<IFileSystem> retryFileSystem = DeepRetryFileSystem.CreateShared(in asyncFileSystem, in accessFailureManager);
|
||||||
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(ref retryFileSystem.Ref, false);
|
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(in retryFileSystem, false);
|
||||||
|
|
||||||
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
||||||
|
|
||||||
|
@ -211,9 +212,9 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
// Add all the file system wrappers
|
// 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));
|
||||||
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(ref typeSetFileSystem.Ref));
|
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(in typeSetFileSystem));
|
||||||
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(ref asyncFileSystem.Ref, allowAllOperations: false);
|
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(in asyncFileSystem, allowAllOperations: false);
|
||||||
|
|
||||||
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
||||||
|
|
||||||
|
@ -237,11 +238,11 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
asyncFileSystem.Reset(new AsynchronousAccessFileSystem(ref fileSystem.Ref));
|
asyncFileSystem.Reset(new AsynchronousAccessFileSystem(in fileSystem));
|
||||||
}
|
}
|
||||||
|
|
||||||
using SharedRef<IFileSystemSf> fileSystemAdapter =
|
using SharedRef<IFileSystemSf> fileSystemAdapter =
|
||||||
FileSystemInterfaceAdapter.CreateShared(ref asyncFileSystem.Ref, allowAllOperations: false);
|
FileSystemInterfaceAdapter.CreateShared(in asyncFileSystem, allowAllOperations: false);
|
||||||
|
|
||||||
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
||||||
|
|
||||||
|
@ -415,8 +416,8 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
|
||||||
in accessFailureManager, ref romDivisionSizeUnitCountSemaphore.Ref, in digest, programInfo.ProgramIdValue,
|
in accessFailureManager, ref romDivisionSizeUnitCountSemaphore.Ref, in digest, programInfo.ProgramIdValue,
|
||||||
storageId, _serviceImpl.FsServer));
|
storageId, _serviceImpl.FsServer));
|
||||||
|
|
||||||
using var typeSetStorage = new SharedRef<IStorage>(new StorageLayoutTypeSetStorage(ref retryStorage.Ref, storageFlag));
|
using var typeSetStorage = new SharedRef<IStorage>(new StorageLayoutTypeSetStorage(in retryStorage, storageFlag));
|
||||||
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);
|
outStorage.SetByMove(ref storageAdapter.Ref);
|
||||||
|
|
||||||
|
@ -467,8 +468,8 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
|
||||||
in accessFailureManager, ref romDivisionSizeUnitCountSemaphore.Ref, in digest, ProgramId.InvalidId.Value,
|
in accessFailureManager, ref romDivisionSizeUnitCountSemaphore.Ref, in digest, ProgramId.InvalidId.Value,
|
||||||
StorageId.None, _serviceImpl.FsServer));
|
StorageId.None, _serviceImpl.FsServer));
|
||||||
|
|
||||||
using var typeSetStorage = new SharedRef<IStorage>(new StorageLayoutTypeSetStorage(ref retryStorage.Ref, storageFlag));
|
using var typeSetStorage = new SharedRef<IStorage>(new StorageLayoutTypeSetStorage(in retryStorage, storageFlag));
|
||||||
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);
|
outStorage.SetByMove(ref storageAdapter.Ref);
|
||||||
|
|
||||||
|
@ -511,8 +512,8 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
|
||||||
in accessFailureManager, ref romDivisionSizeUnitCountSemaphore.Ref, in digest, programId.Value,
|
in accessFailureManager, ref romDivisionSizeUnitCountSemaphore.Ref, in digest, programId.Value,
|
||||||
programInfo.StorageId, _serviceImpl.FsServer));
|
programInfo.StorageId, _serviceImpl.FsServer));
|
||||||
|
|
||||||
using var typeSetStorage = new SharedRef<IStorage>(new StorageLayoutTypeSetStorage(ref retryStorage.Ref, storageFlag));
|
using var typeSetStorage = new SharedRef<IStorage>(new StorageLayoutTypeSetStorage(in retryStorage, storageFlag));
|
||||||
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);
|
outStorage.SetByMove(ref storageAdapter.Ref);
|
||||||
|
|
||||||
|
@ -589,14 +590,9 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
// Add all the wrappers for the file system
|
// Add all the wrappers for the file system
|
||||||
using var typeSetFileSystem =
|
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(in fileSystem, storageFlag));
|
||||||
new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(ref fileSystem.Ref, storageFlag));
|
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(in typeSetFileSystem));
|
||||||
|
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(in asyncFileSystem, allowAllOperations: false);
|
||||||
using var asyncFileSystem =
|
|
||||||
new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(ref fileSystem.Ref));
|
|
||||||
|
|
||||||
using SharedRef<IFileSystemSf> fileSystemAdapter =
|
|
||||||
FileSystemInterfaceAdapter.CreateShared(ref asyncFileSystem.Ref, allowAllOperations: false);
|
|
||||||
|
|
||||||
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
||||||
|
|
||||||
|
@ -618,10 +614,10 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
|
||||||
if (!properProgramInfo.AccessControl.HasContentOwnerId(programId.Value))
|
if (!properProgramInfo.AccessControl.HasContentOwnerId(programId.Value))
|
||||||
return ResultFs.PermissionDenied.Log();
|
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 =
|
using SharedRef<IFileSystemSf> fileSystemAdapter =
|
||||||
FileSystemInterfaceAdapter.CreateShared(ref asyncFileSystem.Ref, allowAllOperations: false);
|
FileSystemInterfaceAdapter.CreateShared(in asyncFileSystem, allowAllOperations: false);
|
||||||
|
|
||||||
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
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,
|
using var retryStorage = new SharedRef<IStorage>(new DeepRetryStorage(in storage, in storageAccessSplitter,
|
||||||
in accessFailureManager, ref mountCountSemaphore.Ref, deepRetryEnabled: isAoc, _serviceImpl.FsServer));
|
in accessFailureManager, ref mountCountSemaphore.Ref, deepRetryEnabled: isAoc, _serviceImpl.FsServer));
|
||||||
|
|
||||||
using var typeSetStorage = new SharedRef<IStorage>(new StorageLayoutTypeSetStorage(ref retryStorage.Ref, storageFlag));
|
using var typeSetStorage = new SharedRef<IStorage>(new StorageLayoutTypeSetStorage(in retryStorage, storageFlag));
|
||||||
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);
|
outStorage.SetByMove(ref storageAdapter.Ref);
|
||||||
|
|
||||||
|
@ -742,8 +738,8 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
|
||||||
return res.Miss();
|
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));
|
||||||
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(ref typeSetFileSystem.Ref, allowAllOperations: false);
|
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(in typeSetFileSystem, allowAllOperations: false);
|
||||||
|
|
||||||
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
||||||
|
|
||||||
|
@ -777,8 +773,8 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add all the file system wrappers
|
// Add all the file system wrappers
|
||||||
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);
|
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(in asyncFileSystem, allowAllOperations: false);
|
||||||
|
|
||||||
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
||||||
|
|
||||||
|
@ -822,8 +818,8 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
|
||||||
in accessFailureManager, ref romDivisionSizeUnitCountSemaphore.Ref, in digest, targetProgramId.Value,
|
in accessFailureManager, ref romDivisionSizeUnitCountSemaphore.Ref, in digest, targetProgramId.Value,
|
||||||
programInfo.StorageId, _serviceImpl.FsServer));
|
programInfo.StorageId, _serviceImpl.FsServer));
|
||||||
|
|
||||||
using var typeSetStorage = new SharedRef<IStorage>(new StorageLayoutTypeSetStorage(ref retryStorage.Ref, storageFlag));
|
using var typeSetStorage = new SharedRef<IStorage>(new StorageLayoutTypeSetStorage(in retryStorage, storageFlag));
|
||||||
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);
|
outStorage.SetByMove(ref storageAdapter.Ref);
|
||||||
|
|
||||||
|
@ -949,7 +945,7 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
// Add all the file system wrappers
|
// 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);
|
outFileSystem.SetByMove(ref typeSetFileSystem.Ref);
|
||||||
|
|
||||||
|
@ -975,10 +971,10 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
// Add all the file system wrappers
|
// 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));
|
||||||
using var alignmentMatchableFileSystem = new SharedRef<IFileSystem>(new AlignmentMatchableFileSystem(ref fileSystem.Ref));
|
using var alignmentMatchableFileSystem = new SharedRef<IFileSystem>(new AlignmentMatchableFileSystem(in typeSetFileSystem));
|
||||||
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(ref alignmentMatchableFileSystem.Ref));
|
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(in alignmentMatchableFileSystem));
|
||||||
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(ref asyncFileSystem.Ref, allowAllOperations: false);
|
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(in asyncFileSystem, allowAllOperations: false);
|
||||||
|
|
||||||
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
||||||
|
|
||||||
|
@ -1054,14 +1050,9 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
// Add all the file system wrappers
|
// Add all the file system wrappers
|
||||||
using var typeSetFileSystem =
|
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(in fileSystem, storageFlag));
|
||||||
new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(ref fileSystem.Ref, storageFlag));
|
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(in typeSetFileSystem));
|
||||||
|
using SharedRef<IFileSystemSf> fileSystemAdapter = FileSystemInterfaceAdapter.CreateShared(in asyncFileSystem, allowAllOperations: false);
|
||||||
using var asyncFileSystem =
|
|
||||||
new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(ref typeSetFileSystem.Ref));
|
|
||||||
|
|
||||||
using SharedRef<IFileSystemSf> fileSystemAdapter =
|
|
||||||
FileSystemInterfaceAdapter.CreateShared(ref asyncFileSystem.Ref, allowAllOperations: false);
|
|
||||||
|
|
||||||
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
||||||
|
|
||||||
|
@ -1131,7 +1122,7 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
|
||||||
pathFlags.AllowWindowsPath();
|
pathFlags.AllowWindowsPath();
|
||||||
|
|
||||||
using SharedRef<IFileSystemSf> fileSystemAdapter =
|
using SharedRef<IFileSystemSf> fileSystemAdapter =
|
||||||
FileSystemInterfaceAdapter.CreateShared(ref fileSystem.Ref, pathFlags, allowAllOperations: false);
|
FileSystemInterfaceAdapter.CreateShared(in fileSystem, pathFlags, allowAllOperations: false);
|
||||||
|
|
||||||
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
||||||
|
|
||||||
|
|
|
@ -382,7 +382,7 @@ public class NcaFileSystemServiceImpl : IDisposable
|
||||||
|
|
||||||
using var ncaReader = new SharedRef<NcaReader>();
|
using var ncaReader = new SharedRef<NcaReader>();
|
||||||
ulong openProgramId = mountInfo.IsHostOrLocalFs() ? ulong.MaxValue : id;
|
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();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
using var storage = new SharedRef<IStorage>();
|
using var storage = new SharedRef<IStorage>();
|
||||||
|
|
|
@ -42,9 +42,9 @@ file class SaveDataOpenCountAdapter : IEntryOpenCountSemaphoreManager
|
||||||
{
|
{
|
||||||
private SharedRef<SaveDataFileSystemService> _saveService;
|
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()
|
public void Dispose()
|
||||||
|
@ -1752,14 +1752,12 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
// Add all the wrappers for the file system
|
// Add all the wrappers for the file system
|
||||||
using var typeSetFileSystem =
|
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(in fileSystem, storageFlag));
|
||||||
new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(ref fileSystem.Ref, storageFlag));
|
|
||||||
|
|
||||||
using var asyncFileSystem = new SharedRef<IFileSystem>();
|
using var asyncFileSystem = new SharedRef<IFileSystem>();
|
||||||
|
|
||||||
if (useAsyncFileSystem)
|
if (useAsyncFileSystem)
|
||||||
{
|
{
|
||||||
asyncFileSystem.Reset(new AsynchronousAccessFileSystem(ref typeSetFileSystem.Ref));
|
asyncFileSystem.Reset(new AsynchronousAccessFileSystem(in typeSetFileSystem));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1768,17 +1766,17 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
|
||||||
|
|
||||||
using SharedRef<SaveDataFileSystemService> saveService = GetSharedFromThis();
|
using SharedRef<SaveDataFileSystemService> saveService = GetSharedFromThis();
|
||||||
using var openEntryCountAdapter =
|
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,
|
using var openCountFileSystem = new SharedRef<IFileSystem>(new OpenCountFileSystem(in asyncFileSystem,
|
||||||
ref openEntryCountAdapter.Ref, ref mountCountSemaphore.Ref));
|
in openEntryCountAdapter, ref mountCountSemaphore.Ref));
|
||||||
|
|
||||||
PathFlags pathFlags = FileSystemInterfaceAdapter.GetDefaultPathFlags();
|
PathFlags pathFlags = FileSystemInterfaceAdapter.GetDefaultPathFlags();
|
||||||
pathFlags.AllowBackslash();
|
pathFlags.AllowBackslash();
|
||||||
pathFlags.AllowInvalidCharacter();
|
pathFlags.AllowInvalidCharacter();
|
||||||
|
|
||||||
using SharedRef<IFileSystemSf> fileSystemAdapter =
|
using SharedRef<IFileSystemSf> fileSystemAdapter =
|
||||||
FileSystemInterfaceAdapter.CreateShared(ref openCountFileSystem.Ref, pathFlags, false);
|
FileSystemInterfaceAdapter.CreateShared(in openCountFileSystem, pathFlags, allowAllOperations: false);
|
||||||
|
|
||||||
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
|
@ -1879,14 +1877,12 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
// Add all the wrappers for the file system
|
// Add all the wrappers for the file system
|
||||||
using var typeSetFileSystem =
|
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(in fileSystem, storageFlag));
|
||||||
new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(ref fileSystem.Ref, storageFlag));
|
|
||||||
|
|
||||||
using var asyncFileSystem = new SharedRef<IFileSystem>();
|
using var asyncFileSystem = new SharedRef<IFileSystem>();
|
||||||
|
|
||||||
if (useAsyncFileSystem)
|
if (useAsyncFileSystem)
|
||||||
{
|
{
|
||||||
asyncFileSystem.Reset(new AsynchronousAccessFileSystem(ref typeSetFileSystem.Ref));
|
asyncFileSystem.Reset(new AsynchronousAccessFileSystem(in typeSetFileSystem));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1895,17 +1891,17 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
|
||||||
|
|
||||||
using SharedRef<SaveDataFileSystemService> saveService = GetSharedFromThis();
|
using SharedRef<SaveDataFileSystemService> saveService = GetSharedFromThis();
|
||||||
using var openEntryCountAdapter =
|
using var openEntryCountAdapter =
|
||||||
new SharedRef<IEntryOpenCountSemaphoreManager>(new SaveDataOpenCountAdapter(ref saveService.Ref));
|
new SharedRef<IEntryOpenCountSemaphoreManager>(new SaveDataOpenCountAdapter(in saveService));
|
||||||
|
|
||||||
using var openCountFileSystem = new SharedRef<IFileSystem>(
|
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 pathFlags = FileSystemInterfaceAdapter.GetDefaultPathFlags();
|
||||||
pathFlags.AllowBackslash();
|
pathFlags.AllowBackslash();
|
||||||
pathFlags.AllowInvalidCharacter();
|
pathFlags.AllowInvalidCharacter();
|
||||||
|
|
||||||
using SharedRef<IFileSystemSf> fileSystemAdapter =
|
using SharedRef<IFileSystemSf> fileSystemAdapter =
|
||||||
FileSystemInterfaceAdapter.CreateShared(ref openCountFileSystem.Ref, pathFlags, allowAllOperations: false);
|
FileSystemInterfaceAdapter.CreateShared(in openCountFileSystem, pathFlags, allowAllOperations: false);
|
||||||
|
|
||||||
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
|
@ -2257,14 +2253,13 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
using var reader = new SharedRef<SaveDataInfoReaderImpl>();
|
using var reader = new SharedRef<SaveDataInfoReaderImpl>();
|
||||||
|
|
||||||
res = accessor.Get.GetInterface().OpenSaveDataInfoReader(ref reader.Ref);
|
res = accessor.Get.GetInterface().OpenSaveDataInfoReader(ref reader.Ref);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
var filter = new SaveDataInfoFilter(ConvertToRealSpaceId(spaceId), programId: default,
|
var filter = new SaveDataInfoFilter(ConvertToRealSpaceId(spaceId), programId: default,
|
||||||
saveDataType: default, userId: default, saveDataId: default, index: default, (int)SaveDataRank.Primary);
|
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);
|
outInfoReader.Set(ref filterReader.Ref);
|
||||||
|
@ -2300,7 +2295,7 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
|
||||||
|
|
||||||
var infoFilter = new SaveDataInfoFilter(ConvertToRealSpaceId(spaceId), in filter);
|
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);
|
outInfoReader.Set(ref filterReader.Ref);
|
||||||
|
@ -2323,7 +2318,7 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
using var filterReader =
|
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();
|
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);
|
in saveDataRootPath, isTemporaryTransferSave, isReconstructible);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
using var typeSetFileSystem =
|
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(in fileSystem, storageFlag));
|
||||||
new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(ref fileSystem.Ref, storageFlag));
|
|
||||||
|
|
||||||
outFileSystem.SetByMove(ref typeSetFileSystem.Ref);
|
outFileSystem.SetByMove(ref typeSetFileSystem.Ref);
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
@ -2476,17 +2469,17 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
// Add all the wrappers for the file system
|
// 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 SharedRef<SaveDataFileSystemService> saveService = GetSharedFromThis();
|
||||||
using var openEntryCountAdapter =
|
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,
|
using var openCountFileSystem = new SharedRef<IFileSystem>(new OpenCountFileSystem(in asyncFileSystem,
|
||||||
ref openEntryCountAdapter.Ref, ref mountCountSemaphore.Ref));
|
in openEntryCountAdapter, ref mountCountSemaphore.Ref));
|
||||||
|
|
||||||
using SharedRef<IFileSystemSf> fileSystemAdapter =
|
using SharedRef<IFileSystemSf> fileSystemAdapter =
|
||||||
FileSystemInterfaceAdapter.CreateShared(ref openCountFileSystem.Ref, allowAllOperations: false);
|
FileSystemInterfaceAdapter.CreateShared(in openCountFileSystem, allowAllOperations: false);
|
||||||
|
|
||||||
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
outFileSystem.SetByMove(ref fileSystemAdapter.Ref);
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
|
@ -2599,7 +2592,7 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
|
||||||
var filter = new SaveDataInfoFilter(ConvertToRealSpaceId(spaceId), resolvedProgramId, SaveDataType.Cache,
|
var filter = new SaveDataInfoFilter(ConvertToRealSpaceId(spaceId), resolvedProgramId, SaveDataType.Cache,
|
||||||
userId: default, saveDataId: default, index: default, (int)SaveDataRank.Primary);
|
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);
|
outInfoReader.Set(ref filterReader.Ref);
|
||||||
|
@ -2617,8 +2610,7 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
|
||||||
Result res = _serviceImpl.OpenSaveDataMetaDirectoryFileSystem(ref fileSystem.Ref, spaceId, saveDataId);
|
Result res = _serviceImpl.OpenSaveDataMetaDirectoryFileSystem(ref fileSystem.Ref, spaceId, saveDataId);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
using var typeSetFileSystem =
|
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(in fileSystem, storageFlag));
|
||||||
new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(ref fileSystem.Ref, storageFlag));
|
|
||||||
|
|
||||||
Unsafe.SkipInit(out Array15<byte> pathMetaBuffer);
|
Unsafe.SkipInit(out Array15<byte> pathMetaBuffer);
|
||||||
|
|
||||||
|
@ -2681,13 +2673,9 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
|
||||||
res = _serviceImpl.OpenSaveDataMetaDirectoryFileSystem(ref tmpFileSystem.Ref, spaceId, targetSaveDataId);
|
res = _serviceImpl.OpenSaveDataMetaDirectoryFileSystem(ref tmpFileSystem.Ref, spaceId, targetSaveDataId);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
using var typeSetFileSystem =
|
using var typeSetFileSystem = new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(in tmpFileSystem, storageFlag));
|
||||||
new SharedRef<IFileSystem>(new StorageLayoutTypeSetFileSystem(ref tmpFileSystem.Ref, storageFlag));
|
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(in typeSetFileSystem));
|
||||||
|
using SharedRef<IFileSystemSf> fileSystem = FileSystemInterfaceAdapter.CreateShared(in asyncFileSystem, allowAllOperations: false);
|
||||||
using var asyncFileSystem = new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(ref typeSetFileSystem.Ref));
|
|
||||||
|
|
||||||
using SharedRef<IFileSystemSf> fileSystem =
|
|
||||||
FileSystemInterfaceAdapter.CreateShared(ref asyncFileSystem.Ref, allowAllOperations: false);
|
|
||||||
|
|
||||||
Unsafe.SkipInit(out Sf.Path sfPath);
|
Unsafe.SkipInit(out Sf.Path sfPath);
|
||||||
var sb = new U8StringBuilder(SpanHelpers.AsByteSpan(ref sfPath));
|
var sb = new U8StringBuilder(SpanHelpers.AsByteSpan(ref sfPath));
|
||||||
|
@ -2847,8 +2835,7 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
|
||||||
|
|
||||||
using SharedRef<ISaveDataTransferCoreInterface> transferInterface = GetSaveDataTransferCoreInterfaceFromThis();
|
using SharedRef<ISaveDataTransferCoreInterface> transferInterface = GetSaveDataTransferCoreInterfaceFromThis();
|
||||||
using var manager = new SharedRef<ISaveDataTransferManager>(
|
using var manager = new SharedRef<ISaveDataTransferManager>(
|
||||||
new SaveDataTransferManager(_serviceImpl.GetSaveDataTransferCryptoConfiguration(),
|
new SaveDataTransferManager(_serviceImpl.GetSaveDataTransferCryptoConfiguration(), in transferInterface));
|
||||||
in transferInterface.Ref));
|
|
||||||
|
|
||||||
if (!manager.HasValue)
|
if (!manager.HasValue)
|
||||||
return ResultFs.AllocationMemoryFailedInFileSystemProxyImplA.Log();
|
return ResultFs.AllocationMemoryFailedInFileSystemProxyImplA.Log();
|
||||||
|
@ -2896,7 +2883,7 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
|
||||||
using SharedRef<ISaveDataTransferCoreInterface> transferInterface = GetSaveDataTransferCoreInterfaceFromThis();
|
using SharedRef<ISaveDataTransferCoreInterface> transferInterface = GetSaveDataTransferCoreInterfaceFromThis();
|
||||||
using var manager = new SharedRef<ISaveDataTransferManagerForSaveDataRepair>(
|
using var manager = new SharedRef<ISaveDataTransferManagerForSaveDataRepair>(
|
||||||
new SaveDataTransferManagerForSaveDataRepair<SaveDataTransferManagerForSaveDataRepairPolicyV0>(
|
new SaveDataTransferManagerForSaveDataRepair<SaveDataTransferManagerForSaveDataRepairPolicyV0>(
|
||||||
_serviceImpl.GetSaveDataTransferCryptoConfiguration(), in transferInterface.Ref,
|
_serviceImpl.GetSaveDataTransferCryptoConfiguration(), in transferInterface,
|
||||||
_serviceImpl.GetSaveDataPorterManager(), isOpenPorterWithKeyEnabled));
|
_serviceImpl.GetSaveDataPorterManager(), isOpenPorterWithKeyEnabled));
|
||||||
|
|
||||||
if (!manager.HasValue)
|
if (!manager.HasValue)
|
||||||
|
@ -2919,7 +2906,7 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
|
||||||
using SharedRef<ISaveDataTransferCoreInterface> transferInterface = GetSaveDataTransferCoreInterfaceFromThis();
|
using SharedRef<ISaveDataTransferCoreInterface> transferInterface = GetSaveDataTransferCoreInterfaceFromThis();
|
||||||
using var manager = new SharedRef<ISaveDataTransferManagerForRepair>(
|
using var manager = new SharedRef<ISaveDataTransferManagerForRepair>(
|
||||||
new Impl.SaveDataTransferManagerForRepair(_serviceImpl.GetSaveDataTransferCryptoConfiguration(),
|
new Impl.SaveDataTransferManagerForRepair(_serviceImpl.GetSaveDataTransferCryptoConfiguration(),
|
||||||
in transferInterface.Ref, _serviceImpl.GetSaveDataPorterManager()));
|
in transferInterface, _serviceImpl.GetSaveDataPorterManager()));
|
||||||
|
|
||||||
if (!manager.HasValue)
|
if (!manager.HasValue)
|
||||||
return ResultFs.AllocationMemoryFailedInFileSystemProxyImplA.Log();
|
return ResultFs.AllocationMemoryFailedInFileSystemProxyImplA.Log();
|
||||||
|
@ -3318,7 +3305,7 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
|
||||||
{
|
{
|
||||||
using SharedRef<ISaveDataMultiCommitCoreInterface> commitInterface = GetSharedMultiCommitInterfaceFromThis();
|
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;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -299,7 +299,7 @@ public class SaveDataFileSystemServiceImpl : IDisposable
|
||||||
bool openShared = SaveDataProperties.IsSharedOpenNeeded(type);
|
bool openShared = SaveDataProperties.IsSharedOpenNeeded(type);
|
||||||
bool isReconstructible = SaveDataProperties.IsReconstructible(type, spaceId);
|
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,
|
isEmulatedOnHost, isDeviceUniqueMac, isJournalingSupported, isMultiCommitSupported,
|
||||||
openReadOnly, openShared, _timeStampGetter, isReconstructible);
|
openReadOnly, openShared, _timeStampGetter, isReconstructible);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
@ -316,7 +316,7 @@ public class SaveDataFileSystemServiceImpl : IDisposable
|
||||||
}
|
}
|
||||||
|
|
||||||
using var registerFs = new SharedRef<SaveDataFileSystemCacheRegister>(
|
using var registerFs = new SharedRef<SaveDataFileSystemCacheRegister>(
|
||||||
new SaveDataFileSystemCacheRegister(ref saveDataFs.Ref, _saveFileSystemCacheManager, spaceId, saveDataId));
|
new SaveDataFileSystemCacheRegister(in saveDataFs, _saveFileSystemCacheManager, spaceId, saveDataId));
|
||||||
|
|
||||||
if (openReadOnly)
|
if (openReadOnly)
|
||||||
{
|
{
|
||||||
|
@ -1148,7 +1148,7 @@ public class SaveDataFileSystemServiceImpl : IDisposable
|
||||||
caseSensitive: true);
|
caseSensitive: true);
|
||||||
if (res.IsFailure()) return res.Miss();
|
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);
|
createIfMissing);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
|
@ -1162,8 +1162,7 @@ public class SaveDataFileSystemServiceImpl : IDisposable
|
||||||
caseSensitive: true);
|
caseSensitive: true);
|
||||||
if (res.IsFailure()) return res.Miss();
|
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);
|
||||||
createIfMissing);
|
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -1189,7 +1188,7 @@ public class SaveDataFileSystemServiceImpl : IDisposable
|
||||||
|
|
||||||
using SharedRef<IFileSystem> tempFileSystem = SharedRef<IFileSystem>.CreateMove(ref baseFileSystem.Ref);
|
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();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
res = _config.EncryptedFsCreator.Create(ref outFileSystem, in baseFileSystem,
|
res = _config.EncryptedFsCreator.Create(ref outFileSystem, in baseFileSystem,
|
||||||
|
@ -1205,8 +1204,7 @@ public class SaveDataFileSystemServiceImpl : IDisposable
|
||||||
BisPartitionId.SystemProperPartition, caseSensitive: true);
|
BisPartitionId.SystemProperPartition, caseSensitive: true);
|
||||||
if (res.IsFailure()) return res.Miss();
|
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);
|
||||||
createIfMissing);
|
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -1218,8 +1216,7 @@ public class SaveDataFileSystemServiceImpl : IDisposable
|
||||||
caseSensitive: true);
|
caseSensitive: true);
|
||||||
if (res.IsFailure()) return res.Miss();
|
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);
|
||||||
createIfMissing);
|
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Buffers.Binary;
|
using System.Buffers.Binary;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using LibHac.Common;
|
using LibHac.Common;
|
||||||
using LibHac.Common.FixedArrays;
|
using LibHac.Common.FixedArrays;
|
||||||
using LibHac.Diag;
|
using LibHac.Diag;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using LibHac.Common;
|
using LibHac.Common;
|
||||||
using LibHac.Fs;
|
using LibHac.Fs;
|
||||||
using LibHac.Os;
|
using LibHac.Os;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using LibHac.Common;
|
using LibHac.Common;
|
||||||
using LibHac.Fs;
|
using LibHac.Fs;
|
||||||
using LibHac.Ncm;
|
using LibHac.Ncm;
|
||||||
|
|
|
@ -366,24 +366,21 @@ public class SaveDataFileStorageHolder
|
||||||
res = baseFileStorage.Get.Initialize(in baseFileSystem, in saveImageName, mode, type.ValueRo);
|
res = baseFileStorage.Get.Initialize(in baseFileSystem, in saveImageName, mode, type.ValueRo);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
using SharedRef<SaveDataOpenTypeSetFileStorage> baseFileStorageCopy =
|
res = Register(in baseFileStorage, spaceId, saveDataId);
|
||||||
SharedRef<SaveDataOpenTypeSetFileStorage>.CreateCopy(in baseFileStorage);
|
|
||||||
|
|
||||||
res = Register(ref baseFileStorageCopy.Ref, spaceId, saveDataId);
|
|
||||||
if (res.IsFailure()) return res.Miss();
|
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;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result Register(ref SharedRef<SaveDataOpenTypeSetFileStorage> storage, SaveDataSpaceId spaceId,
|
public Result Register(ref readonly SharedRef<SaveDataOpenTypeSetFileStorage> storage, SaveDataSpaceId spaceId,
|
||||||
ulong saveDataId)
|
ulong saveDataId)
|
||||||
{
|
{
|
||||||
Assert.SdkRequires(Globals.Mutex.IsLockedByCurrentThread());
|
Assert.SdkRequires(Globals.Mutex.IsLockedByCurrentThread());
|
||||||
|
|
||||||
_entryList.AddLast(new Entry(ref storage, spaceId, saveDataId));
|
_entryList.AddLast(new Entry(in storage, spaceId, saveDataId));
|
||||||
|
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,7 +137,7 @@ internal static class GameCardService
|
||||||
using var storage = new SharedRef<IStorage>(new StorageServiceObjectAdapter(ref gameCardStorageDevice.Ref));
|
using var storage = new SharedRef<IStorage>(new StorageServiceObjectAdapter(ref gameCardStorageDevice.Ref));
|
||||||
|
|
||||||
using var deviceEventSimulationStorage = new SharedRef<DeviceEventSimulationStorage>(
|
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);
|
outStorage.SetByMove(ref deviceEventSimulationStorage.Ref);
|
||||||
|
|
||||||
|
|
|
@ -105,12 +105,12 @@ internal static class MmcService
|
||||||
res = storageDeviceManager.Get.OpenStorage(ref mmcStorage.Ref, attribute);
|
res = storageDeviceManager.Get.OpenStorage(ref mmcStorage.Ref, attribute);
|
||||||
if (res.IsFailure()) return res.Miss();
|
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))
|
if (IsSpeedEmulationNeeded(partition))
|
||||||
{
|
{
|
||||||
using var emulationStorage =
|
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);
|
outStorage.SetByMove(ref emulationStorage.Ref);
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
|
|
|
@ -62,14 +62,14 @@ internal static class SdCardService
|
||||||
res = storageDeviceManager.Get.OpenStorage(ref sdCardStorage.Ref, 0);
|
res = storageDeviceManager.Get.OpenStorage(ref sdCardStorage.Ref, 0);
|
||||||
if (res.IsFailure()) return res.Miss();
|
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();
|
SdCardEventSimulator eventSimulator = service.FsSrv.Impl.GetSdCardEventSimulator();
|
||||||
using var deviceEventSimulationStorage =
|
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>(
|
using var emulationStorage = new SharedRef<IStorage>(
|
||||||
new SpeedEmulationStorage(ref deviceEventSimulationStorage.Ref, service.FsSrv));
|
new SpeedEmulationStorage(in deviceEventSimulationStorage, service.FsSrv));
|
||||||
|
|
||||||
outStorage.SetByMove(ref emulationStorage.Ref);
|
outStorage.SetByMove(ref emulationStorage.Ref);
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using LibHac.Fs;
|
using LibHac.Fs;
|
||||||
using LibHac.Spl;
|
|
||||||
|
|
||||||
namespace LibHac.FsSystem;
|
namespace LibHac.FsSystem;
|
||||||
|
|
||||||
|
|
|
@ -51,9 +51,9 @@ internal class StorageLayoutTypeSetStorage : IStorage
|
||||||
private SharedRef<IStorage> _baseStorage;
|
private SharedRef<IStorage> _baseStorage;
|
||||||
private StorageLayoutType _storageFlag;
|
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;
|
_storageFlag = storageFlag;
|
||||||
|
|
||||||
Assert.SdkAssert(StorageLayoutTypeFunctions.IsStorageFlagValid(storageFlag));
|
Assert.SdkAssert(StorageLayoutTypeFunctions.IsStorageFlagValid(storageFlag));
|
||||||
|
|
|
@ -27,9 +27,9 @@ internal class GameCardDeviceOperator : IStorageDeviceOperator
|
||||||
return (uint)((ulong)byteCount / GcPageSize);
|
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;
|
_gc = gc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -559,14 +559,14 @@ public class GameCardManager : IStorageDeviceManager, IStorageDeviceOperator, IG
|
||||||
{
|
{
|
||||||
using SharedRef<IGameCardManager> manager = SharedRef<IGameCardManager>.Create(in _selfReference);
|
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()
|
private WriteOnlyGameCardStorage MakeWriteOnlyGameCardStorage()
|
||||||
{
|
{
|
||||||
using SharedRef<IGameCardManager> manager = SharedRef<IGameCardManager>.Create(in _selfReference);
|
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,
|
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<IGameCardManager> manager = SharedRef<IGameCardManager>.Create(in _selfReference);
|
||||||
|
|
||||||
using SharedRef<GameCardStorageDevice> storageDevice =
|
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);
|
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<IGameCardManager> manager = SharedRef<IGameCardManager>.Create(in _selfReference);
|
||||||
|
|
||||||
using SharedRef<GameCardStorageDevice> storageDevice = GameCardStorageDevice.CreateShared(
|
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);
|
return SharedRef<IStorageDevice>.CreateMove(ref storageDevice.Ref);
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,7 +145,7 @@ internal class GameCardStorageDevice : GameCardStorageInterfaceAdapter, IStorage
|
||||||
SharedRef<GameCardStorageDevice>.Create(in _selfReference);
|
SharedRef<GameCardStorageDevice>.Create(in _selfReference);
|
||||||
|
|
||||||
using var deviceOperator =
|
using var deviceOperator =
|
||||||
new SharedRef<GameCardDeviceOperator>(new GameCardDeviceOperator(ref storageDevice.Ref, _gc));
|
new SharedRef<GameCardDeviceOperator>(new GameCardDeviceOperator(in storageDevice, _gc));
|
||||||
|
|
||||||
if (!deviceOperator.HasValue)
|
if (!deviceOperator.HasValue)
|
||||||
return ResultFs.AllocationMemoryFailedInGameCardManagerG.Log();
|
return ResultFs.AllocationMemoryFailedInGameCardManagerG.Log();
|
||||||
|
|
|
@ -211,7 +211,7 @@ internal class MmcManager : IStorageDeviceManager, IStorageDeviceOperator, ISdmm
|
||||||
using SharedRef<ISdmmcDeviceManager> manager = SharedRef<ISdmmcDeviceManager>.Create(in _selfReference);
|
using SharedRef<ISdmmcDeviceManager> manager = SharedRef<ISdmmcDeviceManager>.Create(in _selfReference);
|
||||||
|
|
||||||
using SharedRef<MmcUserDataPartitionStorageDevice> storageDevice =
|
using SharedRef<MmcUserDataPartitionStorageDevice> storageDevice =
|
||||||
MmcUserDataPartitionStorageDevice.CreateShared(ref manager.Ref, MmcHandle, _sdmmc);
|
MmcUserDataPartitionStorageDevice.CreateShared(in manager, MmcHandle, _sdmmc);
|
||||||
|
|
||||||
outStorageDevice.SetByMove(ref storageDevice.Ref);
|
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<ISdmmcDeviceManager> manager = SharedRef<ISdmmcDeviceManager>.Create(in _selfReference);
|
||||||
|
|
||||||
using SharedRef<MmcBootPartitionStorageDevice> storageDevice =
|
using SharedRef<MmcBootPartitionStorageDevice> storageDevice =
|
||||||
MmcBootPartitionStorageDevice.CreateShared(partition, ref manager.Ref, MmcHandle, _sdmmc);
|
MmcBootPartitionStorageDevice.CreateShared(partition, in manager, MmcHandle, _sdmmc);
|
||||||
|
|
||||||
outStorageDevice.SetByMove(ref storageDevice.Ref);
|
outStorageDevice.SetByMove(ref storageDevice.Ref);
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,8 +60,7 @@ internal abstract class MmcPartitionStorageDevice : IDisposable
|
||||||
using SharedRef<MmcPartitionStorageDevice> storageDevice =
|
using SharedRef<MmcPartitionStorageDevice> storageDevice =
|
||||||
SharedRef<MmcPartitionStorageDevice>.Create(in SelfReference);
|
SharedRef<MmcPartitionStorageDevice>.Create(in SelfReference);
|
||||||
|
|
||||||
using var deviceOperator =
|
using var deviceOperator = new SharedRef<MmcDeviceOperator>(new MmcDeviceOperator(in storageDevice, Sdmmc));
|
||||||
new SharedRef<MmcDeviceOperator>(new MmcDeviceOperator(ref storageDevice.Ref, Sdmmc));
|
|
||||||
|
|
||||||
if (!deviceOperator.HasValue)
|
if (!deviceOperator.HasValue)
|
||||||
return ResultFs.AllocationMemoryFailedInSdmmcStorageServiceA.Log();
|
return ResultFs.AllocationMemoryFailedInSdmmcStorageServiceA.Log();
|
||||||
|
|
|
@ -183,9 +183,7 @@ public class SdCardManager : IStorageDeviceManager, IStorageDeviceOperator, ISdm
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
using SharedRef<ISdmmcDeviceManager> manager = SharedRef<ISdmmcDeviceManager>.Create(in _selfReference);
|
using SharedRef<ISdmmcDeviceManager> manager = SharedRef<ISdmmcDeviceManager>.Create(in _selfReference);
|
||||||
|
using SharedRef<SdCardStorageDevice> storageDevice = SdCardStorageDevice.CreateShared(in manager, handle, _sdmmc);
|
||||||
using SharedRef<SdCardStorageDevice>
|
|
||||||
storageDevice = SdCardStorageDevice.CreateShared(ref manager.Ref, handle, _sdmmc);
|
|
||||||
|
|
||||||
if (!storageDevice.HasValue)
|
if (!storageDevice.HasValue)
|
||||||
return ResultFs.AllocationMemoryFailedInSdmmcStorageServiceA.Log();
|
return ResultFs.AllocationMemoryFailedInSdmmcStorageServiceA.Log();
|
||||||
|
|
|
@ -73,7 +73,7 @@ internal class SdCardStorageDevice : SdmmcStorageInterfaceAdapter, IStorageDevic
|
||||||
using SharedRef<SdCardStorageDevice> storageDevice = SharedRef<SdCardStorageDevice>.Create(in _selfReference);
|
using SharedRef<SdCardStorageDevice> storageDevice = SharedRef<SdCardStorageDevice>.Create(in _selfReference);
|
||||||
|
|
||||||
using var deviceOperator =
|
using var deviceOperator =
|
||||||
new SharedRef<SdCardDeviceOperator>(new SdCardDeviceOperator(ref storageDevice.Ref, _sdmmc));
|
new SharedRef<SdCardDeviceOperator>(new SdCardDeviceOperator(in storageDevice, _sdmmc));
|
||||||
|
|
||||||
if (!deviceOperator.HasValue)
|
if (!deviceOperator.HasValue)
|
||||||
return ResultFs.AllocationMemoryFailedInSdmmcStorageServiceA.Log();
|
return ResultFs.AllocationMemoryFailedInSdmmcStorageServiceA.Log();
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using LibHac.Fs;
|
using LibHac.Fs;
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class ReadOnlyBlockCacheStorageTests
|
||||||
}
|
}
|
||||||
|
|
||||||
using var baseStorage = new SharedRef<IStorage>(new MemoryStorage(BaseData));
|
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);
|
public Span<byte> GetBaseDataBlock(int index) => BaseData.AsSpan(_blockSize * index, _blockSize);
|
||||||
|
|
Loading…
Reference in a new issue