Move FsSystem/Save

This commit is contained in:
Alex Barney 2021-12-18 19:16:27 -07:00
parent fef8e16a85
commit 2d86d63fc6
27 changed files with 88 additions and 79 deletions

View file

@ -6,7 +6,7 @@ using LibHac.Diag;
using LibHac.Fs;
using LibHac.Fs.Fsa;
using LibHac.FsSystem;
using LibHac.FsSystem.Save;
using LibHac.Tools.FsSystem.Save;
using LibHac.Util;
using OpenType = LibHac.FsSrv.SaveDataOpenTypeSetFileStorage.OpenType;
@ -123,4 +123,4 @@ public class SaveDataFileSystemCreator : ISaveDataFileSystemCreator
{
throw new NotImplementedException();
}
}
}

View file

@ -10,7 +10,7 @@ using LibHac.Util;
using Buffer = LibHac.Mem.Buffer;
using CacheHandle = System.Int64;
namespace LibHac.FsSystem.Save;
namespace LibHac.FsSystem;
/// <summary>
/// An <see cref="IStorage"/> that provides buffered access to a base <see cref="IStorage"/>.
@ -21,7 +21,7 @@ public class BufferedStorage : IStorage
private const int InvalidIndex = -1;
/// <summary>
/// Caches a single block of data for a <see cref="Save.BufferedStorage"/>
/// Caches a single block of data for a <see cref="FsSystem.BufferedStorage"/>
/// </summary>
private struct Cache : IDisposable
{
@ -101,7 +101,7 @@ public class BufferedStorage : IStorage
}
/// <summary>
/// Decrements the ref-count and adds the <see cref="Cache"/> to its <see cref="Save.BufferedStorage"/>'s
/// Decrements the ref-count and adds the <see cref="Cache"/> to its <see cref="FsSystem.BufferedStorage"/>'s
/// fetch list if the <see cref="Cache"/> has no more references, and registering the buffer with
/// the <see cref="IBufferManager"/> if not dirty.
/// </summary>
@ -186,7 +186,7 @@ public class BufferedStorage : IStorage
/// <summary>
/// Increments the ref-count and removes the <see cref="Cache"/> from its
/// <see cref="Save.BufferedStorage"/>'s fetch list if needed.
/// <see cref="FsSystem.BufferedStorage"/>'s fetch list if needed.
/// </summary>
public void Unlink()
{
@ -557,7 +557,7 @@ public class BufferedStorage : IStorage
}
/// <summary>
/// Allows iteration over the <see cref="Save.BufferedStorage.Cache"/> in a <see cref="Save.BufferedStorage"/>.
/// Allows iteration over the <see cref="Cache"/> in a <see cref="FsSystem.BufferedStorage"/>.
/// Several options exist for which Caches to iterate.
/// </summary>
private ref struct SharedCache
@ -584,11 +584,11 @@ public class BufferedStorage : IStorage
}
/// <summary>
/// Moves to the next <see cref="Save.BufferedStorage.Cache"/> that contains data from the specified range.
/// Moves to the next <see cref="FsSystem.BufferedStorage.Cache"/> that contains data from the specified range.
/// </summary>
/// <param name="offset">The start offset of the range.</param>
/// <param name="size">The size of the range.</param>
/// <returns><see langword="true"/> if a <see cref="Save.BufferedStorage.Cache"/> from the
/// <returns><see langword="true"/> if a <see cref="FsSystem.BufferedStorage.Cache"/> from the
/// specified range was found. <see langword="false"/> if no matching Caches exist,
/// or if all matching Caches have already been iterated.</returns>
public bool AcquireNextOverlappedCache(long offset, long size)
@ -643,9 +643,9 @@ public class BufferedStorage : IStorage
}
/// <summary>
/// Moves to the next dirty <see cref="Save.BufferedStorage.Cache"/>.
/// Moves to the next dirty <see cref="FsSystem.BufferedStorage.Cache"/>.
/// </summary>
/// <returns><see langword="true"/> if a dirty <see cref="Save.BufferedStorage.Cache"/> was found.
/// <returns><see langword="true"/> if a dirty <see cref="FsSystem.BufferedStorage.Cache"/> was found.
/// <see langword="false"/> if no dirty Caches exist,
/// or if all dirty Caches have already been iterated.</returns>
public bool AcquireNextDirtyCache()
@ -686,9 +686,9 @@ public class BufferedStorage : IStorage
}
/// <summary>
/// Moves to the next valid <see cref="Save.BufferedStorage.Cache"/>.
/// Moves to the next valid <see cref="FsSystem.BufferedStorage.Cache"/>.
/// </summary>
/// <returns><see langword="true"/> if a valid <see cref="Save.BufferedStorage.Cache"/> was found.
/// <returns><see langword="true"/> if a valid <see cref="FsSystem.BufferedStorage.Cache"/> was found.
/// <see langword="false"/> if no valid Caches exist,
/// or if all valid Caches have already been iterated.</returns>
public bool AcquireNextValidCache()
@ -729,10 +729,10 @@ public class BufferedStorage : IStorage
}
/// <summary>
/// Moves to a <see cref="Save.BufferedStorage.Cache"/> that can be used for
/// Moves to a <see cref="FsSystem.BufferedStorage.Cache"/> that can be used for
/// fetching a new block from the base <see cref="IStorage"/>.
/// </summary>
/// <returns><see langword="true"/> if a <see cref="Save.BufferedStorage.Cache"/> was acquired.
/// <returns><see langword="true"/> if a <see cref="FsSystem.BufferedStorage.Cache"/> was acquired.
/// Otherwise, <see langword="false"/>.</returns>
public bool AcquireFetchableCache()
{
@ -758,9 +758,9 @@ public class BufferedStorage : IStorage
}
/// <summary>
/// Reads from the current <see cref="Save.BufferedStorage.Cache"/>'s buffer.
/// Reads from the current <see cref="FsSystem.BufferedStorage.Cache"/>'s buffer.
/// The provided <paramref name="offset"/> must be inside the block of
/// data held by the <see cref="Save.BufferedStorage.Cache"/>.
/// data held by the <see cref="FsSystem.BufferedStorage.Cache"/>.
/// </summary>
/// <param name="offset">The offset in the base <see cref="IStorage"/> to be read from.</param>
/// <param name="buffer">The buffer in which to place the read data.</param>
@ -772,8 +772,8 @@ public class BufferedStorage : IStorage
/// <summary>
/// Buffers data to be written to the base <see cref="IStorage"/> when the current
/// <see cref="Save.BufferedStorage.Cache"/> is flushed. The provided <paramref name="offset"/>
/// must be contained by the block of data held by the <see cref="Save.BufferedStorage.Cache"/>.
/// <see cref="FsSystem.BufferedStorage.Cache"/> is flushed. The provided <paramref name="offset"/>
/// must be contained by the block of data held by the <see cref="FsSystem.BufferedStorage.Cache"/>.
/// </summary>
/// <param name="offset">The offset in the base <see cref="IStorage"/> to be written to.</param>
/// <param name="buffer">The buffer containing the data to be written.</param>
@ -784,7 +784,7 @@ public class BufferedStorage : IStorage
}
/// <summary>
/// If the current <see cref="Save.BufferedStorage.Cache"/> is dirty,
/// If the current <see cref="FsSystem.BufferedStorage.Cache"/> is dirty,
/// flushes its data to the base <see cref="IStorage"/>.
/// </summary>
/// <returns>The <see cref="Result"/> of the operation.</returns>
@ -795,7 +795,7 @@ public class BufferedStorage : IStorage
}
/// <summary>
/// Invalidates the data in the current <see cref="Save.BufferedStorage.Cache"/>.
/// Invalidates the data in the current <see cref="FsSystem.BufferedStorage.Cache"/>.
/// Any dirty data will be discarded.
/// </summary>
public void Invalidate()
@ -805,11 +805,11 @@ public class BufferedStorage : IStorage
}
/// <summary>
/// Checks if the current <see cref="Save.BufferedStorage.Cache"/> covers any of the specified range.
/// Checks if the current <see cref="FsSystem.BufferedStorage.Cache"/> covers any of the specified range.
/// </summary>
/// <param name="offset">The start offset of the range to check.</param>
/// <param name="size">The size of the range to check.</param>
/// <returns><see langword="true"/> if the current <see cref="Save.BufferedStorage.Cache"/>'s range
/// <returns><see langword="true"/> if the current <see cref="FsSystem.BufferedStorage.Cache"/>'s range
/// covers any of the input range. Otherwise, <see langword="false"/>.</returns>
public bool Hits(long offset, long size)
{
@ -818,7 +818,7 @@ public class BufferedStorage : IStorage
}
/// <summary>
/// Releases the current <see cref="Save.BufferedStorage.Cache"/> to return to the fetch list.
/// Releases the current <see cref="FsSystem.BufferedStorage.Cache"/> to return to the fetch list.
/// </summary>
private void Release()
{
@ -839,8 +839,8 @@ public class BufferedStorage : IStorage
}
/// <summary>
/// Provides exclusive access to a <see cref="Save.BufferedStorage.Cache"/>
/// entry in a <see cref="Save.BufferedStorage"/>.
/// Provides exclusive access to a <see cref="Cache"/>
/// entry in a <see cref="FsSystem.BufferedStorage"/>.
/// </summary>
private ref struct UniqueCache
{
@ -856,7 +856,7 @@ public class BufferedStorage : IStorage
}
/// <summary>
/// Disposes the <see cref="UniqueCache"/>, releasing any held <see cref="Save.BufferedStorage.Cache"/>.
/// Disposes the <see cref="UniqueCache"/>, releasing any held <see cref="FsSystem.BufferedStorage.Cache"/>.
/// </summary>
public void Dispose()
{
@ -870,7 +870,7 @@ public class BufferedStorage : IStorage
}
/// <summary>
/// Attempts to gain exclusive access to the <see cref="Save.BufferedStorage.Cache"/> held by
/// Attempts to gain exclusive access to the <see cref="FsSystem.BufferedStorage.Cache"/> held by
/// <paramref name="sharedCache"/> and prepare it to read a new block from the base <see cref="IStorage"/>.
/// </summary>
/// <param name="sharedCache">The <see cref="SharedCache"/> to gain exclusive access to.</param>
@ -894,7 +894,7 @@ public class BufferedStorage : IStorage
/// <summary>
/// Reads the storage block containing the specified offset into the
/// <see cref="Save.BufferedStorage.Cache"/>'s buffer, and sets the Cache to that offset.
/// <see cref="FsSystem.BufferedStorage.Cache"/>'s buffer, and sets the Cache to that offset.
/// </summary>
/// <param name="offset">An offset in the block to fetch.</param>
/// <returns><see cref="Result.Success"/>: The operation was successful.<br/>
@ -907,7 +907,7 @@ public class BufferedStorage : IStorage
}
/// <summary>
/// Fills the <see cref="Save.BufferedStorage.Cache"/>'s buffer from an input buffer containing a block of data
/// Fills the <see cref="FsSystem.BufferedStorage.Cache"/>'s buffer from an input buffer containing a block of data
/// read from the base <see cref="IStorage"/>, and sets the Cache to that offset.
/// </summary>
/// <param name="offset">The start offset of the block in the base <see cref="IStorage"/>
@ -1709,4 +1709,4 @@ public class BufferedStorage : IStorage
return Result.Success;
}
}
}

View file

@ -3,7 +3,7 @@ using System.Buffers;
using System.IO;
using LibHac.Crypto;
using LibHac.Fs;
using LibHac.FsSystem.Save;
using LibHac.Tools.FsSystem.Save;
namespace LibHac.FsSystem;
@ -250,4 +250,4 @@ public enum IntegrityCheckLevel
/// An <see cref="InvalidDataException"/> will be thrown if an integrity check fails.
/// </summary>
ErrorOnInvalid
}
}

View file

@ -4,7 +4,7 @@ using LibHac.Common;
using LibHac.Diag;
using LibHac.Fs;
using LibHac.Fs.Fsa;
using LibHac.FsSystem.Save;
using LibHac.Tools.FsSystem.Save;
namespace LibHac.FsSystem;
@ -145,4 +145,4 @@ public class SaveDataFileSystemCacheRegisterBase<T> : IFileSystem where T : IFil
{
return _baseFileSystem.Get.GetTotalSpaceSize(out totalSpace, path);
}
}
}

View file

@ -9,9 +9,9 @@ using LibHac.Fs;
using LibHac.Fs.Fsa;
using LibHac.FsSystem;
using LibHac.FsSystem.NcaUtils;
using LibHac.FsSystem.Save;
using LibHac.Ncm;
using LibHac.Ns;
using LibHac.Tools.FsSystem.Save;
using LibHac.Tools.Ncm;
using LibHac.Util;

View file

@ -3,8 +3,9 @@ using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using LibHac.Fs;
using LibHac.FsSystem;
namespace LibHac.FsSystem.Save;
namespace LibHac.Tools.FsSystem.Save;
public class AllocationTable
{
@ -550,4 +551,4 @@ public class AllocationTableHeader
DirectoryTableBlock = reader.ReadInt32();
FileTableBlock = reader.ReadInt32();
}
}
}

View file

@ -1,6 +1,6 @@
using System;
namespace LibHac.FsSystem.Save;
namespace LibHac.Tools.FsSystem.Save;
public class AllocationTableIterator
{
@ -75,4 +75,4 @@ public class AllocationTableIterator
}
}
}
}
}

View file

@ -3,7 +3,7 @@ using System.IO;
using LibHac.Fs;
using LibHac.Util;
namespace LibHac.FsSystem.Save;
namespace LibHac.Tools.FsSystem.Save;
public class AllocationTableStorage : IStorage
{
@ -147,4 +147,4 @@ public class AllocationTableStorage : IStorage
return Result.Success;
}
}
}

View file

@ -2,8 +2,9 @@
using System.Collections;
using System.IO;
using LibHac.Fs;
using LibHac.FsSystem;
namespace LibHac.FsSystem.Save;
namespace LibHac.Tools.FsSystem.Save;
public class DuplexBitmap
{
@ -38,4 +39,4 @@ public class DuplexBitmap
}
}
}
}
}

View file

@ -1,7 +1,8 @@
using System;
using LibHac.Fs;
using LibHac.FsSystem;
namespace LibHac.FsSystem.Save;
namespace LibHac.Tools.FsSystem.Save;
public class DuplexStorage : IStorage
{
@ -123,4 +124,4 @@ public class DuplexStorage : IStorage
dataToClear.Slice(i * BlockSize, BlockSize).Fill(SaveDataFileSystem.TrimFillValue);
}
}
}
}

View file

@ -3,8 +3,9 @@ using System.IO;
using LibHac.Common.Keys;
using LibHac.Crypto;
using LibHac.Fs;
using LibHac.FsSystem;
namespace LibHac.FsSystem.Save;
namespace LibHac.Tools.FsSystem.Save;
public class Header
{
@ -284,4 +285,4 @@ public class ExtraData
return new Guid(b);
}
}
}

View file

@ -1,7 +1,7 @@
using System;
using LibHac.Fs;
namespace LibHac.FsSystem.Save;
namespace LibHac.Tools.FsSystem.Save;
public class HierarchicalDuplexStorage : IStorage
{
@ -74,4 +74,4 @@ public class DuplexFsLayerInfo
public IStorage DataA { get; set; }
public IStorage DataB { get; set; }
public DuplexInfo Info { get; set; }
}
}

View file

@ -3,9 +3,10 @@ using System.IO;
using System.Runtime.InteropServices;
using LibHac.Common;
using LibHac.Fs;
using LibHac.FsSystem;
using LibHac.Util;
namespace LibHac.FsSystem.Save;
namespace LibHac.Tools.FsSystem.Save;
public class HierarchicalSaveFileTable
{
@ -408,4 +409,4 @@ public class HierarchicalSaveFileTable
public int NextSibling;
public T Value;
}
}
}

View file

@ -1,8 +1,9 @@
using System.IO;
using LibHac.Fs;
using LibHac.FsSystem;
using LibHac.Util;
namespace LibHac.FsSystem.Save;
namespace LibHac.Tools.FsSystem.Save;
public class JournalMap
{
@ -99,4 +100,4 @@ public class JournalMapParams
public IStorage PhysicalBlockBitmap { get; set; }
public IStorage VirtualBlockBitmap { get; set; }
public IStorage FreeBlockBitmap { get; set; }
}
}

View file

@ -2,8 +2,9 @@
using System.Collections;
using System.IO;
using LibHac.Fs;
using LibHac.FsSystem;
namespace LibHac.FsSystem.Save;
namespace LibHac.Tools.FsSystem.Save;
public class JournalStorage : IStorage
{
@ -161,4 +162,4 @@ public class JournalMapEntry
{
public int PhysicalIndex { get; set; }
public int VirtualIndex { get; set; }
}
}

View file

@ -3,8 +3,9 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using LibHac.Fs;
using LibHac.FsSystem;
namespace LibHac.FsSystem.Save;
namespace LibHac.Tools.FsSystem.Save;
public class RemapStorage : IStorage
{
@ -270,4 +271,4 @@ public class RemapSegment
public List<MapEntry> Entries { get; } = new List<MapEntry>();
public long Offset { get; internal set; }
public long Length { get; internal set; }
}
}

View file

@ -4,7 +4,7 @@ using LibHac.Fs;
using LibHac.Fs.Fsa;
using LibHac.Util;
namespace LibHac.FsSystem.Save;
namespace LibHac.Tools.FsSystem.Save;
public class SaveDataDirectory : IDirectory
{
@ -85,4 +85,4 @@ public class SaveDataDirectory : IDirectory
return Result.Success;
}
}
}

View file

@ -4,7 +4,7 @@ using LibHac.Common;
using LibHac.Fs;
using LibHac.Fs.Fsa;
namespace LibHac.FsSystem.Save;
namespace LibHac.Tools.FsSystem.Save;
public class SaveDataFile : IFile
{
@ -104,4 +104,4 @@ public class SaveDataFile : IFile
{
return ResultFs.NotImplemented.Log();
}
}
}

View file

@ -5,9 +5,10 @@ using LibHac.Common.Keys;
using LibHac.Crypto;
using LibHac.Fs;
using LibHac.Fs.Fsa;
using LibHac.FsSystem;
using Path = LibHac.Fs.Path;
namespace LibHac.FsSystem.Save;
namespace LibHac.Tools.FsSystem.Save;
public class SaveDataFileSystem : IFileSystem
{
@ -331,4 +332,4 @@ public class SaveDataFileSystem : IFileSystem
base.Dispose();
}
}
}

View file

@ -2,10 +2,11 @@
using LibHac.Common;
using LibHac.Fs;
using LibHac.Fs.Fsa;
using LibHac.FsSystem;
using LibHac.Util;
using Path = LibHac.Fs.Path;
namespace LibHac.FsSystem.Save;
namespace LibHac.Tools.FsSystem.Save;
public class SaveDataFileSystemCore : IFileSystem
{
@ -283,4 +284,4 @@ public class SaveHeader
BlockCount = reader.ReadInt64();
BlockSize = reader.ReadInt64();
}
}
}

View file

@ -1,6 +1,6 @@
using System.Collections.Generic;
namespace LibHac.FsSystem.Save;
namespace LibHac.Tools.FsSystem.Save;
public static class SaveExtensions
{
@ -13,4 +13,4 @@ public static class SaveExtensions
yield return (iterator.PhysicalBlock, iterator.CurrentSegmentSize);
} while (iterator.MoveNext());
}
}
}

View file

@ -1,7 +1,7 @@
using System;
using System.Runtime.InteropServices;
namespace LibHac.FsSystem.Save;
namespace LibHac.Tools.FsSystem.Save;
internal ref struct SaveEntryKey
{
@ -33,4 +33,4 @@ public struct SaveFindPosition
public int NextDirectory;
/// <summary>The ID of the next file to be enumerated.</summary>
public int NextFile;
}
}

View file

@ -7,7 +7,7 @@ using LibHac.Common;
using LibHac.Fs;
using LibHac.Util;
namespace LibHac.FsSystem.Save;
namespace LibHac.Tools.FsSystem.Save;
// todo: Change constraint to "unmanaged" after updating to
// a newer SDK https://github.com/dotnet/csharplang/issues/1937
@ -376,4 +376,4 @@ internal class SaveFsList<T> where T : struct
[StructLayout(LayoutKind.Sequential, Size = 0x40)]
private struct NameDummy { }
}
}

View file

@ -1,6 +1,6 @@
using LibHac.Fs;
namespace LibHac.FsSystem.Save;
namespace LibHac.Tools.FsSystem.Save;
internal static class SaveResults
{
@ -125,4 +125,4 @@ internal static class SaveResults
return result;
}
}
}

View file

@ -10,7 +10,7 @@ using LibHac.Fs;
using LibHac.Fs.Fsa;
using LibHac.Fs.Impl;
using LibHac.FsSystem;
using LibHac.FsSystem.Save;
using LibHac.Tools.FsSystem.Save;
using static hactoolnet.Print;
using Path = System.IO.Path;
@ -353,4 +353,4 @@ internal static class ProcessSave
return sb.ToString();
}
}
}

View file

@ -9,9 +9,9 @@ using LibHac.Fs;
using LibHac.Fs.Fsa;
using LibHac.FsSystem;
using LibHac.FsSystem.NcaUtils;
using LibHac.FsSystem.Save;
using LibHac.Ns;
using LibHac.Tools.Fs;
using LibHac.Tools.FsSystem.Save;
using Path = System.IO.Path;
namespace hactoolnet;

View file

@ -2,7 +2,6 @@
using System.Collections.Generic;
using LibHac.Fs;
using LibHac.FsSystem;
using LibHac.FsSystem.Save;
using LibHac.Tests.Fs;
using Xunit;
@ -224,4 +223,4 @@ public class BufferedStorageTests
var tester = new StorageTester(testerConfig);
tester.Run(0x100);
}
}
}