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;
using LibHac.Fs.Fsa; using LibHac.Fs.Fsa;
using LibHac.FsSystem; using LibHac.FsSystem;
using LibHac.FsSystem.Save; using LibHac.Tools.FsSystem.Save;
using LibHac.Util; using LibHac.Util;
using OpenType = LibHac.FsSrv.SaveDataOpenTypeSetFileStorage.OpenType; using OpenType = LibHac.FsSrv.SaveDataOpenTypeSetFileStorage.OpenType;

View file

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

View file

@ -3,7 +3,7 @@ using System.Buffers;
using System.IO; using System.IO;
using LibHac.Crypto; using LibHac.Crypto;
using LibHac.Fs; using LibHac.Fs;
using LibHac.FsSystem.Save; using LibHac.Tools.FsSystem.Save;
namespace LibHac.FsSystem; namespace LibHac.FsSystem;

View file

@ -4,7 +4,7 @@ using LibHac.Common;
using LibHac.Diag; using LibHac.Diag;
using LibHac.Fs; using LibHac.Fs;
using LibHac.Fs.Fsa; using LibHac.Fs.Fsa;
using LibHac.FsSystem.Save; using LibHac.Tools.FsSystem.Save;
namespace LibHac.FsSystem; namespace LibHac.FsSystem;

View file

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

View file

@ -3,8 +3,9 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using LibHac.Fs; using LibHac.Fs;
using LibHac.FsSystem;
namespace LibHac.FsSystem.Save; namespace LibHac.Tools.FsSystem.Save;
public class AllocationTable public class AllocationTable
{ {

View file

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

View file

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

View file

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

View file

@ -1,7 +1,8 @@
using System; using System;
using LibHac.Fs; using LibHac.Fs;
using LibHac.FsSystem;
namespace LibHac.FsSystem.Save; namespace LibHac.Tools.FsSystem.Save;
public class DuplexStorage : IStorage public class DuplexStorage : IStorage
{ {

View file

@ -3,8 +3,9 @@ using System.IO;
using LibHac.Common.Keys; using LibHac.Common.Keys;
using LibHac.Crypto; using LibHac.Crypto;
using LibHac.Fs; using LibHac.Fs;
using LibHac.FsSystem;
namespace LibHac.FsSystem.Save; namespace LibHac.Tools.FsSystem.Save;
public class Header public class Header
{ {

View file

@ -1,7 +1,7 @@
using System; using System;
using LibHac.Fs; using LibHac.Fs;
namespace LibHac.FsSystem.Save; namespace LibHac.Tools.FsSystem.Save;
public class HierarchicalDuplexStorage : IStorage public class HierarchicalDuplexStorage : IStorage
{ {

View file

@ -3,9 +3,10 @@ using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using LibHac.Common; using LibHac.Common;
using LibHac.Fs; using LibHac.Fs;
using LibHac.FsSystem;
using LibHac.Util; using LibHac.Util;
namespace LibHac.FsSystem.Save; namespace LibHac.Tools.FsSystem.Save;
public class HierarchicalSaveFileTable public class HierarchicalSaveFileTable
{ {

View file

@ -1,8 +1,9 @@
using System.IO; using System.IO;
using LibHac.Fs; using LibHac.Fs;
using LibHac.FsSystem;
using LibHac.Util; using LibHac.Util;
namespace LibHac.FsSystem.Save; namespace LibHac.Tools.FsSystem.Save;
public class JournalMap public class JournalMap
{ {

View file

@ -2,8 +2,9 @@
using System.Collections; using System.Collections;
using System.IO; using System.IO;
using LibHac.Fs; using LibHac.Fs;
using LibHac.FsSystem;
namespace LibHac.FsSystem.Save; namespace LibHac.Tools.FsSystem.Save;
public class JournalStorage : IStorage public class JournalStorage : IStorage
{ {

View file

@ -3,8 +3,9 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using LibHac.Fs; using LibHac.Fs;
using LibHac.FsSystem;
namespace LibHac.FsSystem.Save; namespace LibHac.Tools.FsSystem.Save;
public class RemapStorage : IStorage public class RemapStorage : IStorage
{ {

View file

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

View file

@ -4,7 +4,7 @@ using LibHac.Common;
using LibHac.Fs; using LibHac.Fs;
using LibHac.Fs.Fsa; using LibHac.Fs.Fsa;
namespace LibHac.FsSystem.Save; namespace LibHac.Tools.FsSystem.Save;
public class SaveDataFile : IFile public class SaveDataFile : IFile
{ {

View file

@ -5,9 +5,10 @@ using LibHac.Common.Keys;
using LibHac.Crypto; using LibHac.Crypto;
using LibHac.Fs; using LibHac.Fs;
using LibHac.Fs.Fsa; using LibHac.Fs.Fsa;
using LibHac.FsSystem;
using Path = LibHac.Fs.Path; using Path = LibHac.Fs.Path;
namespace LibHac.FsSystem.Save; namespace LibHac.Tools.FsSystem.Save;
public class SaveDataFileSystem : IFileSystem public class SaveDataFileSystem : IFileSystem
{ {

View file

@ -2,10 +2,11 @@
using LibHac.Common; using LibHac.Common;
using LibHac.Fs; using LibHac.Fs;
using LibHac.Fs.Fsa; using LibHac.Fs.Fsa;
using LibHac.FsSystem;
using LibHac.Util; using LibHac.Util;
using Path = LibHac.Fs.Path; using Path = LibHac.Fs.Path;
namespace LibHac.FsSystem.Save; namespace LibHac.Tools.FsSystem.Save;
public class SaveDataFileSystemCore : IFileSystem public class SaveDataFileSystemCore : IFileSystem
{ {

View file

@ -1,6 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace LibHac.FsSystem.Save; namespace LibHac.Tools.FsSystem.Save;
public static class SaveExtensions public static class SaveExtensions
{ {

View file

@ -1,7 +1,7 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace LibHac.FsSystem.Save; namespace LibHac.Tools.FsSystem.Save;
internal ref struct SaveEntryKey internal ref struct SaveEntryKey
{ {

View file

@ -7,7 +7,7 @@ using LibHac.Common;
using LibHac.Fs; using LibHac.Fs;
using LibHac.Util; using LibHac.Util;
namespace LibHac.FsSystem.Save; namespace LibHac.Tools.FsSystem.Save;
// todo: Change constraint to "unmanaged" after updating to // todo: Change constraint to "unmanaged" after updating to
// a newer SDK https://github.com/dotnet/csharplang/issues/1937 // a newer SDK https://github.com/dotnet/csharplang/issues/1937

View file

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

View file

@ -10,7 +10,7 @@ using LibHac.Fs;
using LibHac.Fs.Fsa; using LibHac.Fs.Fsa;
using LibHac.Fs.Impl; using LibHac.Fs.Impl;
using LibHac.FsSystem; using LibHac.FsSystem;
using LibHac.FsSystem.Save; using LibHac.Tools.FsSystem.Save;
using static hactoolnet.Print; using static hactoolnet.Print;
using Path = System.IO.Path; using Path = System.IO.Path;

View file

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

View file

@ -2,7 +2,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using LibHac.Fs; using LibHac.Fs;
using LibHac.FsSystem; using LibHac.FsSystem;
using LibHac.FsSystem.Save;
using LibHac.Tests.Fs; using LibHac.Tests.Fs;
using Xunit; using Xunit;