mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Ensure more FS classes are updated for 13.1.0
- DeviceEventSimulationStorage - MultiCommitManager - DirectorySaveDataFileSystem - SubdirectoryFileSystem - FsSystem.Utility
This commit is contained in:
parent
795bcf0960
commit
37b8249a8b
5 changed files with 21 additions and 14 deletions
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using LibHac.Common;
|
||||
using LibHac.Diag;
|
||||
using LibHac.Fs;
|
||||
|
||||
namespace LibHac.FsSrv.Impl;
|
||||
|
@ -7,16 +8,16 @@ namespace LibHac.FsSrv.Impl;
|
|||
/// <summary>
|
||||
/// An <see cref="IStorage"/> for simulating device failures
|
||||
/// </summary>
|
||||
/// <remarks>Based on FS 12.1.0 (nnSdk 12.3.1)</remarks>
|
||||
/// <remarks>Based on FS 13.1.0 (nnSdk 13.4.0)</remarks>
|
||||
internal class DeviceEventSimulationStorage : IStorage
|
||||
{
|
||||
private SharedRef<IStorage> _baseStorage;
|
||||
private IDeviceEventSimulator _eventSimulator;
|
||||
private IDeviceEventSimulator _deviceEventSimulator;
|
||||
|
||||
public DeviceEventSimulationStorage(ref SharedRef<IStorage> baseStorage, IDeviceEventSimulator eventSimulator)
|
||||
public DeviceEventSimulationStorage(ref SharedRef<IStorage> baseStorage, IDeviceEventSimulator deviceEventSimulator)
|
||||
{
|
||||
_baseStorage = SharedRef<IStorage>.CreateMove(ref baseStorage);
|
||||
_eventSimulator = eventSimulator;
|
||||
_deviceEventSimulator = deviceEventSimulator;
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
|
@ -27,7 +28,9 @@ internal class DeviceEventSimulationStorage : IStorage
|
|||
|
||||
public override Result Read(long offset, Span<byte> destination)
|
||||
{
|
||||
Result rc = _eventSimulator.CheckSimulatedAccessFailureEvent(SimulatingDeviceTargetOperation.Read);
|
||||
Assert.SdkNotNull(_deviceEventSimulator);
|
||||
|
||||
Result rc = _deviceEventSimulator.CheckSimulatedAccessFailureEvent(SimulatingDeviceTargetOperation.Read);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
||||
return _baseStorage.Get.Read(offset, destination);
|
||||
|
@ -35,7 +38,9 @@ internal class DeviceEventSimulationStorage : IStorage
|
|||
|
||||
public override Result Write(long offset, ReadOnlySpan<byte> source)
|
||||
{
|
||||
Result rc = _eventSimulator.CheckSimulatedAccessFailureEvent(SimulatingDeviceTargetOperation.Write);
|
||||
Assert.SdkNotNull(_deviceEventSimulator);
|
||||
|
||||
Result rc = _deviceEventSimulator.CheckSimulatedAccessFailureEvent(SimulatingDeviceTargetOperation.Write);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
||||
return _baseStorage.Get.Write(offset, source);
|
||||
|
|
|
@ -20,7 +20,7 @@ internal struct MultiCommitManagerGlobals
|
|||
|
||||
public void Initialize()
|
||||
{
|
||||
MultiCommitMutex.Initialize();
|
||||
MultiCommitMutex = new SdkMutexType();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ internal struct MultiCommitManagerGlobals
|
|||
/// Save data image files are designed so that minimal changes are made when fully committing a provisionally committed save.
|
||||
/// However if any commit fails for any reason, all other saves in the multi-commit will still be committed.
|
||||
/// This can especially cause issues with directory save data where finishing a commit is much more involved.
|
||||
/// <para>Based on FS 12.1.0 (nnSdk 12.3.1)</para>
|
||||
/// <para>Based on FS 13.1.0 (nnSdk 13.4.0)</para>
|
||||
/// </remarks>
|
||||
internal class MultiCommitManager : IMultiCommitManager
|
||||
{
|
||||
|
@ -501,7 +501,9 @@ internal class MultiCommitManager : IMultiCommitManager
|
|||
{
|
||||
public int Version;
|
||||
public CommitState State;
|
||||
// ReSharper disable once NotAccessedField.Local
|
||||
public int FileSystemCount;
|
||||
// ReSharper disable once NotAccessedField.Local
|
||||
public long Counter;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ internal struct DirectorySaveDataFileSystemGlobals
|
|||
/// <remarks>
|
||||
/// Transactional commits should be atomic as long as the <see cref="IFileSystem.RenameDirectory"/> function of the
|
||||
/// underlying <see cref="IFileSystem"/> is atomic.
|
||||
/// <para>Based on FS 12.1.0 (nnSdk 12.3.1)</para>
|
||||
/// <para>Based on FS 13.1.0 (nnSdk 13.4.0)</para>
|
||||
/// </remarks>
|
||||
public class DirectorySaveDataFileSystem : IFileSystem, ISaveDataExtraDataAccessor
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace LibHac.FsSystem;
|
|||
/// <summary>
|
||||
/// An <see cref="IFileSystem"/> that uses a directory of another <see cref="IFileSystem"/> as its root directory.
|
||||
/// </summary>
|
||||
/// <remarks>Based on FS 12.1.0 (nnSdk 12.3.1)</remarks>
|
||||
/// <remarks>Based on FS 13.1.0 (nnSdk 13.4.0)</remarks>
|
||||
public class SubdirectoryFileSystem : IFileSystem
|
||||
{
|
||||
private IFileSystem _baseFileSystem;
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace LibHac.FsSystem;
|
|||
/// <summary>
|
||||
/// Various utility functions used by the <see cref="LibHac.FsSystem"/> namespace.
|
||||
/// </summary>
|
||||
/// <remarks>Based on FS 12.1.0 (nnSdk 12.3.1)</remarks>
|
||||
/// <remarks>Based on FS 13.1.0 (nnSdk 13.4.0)</remarks>
|
||||
internal static class Utility
|
||||
{
|
||||
public delegate Result FsIterationTask(in Path path, in DirectoryEntry entry, ref FsIterationTaskClosure closure);
|
||||
|
@ -172,7 +172,7 @@ internal static class Utility
|
|||
rc = destFileSystem.OpenFile(ref destFile.Ref(), in destPath, OpenMode.Write);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
||||
// Read/Write file in work buffer sized chunks.
|
||||
// Read/Write file in work-buffer-sized chunks.
|
||||
long remaining = fileSize;
|
||||
long offset = 0;
|
||||
|
||||
|
|
Loading…
Reference in a new issue