diff --git a/src/LibHac/Boot/Package1.cs b/src/LibHac/Boot/Package1.cs index b93972cd..70407b41 100644 --- a/src/LibHac/Boot/Package1.cs +++ b/src/LibHac/Boot/Package1.cs @@ -1,6 +1,5 @@ using LibHac.Common; using LibHac.Fs; -using LibHac.FsSystem; using System; using System.Collections.Generic; using System.Runtime.CompilerServices; diff --git a/src/LibHac/Boot/Package2StorageReader.cs b/src/LibHac/Boot/Package2StorageReader.cs index f9d77bf7..e19dd186 100644 --- a/src/LibHac/Boot/Package2StorageReader.cs +++ b/src/LibHac/Boot/Package2StorageReader.cs @@ -5,7 +5,6 @@ using LibHac.Common; using LibHac.Common.Keys; using LibHac.Crypto; using LibHac.Fs; -using LibHac.FsSystem; using LibHac.Kernel; using LibHac.Tools.FsSystem; diff --git a/src/LibHac/Common/PathBuilder.cs b/src/LibHac/Common/PathBuilder.cs deleted file mode 100644 index 5501db3d..00000000 --- a/src/LibHac/Common/PathBuilder.cs +++ /dev/null @@ -1,123 +0,0 @@ -using System; -using System.Diagnostics; -using System.Runtime.CompilerServices; -using LibHac.Fs; -using LibHac.FsSystem; -using LibHac.Util; - -namespace LibHac.Common; - -[DebuggerDisplay("{ToString()}")] -internal ref struct PathBuilder -{ - private Span _buffer; - private int _pos; - - public int Length - { - get => _pos; - set - { - Debug.Assert(value >= 0); - Debug.Assert(value <= Capacity); - _pos = value; - } - } - - public int Capacity => _buffer.Length - 1; - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public PathBuilder(Span buffer) - { - _buffer = buffer; - _pos = 0; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Result Append(byte value) - { - int pos = _pos; - if (pos >= Capacity) - { - return ResultFs.TooLongPath.Log(); - } - - _buffer[pos] = value; - _pos = pos + 1; - return Result.Success; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Result Append(ReadOnlySpan value) - { - int pos = _pos; - if (pos + value.Length >= Capacity) - { - return ResultFs.TooLongPath.Log(); - } - - value.CopyTo(_buffer.Slice(pos)); - _pos = pos + value.Length; - return Result.Success; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Result AppendWithPrecedingSeparator(byte value) - { - int pos = _pos; - if (pos + 1 >= Capacity) - { - // Append the separator if there's enough space - if (pos < Capacity) - { - _buffer[pos] = (byte)'/'; - _pos = pos + 1; - } - - return ResultFs.TooLongPath.Log(); - } - - _buffer[pos] = (byte)'/'; - _buffer[pos + 1] = value; - _pos = pos + 2; - return Result.Success; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Result GoUpLevels(int count) - { - Debug.Assert(count > 0); - - int separators = 0; - int pos = _pos - 1; - - for (; pos >= 0; pos--) - { - if (PathTools.IsDirectorySeparator(_buffer[pos])) - { - separators++; - - if (separators == count) break; - } - } - - if (separators != count) return ResultFs.DirectoryUnobtainable.Log(); - - _pos = pos; - return Result.Success; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Terminate() - { - if (_buffer.Length > _pos) - { - _buffer[_pos] = 0; - } - } - - public override string ToString() - { - return StringUtils.Utf8ZToString(_buffer.Slice(0, Length)); - } -} diff --git a/src/LibHac/FsSystem/PartitionDirectory.cs b/src/LibHac/FsSystem/PartitionDirectory.cs index 6876dd5f..a21ec0d8 100644 --- a/src/LibHac/FsSystem/PartitionDirectory.cs +++ b/src/LibHac/FsSystem/PartitionDirectory.cs @@ -3,6 +3,7 @@ using System.IO; using System.Text; using LibHac.Fs; using LibHac.Fs.Fsa; +using LibHac.Tools.FsSystem; using LibHac.Util; namespace LibHac.FsSystem; diff --git a/src/LibHac/Tools/Fs/DirectoryEntryEx.cs b/src/LibHac/Tools/Fs/DirectoryEntryEx.cs index 0eabb724..62aeb59d 100644 --- a/src/LibHac/Tools/Fs/DirectoryEntryEx.cs +++ b/src/LibHac/Tools/Fs/DirectoryEntryEx.cs @@ -1,5 +1,5 @@ using LibHac.Fs; -using LibHac.FsSystem; +using LibHac.Tools.FsSystem; namespace LibHac.Tools.Fs; diff --git a/src/LibHac/Tools/Fs/FileSystemClientUtils.cs b/src/LibHac/Tools/Fs/FileSystemClientUtils.cs index bc0f4936..f1b8e6bc 100644 --- a/src/LibHac/Tools/Fs/FileSystemClientUtils.cs +++ b/src/LibHac/Tools/Fs/FileSystemClientUtils.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using LibHac.Common; using LibHac.Fs; using LibHac.Fs.Fsa; -using LibHac.FsSystem; using LibHac.Tools.FsSystem; namespace LibHac.Tools.Fs; diff --git a/src/LibHac/Fs/InMemoryFileSystem.cs b/src/LibHac/Tools/Fs/InMemoryFileSystem.cs similarity index 99% rename from src/LibHac/Fs/InMemoryFileSystem.cs rename to src/LibHac/Tools/Fs/InMemoryFileSystem.cs index 60634766..e799804f 100644 --- a/src/LibHac/Fs/InMemoryFileSystem.cs +++ b/src/LibHac/Tools/Fs/InMemoryFileSystem.cs @@ -2,11 +2,13 @@ using System.Diagnostics; using System.IO; using LibHac.Common; +using LibHac.Fs; using LibHac.Fs.Fsa; -using LibHac.FsSystem; +using LibHac.Tools.FsSystem; using LibHac.Util; +using Path = LibHac.Fs.Path; -namespace LibHac.Fs; +namespace LibHac.Tools.Fs; /// /// A filesystem stored in-memory. Mainly used for testing. diff --git a/src/LibHac/Tools/FsSystem/AesXtsDirectory.cs b/src/LibHac/Tools/FsSystem/AesXtsDirectory.cs index 8547924f..c70ed038 100644 --- a/src/LibHac/Tools/FsSystem/AesXtsDirectory.cs +++ b/src/LibHac/Tools/FsSystem/AesXtsDirectory.cs @@ -2,7 +2,6 @@ using LibHac.Common; using LibHac.Fs; using LibHac.Fs.Fsa; -using LibHac.FsSystem; using LibHac.Util; namespace LibHac.Tools.FsSystem; diff --git a/src/LibHac/Tools/FsSystem/AesXtsFileSystem.cs b/src/LibHac/Tools/FsSystem/AesXtsFileSystem.cs index 62bda6a1..477c93dc 100644 --- a/src/LibHac/Tools/FsSystem/AesXtsFileSystem.cs +++ b/src/LibHac/Tools/FsSystem/AesXtsFileSystem.cs @@ -3,7 +3,6 @@ using System.Diagnostics; using LibHac.Common; using LibHac.Fs; using LibHac.Fs.Fsa; -using LibHac.FsSystem; using LibHac.Tools.Fs; using LibHac.Util; diff --git a/src/LibHac/Tools/FsSystem/Delta.cs b/src/LibHac/Tools/FsSystem/Delta.cs index 07d783aa..a940f407 100644 --- a/src/LibHac/Tools/FsSystem/Delta.cs +++ b/src/LibHac/Tools/FsSystem/Delta.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.IO; using LibHac.Fs; using LibHac.Fs.Fsa; -using LibHac.FsSystem; namespace LibHac.Tools.FsSystem; diff --git a/src/LibHac/FsSystem/PathParser.cs b/src/LibHac/Tools/FsSystem/PathParser.cs similarity index 98% rename from src/LibHac/FsSystem/PathParser.cs rename to src/LibHac/Tools/FsSystem/PathParser.cs index 76bf7524..3416bcd7 100644 --- a/src/LibHac/FsSystem/PathParser.cs +++ b/src/LibHac/Tools/FsSystem/PathParser.cs @@ -1,7 +1,7 @@ using System; using System.Diagnostics; -namespace LibHac.FsSystem; +namespace LibHac.Tools.FsSystem; /// /// Enumerates a file or directory path one segment at a time. @@ -82,4 +82,4 @@ public ref struct PathParser /// /// if the current path segment is the final one. public bool IsFinished() => _finished; -} +} \ No newline at end of file diff --git a/src/LibHac/FsSystem/PathTools.cs b/src/LibHac/Tools/FsSystem/PathTools.cs similarity index 99% rename from src/LibHac/FsSystem/PathTools.cs rename to src/LibHac/Tools/FsSystem/PathTools.cs index d21f03c7..2c611b62 100644 --- a/src/LibHac/FsSystem/PathTools.cs +++ b/src/LibHac/Tools/FsSystem/PathTools.cs @@ -5,9 +5,10 @@ using System.Runtime.CompilerServices; using LibHac.Common; using LibHac.Diag; using LibHac.Fs; +using LibHac.FsSystem; using LibHac.Util; -namespace LibHac.FsSystem; +namespace LibHac.Tools.FsSystem; public static class PathTools { diff --git a/src/LibHac/Tools/FsSystem/RomFs/HierarchicalRomFileTable.cs b/src/LibHac/Tools/FsSystem/RomFs/HierarchicalRomFileTable.cs index f27e6ff0..da84a948 100644 --- a/src/LibHac/Tools/FsSystem/RomFs/HierarchicalRomFileTable.cs +++ b/src/LibHac/Tools/FsSystem/RomFs/HierarchicalRomFileTable.cs @@ -2,7 +2,6 @@ using System.Runtime.InteropServices; using LibHac.Common; using LibHac.Fs; -using LibHac.FsSystem; using LibHac.Util; namespace LibHac.Tools.FsSystem.RomFs; diff --git a/src/LibHac/Tools/FsSystem/RomFs/RomFsBuilder.cs b/src/LibHac/Tools/FsSystem/RomFs/RomFsBuilder.cs index a2e0c7a5..3da4aaae 100644 --- a/src/LibHac/Tools/FsSystem/RomFs/RomFsBuilder.cs +++ b/src/LibHac/Tools/FsSystem/RomFs/RomFsBuilder.cs @@ -5,7 +5,6 @@ using System.Linq; using LibHac.Common; using LibHac.Fs; using LibHac.Fs.Fsa; -using LibHac.FsSystem; using LibHac.Tools.Fs; using LibHac.Util; diff --git a/src/LibHac/Tools/FsSystem/Save/HierarchicalSaveFileTable.cs b/src/LibHac/Tools/FsSystem/Save/HierarchicalSaveFileTable.cs index 9293eb49..de8c7d92 100644 --- a/src/LibHac/Tools/FsSystem/Save/HierarchicalSaveFileTable.cs +++ b/src/LibHac/Tools/FsSystem/Save/HierarchicalSaveFileTable.cs @@ -3,7 +3,6 @@ using System.IO; using System.Runtime.InteropServices; using LibHac.Common; using LibHac.Fs; -using LibHac.FsSystem; using LibHac.Util; namespace LibHac.Tools.FsSystem.Save; diff --git a/src/hactoolnet/FsUtils.cs b/src/hactoolnet/FsUtils.cs index e7da5e1e..1e12d8a7 100644 --- a/src/hactoolnet/FsUtils.cs +++ b/src/hactoolnet/FsUtils.cs @@ -4,7 +4,6 @@ using LibHac; using LibHac.Common; using LibHac.Fs; using LibHac.Fs.Fsa; -using LibHac.FsSystem; using LibHac.Tools.Fs; using LibHac.Tools.FsSystem; diff --git a/tests/LibHac.Tests/Fs/AesXtsFileSystemTests.cs b/tests/LibHac.Tests/Fs/AesXtsFileSystemTests.cs index b6bb24df..c46e8788 100644 --- a/tests/LibHac.Tests/Fs/AesXtsFileSystemTests.cs +++ b/tests/LibHac.Tests/Fs/AesXtsFileSystemTests.cs @@ -1,6 +1,6 @@ -using LibHac.Fs; -using LibHac.Fs.Fsa; +using LibHac.Fs.Fsa; using LibHac.Tests.Fs.IFileSystemTestBase; +using LibHac.Tools.Fs; using LibHac.Tools.FsSystem; namespace LibHac.Tests.Fs; diff --git a/tests/LibHac.Tests/Fs/DirectorySaveDataFileSystemTests.cs b/tests/LibHac.Tests/Fs/DirectorySaveDataFileSystemTests.cs index ceff4a10..9e2945f4 100644 --- a/tests/LibHac.Tests/Fs/DirectorySaveDataFileSystemTests.cs +++ b/tests/LibHac.Tests/Fs/DirectorySaveDataFileSystemTests.cs @@ -7,6 +7,7 @@ using LibHac.Fs.Fsa; using LibHac.FsSrv; using LibHac.FsSystem; using LibHac.Tests.Fs.IFileSystemTestBase; +using LibHac.Tools.Fs; using Xunit; namespace LibHac.Tests.Fs; @@ -448,4 +449,4 @@ public class DirectorySaveDataFileSystemTests : CommittableIFileSystemTests return Result.Success; } -} +} \ No newline at end of file diff --git a/tests/LibHac.Tests/Fs/FileSystemClientTests/FileSystemServerFactory.cs b/tests/LibHac.Tests/Fs/FileSystemClientTests/FileSystemServerFactory.cs index eb7438a9..bbb61dff 100644 --- a/tests/LibHac.Tests/Fs/FileSystemClientTests/FileSystemServerFactory.cs +++ b/tests/LibHac.Tests/Fs/FileSystemClientTests/FileSystemServerFactory.cs @@ -2,6 +2,7 @@ using LibHac.Fs; using LibHac.Fs.Fsa; using LibHac.FsSrv; +using LibHac.Tools.Fs; namespace LibHac.Tests.Fs.FileSystemClientTests; @@ -53,4 +54,4 @@ public static class FileSystemServerFactory { return CreateHorizonImpl(true, out _); } -} +} \ No newline at end of file diff --git a/tests/LibHac.Tests/Fs/InMemoryFileSystemTests.cs b/tests/LibHac.Tests/Fs/InMemoryFileSystemTests.cs index ca8d42d7..23712fb5 100644 --- a/tests/LibHac.Tests/Fs/InMemoryFileSystemTests.cs +++ b/tests/LibHac.Tests/Fs/InMemoryFileSystemTests.cs @@ -1,6 +1,6 @@ -using LibHac.Fs; -using LibHac.Fs.Fsa; +using LibHac.Fs.Fsa; using LibHac.Tests.Fs.IFileSystemTestBase; +using LibHac.Tools.Fs; namespace LibHac.Tests.Fs; @@ -15,4 +15,4 @@ public class InMemoryFileSystemTests : IAttributeFileSystemTests { return new InMemoryFileSystem(); } -} +} \ No newline at end of file diff --git a/tests/LibHac.Tests/Fs/LayeredFileSystemTests.cs b/tests/LibHac.Tests/Fs/LayeredFileSystemTests.cs index ad789031..0ae66103 100644 --- a/tests/LibHac.Tests/Fs/LayeredFileSystemTests.cs +++ b/tests/LibHac.Tests/Fs/LayeredFileSystemTests.cs @@ -3,6 +3,7 @@ using LibHac.Common; using LibHac.Fs; using LibHac.Fs.Fsa; using LibHac.FsSystem; +using LibHac.Tools.Fs; using LibHac.Util; using Xunit; @@ -205,4 +206,4 @@ public class LayeredFileSystemTests Assert.Success(directory.Get.GetEntryCount(out long entryCount)); Assert.Equal(0, entryCount); } -} +} \ No newline at end of file diff --git a/tests/LibHac.Tests/Fs/SubdirectoryFileSystemTests.cs b/tests/LibHac.Tests/Fs/SubdirectoryFileSystemTests.cs index 3e48aeee..5770ee8e 100644 --- a/tests/LibHac.Tests/Fs/SubdirectoryFileSystemTests.cs +++ b/tests/LibHac.Tests/Fs/SubdirectoryFileSystemTests.cs @@ -3,6 +3,7 @@ using LibHac.Fs; using LibHac.Fs.Fsa; using LibHac.FsSystem; using LibHac.Tests.Fs.IFileSystemTestBase; +using LibHac.Tools.Fs; using Xunit; namespace LibHac.Tests.Fs; @@ -65,4 +66,4 @@ public class SubdirectoryFileSystemTestsRoot : IFileSystemTests subFs.Initialize(in rootPath).ThrowIfFailure(); return subFs; } -} +} \ No newline at end of file diff --git a/tests/LibHac.Tests/HorizonFactory.cs b/tests/LibHac.Tests/HorizonFactory.cs index f333a050..1371d641 100644 --- a/tests/LibHac.Tests/HorizonFactory.cs +++ b/tests/LibHac.Tests/HorizonFactory.cs @@ -1,8 +1,8 @@ using LibHac.Bcat; using LibHac.Common.Keys; -using LibHac.Fs; using LibHac.Fs.Fsa; using LibHac.FsSrv; +using LibHac.Tools.Fs; namespace LibHac.Tests; @@ -32,4 +32,4 @@ public static class HorizonFactory return horizon; } -} +} \ No newline at end of file diff --git a/tests/LibHac.Tests/Kvdb/FlatMapKeyValueStoreTests.cs b/tests/LibHac.Tests/Kvdb/FlatMapKeyValueStoreTests.cs index c19f88c1..a31f0ff2 100644 --- a/tests/LibHac.Tests/Kvdb/FlatMapKeyValueStoreTests.cs +++ b/tests/LibHac.Tests/Kvdb/FlatMapKeyValueStoreTests.cs @@ -4,6 +4,7 @@ using LibHac.Fs; using LibHac.Fs.Fsa; using LibHac.Kvdb; using LibHac.Tests.Fs.FileSystemClientTests; +using LibHac.Tools.Fs; using Xunit; using TTest = System.Int32; @@ -581,4 +582,4 @@ public class FlatMapKeyValueStoreTests iterator.Next(); } } -} +} \ No newline at end of file diff --git a/tests/LibHac.Tests/PathToolsTests.cs b/tests/LibHac.Tests/PathToolsTests.cs index 77d95b45..cd24b56b 100644 --- a/tests/LibHac.Tests/PathToolsTests.cs +++ b/tests/LibHac.Tests/PathToolsTests.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using LibHac.Common; -using LibHac.FsSystem; +using LibHac.Tools.FsSystem; using LibHac.Util; using Xunit; @@ -219,4 +219,4 @@ public class PathToolsTests Assert.Equal(expected, actual); } -} +} \ No newline at end of file