mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Use ref readonly
instead of in
for SharedRef parameters
This commit is contained in:
parent
dd2b9fe2ca
commit
e19ea92b90
8 changed files with 35 additions and 28 deletions
|
@ -62,9 +62,9 @@ public class DefaultFsServerObjects
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Result InitializeNcaReader(ref SharedRef<NcaReader> outReader, in SharedRef<IStorage> baseStorage,
|
public static Result InitializeNcaReader(ref SharedRef<NcaReader> outReader,
|
||||||
in NcaCompressionConfiguration compressionConfig, IHash256GeneratorFactorySelector hashGeneratorFactorySelector,
|
ref readonly SharedRef<IStorage> baseStorage, in NcaCompressionConfiguration compressionConfig,
|
||||||
ContentAttributes contentAttributes)
|
IHash256GeneratorFactorySelector hashGeneratorFactorySelector, ContentAttributes contentAttributes)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace LibHac.FsSrv.FsCreator;
|
||||||
|
|
||||||
public interface ISaveDataFileSystemCreator : IDisposable
|
public interface ISaveDataFileSystemCreator : IDisposable
|
||||||
{
|
{
|
||||||
Result CreateRaw(ref SharedRef<IFile> outFile, in SharedRef<IFileSystem> fileSystem, ulong saveDataId, OpenMode openMode);
|
Result CreateRaw(ref SharedRef<IFile> outFile, ref readonly SharedRef<IFileSystem> fileSystem, ulong saveDataId, OpenMode openMode);
|
||||||
|
|
||||||
Result Create(ref SharedRef<ISaveDataFileSystem> outFileSystem, ref SharedRef<IFileSystem> baseFileSystem,
|
Result Create(ref SharedRef<ISaveDataFileSystem> outFileSystem, ref SharedRef<IFileSystem> baseFileSystem,
|
||||||
SaveDataSpaceId spaceId, ulong saveDataId, bool allowDirectorySaveData, bool isDeviceUniqueMac,
|
SaveDataSpaceId spaceId, ulong saveDataId, bool allowDirectorySaveData, bool isDeviceUniqueMac,
|
||||||
|
@ -18,16 +18,18 @@ public interface ISaveDataFileSystemCreator : IDisposable
|
||||||
ISaveDataCommitTimeStampGetter timeStampGetter, bool isReconstructible);
|
ISaveDataCommitTimeStampGetter timeStampGetter, bool isReconstructible);
|
||||||
|
|
||||||
Result CreateExtraDataAccessor(ref SharedRef<ISaveDataExtraDataAccessor> outExtraDataAccessor,
|
Result CreateExtraDataAccessor(ref SharedRef<ISaveDataExtraDataAccessor> outExtraDataAccessor,
|
||||||
in SharedRef<IStorage> baseStorage, bool isDeviceUniqueMac, bool isIntegritySaveData, bool isReconstructible);
|
ref readonly SharedRef<IStorage> baseStorage, bool isDeviceUniqueMac, bool isIntegritySaveData,
|
||||||
|
bool isReconstructible);
|
||||||
|
|
||||||
Result CreateInternalStorage(ref SharedRef<IFileSystem> outFileSystem, in SharedRef<IFileSystem> baseFileSystem,
|
Result CreateInternalStorage(ref SharedRef<IFileSystem> outFileSystem,
|
||||||
SaveDataSpaceId spaceId, ulong saveDataId, bool isDeviceUniqueMac, bool useUniqueKey1,
|
ref readonly SharedRef<IFileSystem> baseFileSystem, SaveDataSpaceId spaceId, ulong saveDataId,
|
||||||
ISaveDataCommitTimeStampGetter timeStampGetter, bool isReconstructible);
|
bool isDeviceUniqueMac, bool useUniqueKey1, ISaveDataCommitTimeStampGetter timeStampGetter,
|
||||||
|
bool isReconstructible);
|
||||||
|
|
||||||
Result RecoverMasterHeader(in SharedRef<IFileSystem> baseFileSystem, ulong saveDataId, IBufferManager bufferManager,
|
Result RecoverMasterHeader(ref readonly SharedRef<IFileSystem> baseFileSystem, ulong saveDataId,
|
||||||
bool isDeviceUniqueMac, bool isReconstructible);
|
IBufferManager bufferManager, bool isDeviceUniqueMac, bool isReconstructible);
|
||||||
|
|
||||||
Result UpdateMac(in SharedRef<IFileSystem> baseFileSystem, ulong saveDataId, bool isDeviceUniqueMac,
|
Result UpdateMac(ref readonly SharedRef<IFileSystem> baseFileSystem, ulong saveDataId, bool isDeviceUniqueMac,
|
||||||
bool isReconstructible);
|
bool isReconstructible);
|
||||||
|
|
||||||
Result Format(in ValueSubStorage saveImageStorage, long blockSize, int countExpandMax, uint blockCount,
|
Result Format(in ValueSubStorage saveImageStorage, long blockSize, int countExpandMax, uint blockCount,
|
||||||
|
@ -47,7 +49,7 @@ public interface ISaveDataFileSystemCreator : IDisposable
|
||||||
void SetMacGenerationSeed(ReadOnlySpan<byte> seed);
|
void SetMacGenerationSeed(ReadOnlySpan<byte> seed);
|
||||||
|
|
||||||
Result IsProvisionallyCommittedSaveData(out bool outIsProvisionallyCommitted,
|
Result IsProvisionallyCommittedSaveData(out bool outIsProvisionallyCommitted,
|
||||||
in SharedRef<IFileSystem> baseFileSystem, in SaveDataInfo info, bool isDeviceUniqueMac,
|
ref readonly SharedRef<IFileSystem> baseFileSystem, in SaveDataInfo info, bool isDeviceUniqueMac,
|
||||||
ISaveDataCommitTimeStampGetter timeStampGetter, bool isReconstructible);
|
ISaveDataCommitTimeStampGetter timeStampGetter, bool isReconstructible);
|
||||||
|
|
||||||
IMacGenerator GetMacGenerator(bool isDeviceUniqueMac, bool isTemporaryTransferSave);
|
IMacGenerator GetMacGenerator(bool isDeviceUniqueMac, bool isTemporaryTransferSave);
|
||||||
|
|
|
@ -281,7 +281,8 @@ public class SaveDataFileSystemCreator : ISaveDataFileSystemCreator
|
||||||
seed.CopyTo(_macGenerationSeed.Value);
|
seed.CopyTo(_macGenerationSeed.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result CreateRaw(ref SharedRef<IFile> outFile, in SharedRef<IFileSystem> fileSystem, ulong saveDataId, OpenMode openMode)
|
public Result CreateRaw(ref SharedRef<IFile> outFile, ref readonly SharedRef<IFileSystem> fileSystem,
|
||||||
|
ulong saveDataId, OpenMode openMode)
|
||||||
{
|
{
|
||||||
Unsafe.SkipInit(out Array18<byte> saveImageNameBuffer);
|
Unsafe.SkipInit(out Array18<byte> saveImageNameBuffer);
|
||||||
|
|
||||||
|
@ -419,7 +420,8 @@ public class SaveDataFileSystemCreator : ISaveDataFileSystemCreator
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result CreateExtraDataAccessor(ref SharedRef<ISaveDataExtraDataAccessor> outExtraDataAccessor,
|
public Result CreateExtraDataAccessor(ref SharedRef<ISaveDataExtraDataAccessor> outExtraDataAccessor,
|
||||||
in SharedRef<IStorage> baseStorage, bool isDeviceUniqueMac, bool isIntegritySaveData, bool isReconstructible)
|
ref readonly SharedRef<IStorage> baseStorage, bool isDeviceUniqueMac, bool isIntegritySaveData,
|
||||||
|
bool isReconstructible)
|
||||||
{
|
{
|
||||||
using var saveDataFs = new SharedRef<ISaveDataFileSystem>();
|
using var saveDataFs = new SharedRef<ISaveDataFileSystem>();
|
||||||
|
|
||||||
|
@ -455,8 +457,9 @@ public class SaveDataFileSystemCreator : ISaveDataFileSystemCreator
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result CreateInternalStorage(ref SharedRef<IFileSystem> outFileSystem,
|
public Result CreateInternalStorage(ref SharedRef<IFileSystem> outFileSystem,
|
||||||
in SharedRef<IFileSystem> baseFileSystem, SaveDataSpaceId spaceId, ulong saveDataId, bool isDeviceUniqueMac,
|
ref readonly SharedRef<IFileSystem> baseFileSystem, SaveDataSpaceId spaceId, ulong saveDataId,
|
||||||
bool useUniqueKey1, ISaveDataCommitTimeStampGetter timeStampGetter, bool isReconstructible)
|
bool isDeviceUniqueMac, bool useUniqueKey1, ISaveDataCommitTimeStampGetter timeStampGetter,
|
||||||
|
bool isReconstructible)
|
||||||
{
|
{
|
||||||
Result res;
|
Result res;
|
||||||
Unsafe.SkipInit(out Array18<byte> saveImageNameBuffer);
|
Unsafe.SkipInit(out Array18<byte> saveImageNameBuffer);
|
||||||
|
@ -510,7 +513,7 @@ public class SaveDataFileSystemCreator : ISaveDataFileSystemCreator
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result RecoverMasterHeader(in SharedRef<IFileSystem> baseFileSystem, ulong saveDataId,
|
public Result RecoverMasterHeader(ref readonly SharedRef<IFileSystem> baseFileSystem, ulong saveDataId,
|
||||||
IBufferManager bufferManager, bool isDeviceUniqueMac, bool isReconstructible)
|
IBufferManager bufferManager, bool isDeviceUniqueMac, bool isReconstructible)
|
||||||
{
|
{
|
||||||
Unsafe.SkipInit(out Array18<byte> saveImageNameBuffer);
|
Unsafe.SkipInit(out Array18<byte> saveImageNameBuffer);
|
||||||
|
@ -554,8 +557,8 @@ public class SaveDataFileSystemCreator : ISaveDataFileSystemCreator
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result UpdateMac(in SharedRef<IFileSystem> baseFileSystem, ulong saveDataId, bool isDeviceUniqueMac,
|
public Result UpdateMac(ref readonly SharedRef<IFileSystem> baseFileSystem, ulong saveDataId,
|
||||||
bool isReconstructible)
|
bool isDeviceUniqueMac, bool isReconstructible)
|
||||||
{
|
{
|
||||||
Unsafe.SkipInit(out Array18<byte> saveImageNameBuffer);
|
Unsafe.SkipInit(out Array18<byte> saveImageNameBuffer);
|
||||||
|
|
||||||
|
@ -599,7 +602,7 @@ public class SaveDataFileSystemCreator : ISaveDataFileSystemCreator
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result IsProvisionallyCommittedSaveData(out bool outIsProvisionallyCommitted,
|
public Result IsProvisionallyCommittedSaveData(out bool outIsProvisionallyCommitted,
|
||||||
in SharedRef<IFileSystem> baseFileSystem, in SaveDataInfo info, bool isDeviceUniqueMac,
|
ref readonly SharedRef<IFileSystem> baseFileSystem, in SaveDataInfo info, bool isDeviceUniqueMac,
|
||||||
ISaveDataCommitTimeStampGetter timeStampGetter, bool isReconstructible)
|
ISaveDataCommitTimeStampGetter timeStampGetter, bool isReconstructible)
|
||||||
{
|
{
|
||||||
UnsafeHelpers.SkipParamInit(out outIsProvisionallyCommitted);
|
UnsafeHelpers.SkipParamInit(out outIsProvisionallyCommitted);
|
||||||
|
|
|
@ -38,8 +38,9 @@ public class SaveDataMover : ISaveDataMover
|
||||||
private State _state;
|
private State _state;
|
||||||
private SdkMutex _mutex;
|
private SdkMutex _mutex;
|
||||||
|
|
||||||
public SaveDataMover(in SharedRef<ISaveDataTransferCoreInterface> transferInterface, SaveDataSpaceId sourceSpaceId,
|
public SaveDataMover(ref readonly SharedRef<ISaveDataTransferCoreInterface> transferInterface,
|
||||||
SaveDataSpaceId destinationSpaceId, NativeHandle transferMemoryHandle, ulong transferMemorySize)
|
SaveDataSpaceId sourceSpaceId, SaveDataSpaceId destinationSpaceId, NativeHandle transferMemoryHandle,
|
||||||
|
ulong transferMemorySize)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,7 +150,7 @@ file static class Anonymous
|
||||||
|
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
|
|
||||||
static Result ReadData(in UniqueRef<IFile> file, ref CodeVerificationData outData)
|
static Result ReadData(ref readonly UniqueRef<IFile> file, ref CodeVerificationData outData)
|
||||||
{
|
{
|
||||||
Result res = file.Get.GetSize(out long verificationDataSize);
|
Result res = file.Get.GetSize(out long verificationDataSize);
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
|
@ -551,7 +551,8 @@ public class SaveDataFileSystemServiceImpl : IDisposable
|
||||||
using (var extraDataAccessor = new SharedRef<ISaveDataExtraDataAccessor>())
|
using (var extraDataAccessor = new SharedRef<ISaveDataExtraDataAccessor>())
|
||||||
{
|
{
|
||||||
res = _config.SaveFsCreator.CreateExtraDataAccessor(ref extraDataAccessor.Ref, in saveDataStorage,
|
res = _config.SaveFsCreator.CreateExtraDataAccessor(ref extraDataAccessor.Ref, in saveDataStorage,
|
||||||
IsDeviceUniqueMac(spaceId), isIntegritySaveData: true, SaveDataProperties.IsReconstructible(type, spaceId));
|
IsDeviceUniqueMac(spaceId), isIntegritySaveData: true,
|
||||||
|
isReconstructible: SaveDataProperties.IsReconstructible(type, spaceId));
|
||||||
if (res.IsFailure()) return res.Miss();
|
if (res.IsFailure()) return res.Miss();
|
||||||
|
|
||||||
res = extraDataAccessor.Get.ReadExtraData(out SaveDataExtraData extraData);
|
res = extraDataAccessor.Get.ReadExtraData(out SaveDataExtraData extraData);
|
||||||
|
|
|
@ -87,7 +87,7 @@ file class SharedNcaBodyStorage : IStorage
|
||||||
private SharedRef<IStorage> _storage;
|
private SharedRef<IStorage> _storage;
|
||||||
private SharedRef<NcaReader> _ncaReader;
|
private SharedRef<NcaReader> _ncaReader;
|
||||||
|
|
||||||
public SharedNcaBodyStorage(in SharedRef<IStorage> baseStorage, in SharedRef<NcaReader> ncaReader)
|
public SharedNcaBodyStorage(ref readonly SharedRef<IStorage> baseStorage, ref readonly SharedRef<NcaReader> ncaReader)
|
||||||
{
|
{
|
||||||
_storage = SharedRef<IStorage>.CreateCopy(in baseStorage);
|
_storage = SharedRef<IStorage>.CreateCopy(in baseStorage);
|
||||||
_ncaReader = SharedRef<NcaReader>.CreateCopy(in ncaReader);
|
_ncaReader = SharedRef<NcaReader>.CreateCopy(in ncaReader);
|
||||||
|
|
|
@ -8,9 +8,9 @@ using LibHac.Spl;
|
||||||
|
|
||||||
namespace LibHac.FsSystem;
|
namespace LibHac.FsSystem;
|
||||||
|
|
||||||
public delegate Result NcaReaderInitializer(ref SharedRef<NcaReader> outReader, in SharedRef<IStorage> baseStorage,
|
public delegate Result NcaReaderInitializer(ref SharedRef<NcaReader> outReader,
|
||||||
in NcaCompressionConfiguration compressionConfig, IHash256GeneratorFactorySelector hashGeneratorFactorySelector,
|
ref readonly SharedRef<IStorage> baseStorage, in NcaCompressionConfiguration compressionConfig,
|
||||||
ContentAttributes contentAttributes);
|
IHash256GeneratorFactorySelector hashGeneratorFactorySelector, ContentAttributes contentAttributes);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles reading information from an NCA's header.
|
/// Handles reading information from an NCA's header.
|
||||||
|
|
Loading…
Reference in a new issue