From 34faf2b468a72dc6c92efb147febd3584b1ea30f Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Sat, 18 Dec 2021 19:49:31 -0700 Subject: [PATCH] Move RomFs --- src/LibHac/FsSrv/FsCreator/RomFileSystemCreator.cs | 4 ++-- src/LibHac/Tools/FsSystem/NcaUtils/Nca.cs | 2 +- src/LibHac/{ => Tools/FsSystem/RomFs}/HashHelpers.cs | 4 ++-- .../FsSystem/RomFs/HierarchicalRomFileTable.cs | 5 +++-- src/LibHac/{ => Tools}/FsSystem/RomFs/RomFsBuilder.cs | 5 +++-- src/LibHac/{ => Tools}/FsSystem/RomFs/RomFsDictionary.cs | 5 +++-- src/LibHac/{ => Tools}/FsSystem/RomFs/RomFsDirectory.cs | 5 +++-- src/LibHac/{ => Tools}/FsSystem/RomFs/RomFsEntries.cs | 8 +++----- src/LibHac/{ => Tools}/FsSystem/RomFs/RomFsFile.cs | 4 ++-- src/LibHac/{ => Tools}/FsSystem/RomFs/RomFsFileSystem.cs | 5 +++-- src/hactoolnet/ProcessFsBuild.cs | 4 ++-- src/hactoolnet/ProcessRomfs.cs | 4 ++-- tests/LibHac.Tests/RomFsTests.cs | 4 ++-- 13 files changed, 31 insertions(+), 28 deletions(-) rename src/LibHac/{ => Tools/FsSystem/RomFs}/HashHelpers.cs (99%) rename src/LibHac/{ => Tools}/FsSystem/RomFs/HierarchicalRomFileTable.cs (99%) rename src/LibHac/{ => Tools}/FsSystem/RomFs/RomFsBuilder.cs (98%) rename src/LibHac/{ => Tools}/FsSystem/RomFs/RomFsDictionary.cs (99%) rename src/LibHac/{ => Tools}/FsSystem/RomFs/RomFsDirectory.cs (97%) rename src/LibHac/{ => Tools}/FsSystem/RomFs/RomFsEntries.cs (84%) rename src/LibHac/{ => Tools}/FsSystem/RomFs/RomFsFile.cs (97%) rename src/LibHac/{ => Tools}/FsSystem/RomFs/RomFsFileSystem.cs (99%) diff --git a/src/LibHac/FsSrv/FsCreator/RomFileSystemCreator.cs b/src/LibHac/FsSrv/FsCreator/RomFileSystemCreator.cs index a03eff17..0208813a 100644 --- a/src/LibHac/FsSrv/FsCreator/RomFileSystemCreator.cs +++ b/src/LibHac/FsSrv/FsCreator/RomFileSystemCreator.cs @@ -1,7 +1,7 @@ using LibHac.Common; using LibHac.Fs; using LibHac.Fs.Fsa; -using LibHac.FsSystem.RomFs; +using LibHac.Tools.FsSystem.RomFs; namespace LibHac.FsSrv.FsCreator; @@ -13,4 +13,4 @@ public class RomFileSystemCreator : IRomFileSystemCreator outFileSystem.Reset(new RomFsFileSystem(ref romFsStorage)); return Result.Success; } -} +} \ No newline at end of file diff --git a/src/LibHac/Tools/FsSystem/NcaUtils/Nca.cs b/src/LibHac/Tools/FsSystem/NcaUtils/Nca.cs index c73c35fd..f90bdd42 100644 --- a/src/LibHac/Tools/FsSystem/NcaUtils/Nca.cs +++ b/src/LibHac/Tools/FsSystem/NcaUtils/Nca.cs @@ -10,8 +10,8 @@ using LibHac.Diag; using LibHac.Fs; using LibHac.Fs.Fsa; using LibHac.FsSystem; -using LibHac.FsSystem.RomFs; using LibHac.Spl; +using LibHac.Tools.FsSystem.RomFs; namespace LibHac.Tools.FsSystem.NcaUtils; diff --git a/src/LibHac/HashHelpers.cs b/src/LibHac/Tools/FsSystem/RomFs/HashHelpers.cs similarity index 99% rename from src/LibHac/HashHelpers.cs rename to src/LibHac/Tools/FsSystem/RomFs/HashHelpers.cs index c668c357..e5b3b86a 100644 --- a/src/LibHac/HashHelpers.cs +++ b/src/LibHac/Tools/FsSystem/RomFs/HashHelpers.cs @@ -6,7 +6,7 @@ using System; using System.Diagnostics; -namespace LibHac; +namespace LibHac.Tools.FsSystem.RomFs; internal static class HashHelpers { @@ -103,4 +103,4 @@ internal static class HashHelpers return min; } -} +} \ No newline at end of file diff --git a/src/LibHac/FsSystem/RomFs/HierarchicalRomFileTable.cs b/src/LibHac/Tools/FsSystem/RomFs/HierarchicalRomFileTable.cs similarity index 99% rename from src/LibHac/FsSystem/RomFs/HierarchicalRomFileTable.cs rename to src/LibHac/Tools/FsSystem/RomFs/HierarchicalRomFileTable.cs index 76836755..f27e6ff0 100644 --- a/src/LibHac/FsSystem/RomFs/HierarchicalRomFileTable.cs +++ b/src/LibHac/Tools/FsSystem/RomFs/HierarchicalRomFileTable.cs @@ -2,9 +2,10 @@ using System.Runtime.InteropServices; using LibHac.Common; using LibHac.Fs; +using LibHac.FsSystem; using LibHac.Util; -namespace LibHac.FsSystem.RomFs; +namespace LibHac.Tools.FsSystem.RomFs; /// /// Represents the file table used by the RomFS format. @@ -384,4 +385,4 @@ public class HierarchicalRomFileTable where T : unmanaged public int NextSibling; public T Info; } -} +} \ No newline at end of file diff --git a/src/LibHac/FsSystem/RomFs/RomFsBuilder.cs b/src/LibHac/Tools/FsSystem/RomFs/RomFsBuilder.cs similarity index 98% rename from src/LibHac/FsSystem/RomFs/RomFsBuilder.cs rename to src/LibHac/Tools/FsSystem/RomFs/RomFsBuilder.cs index 75f2499b..b90ff93c 100644 --- a/src/LibHac/FsSystem/RomFs/RomFsBuilder.cs +++ b/src/LibHac/Tools/FsSystem/RomFs/RomFsBuilder.cs @@ -5,9 +5,10 @@ using System.Linq; using LibHac.Common; using LibHac.Fs; using LibHac.Fs.Fsa; +using LibHac.FsSystem; using LibHac.Util; -namespace LibHac.FsSystem.RomFs; +namespace LibHac.Tools.FsSystem.RomFs; /// /// Builds a RomFS from a collection of files. @@ -113,4 +114,4 @@ public class RomFsBuilder fileLength += table.Length; } } -} +} \ No newline at end of file diff --git a/src/LibHac/FsSystem/RomFs/RomFsDictionary.cs b/src/LibHac/Tools/FsSystem/RomFs/RomFsDictionary.cs similarity index 99% rename from src/LibHac/FsSystem/RomFs/RomFsDictionary.cs rename to src/LibHac/Tools/FsSystem/RomFs/RomFsDictionary.cs index ea02f261..e720cca5 100644 --- a/src/LibHac/FsSystem/RomFs/RomFsDictionary.cs +++ b/src/LibHac/Tools/FsSystem/RomFs/RomFsDictionary.cs @@ -3,9 +3,10 @@ using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using LibHac.Fs; +using LibHac.FsSystem; using LibHac.Util; -namespace LibHac.FsSystem.RomFs; +namespace LibHac.Tools.FsSystem.RomFs; internal class RomFsDictionary where T : unmanaged { @@ -296,4 +297,4 @@ internal class RomFsDictionary where T : unmanaged public int Next; public int KeyLength; } -} +} \ No newline at end of file diff --git a/src/LibHac/FsSystem/RomFs/RomFsDirectory.cs b/src/LibHac/Tools/FsSystem/RomFs/RomFsDirectory.cs similarity index 97% rename from src/LibHac/FsSystem/RomFs/RomFsDirectory.cs rename to src/LibHac/Tools/FsSystem/RomFs/RomFsDirectory.cs index a6658638..e6866cc7 100644 --- a/src/LibHac/FsSystem/RomFs/RomFsDirectory.cs +++ b/src/LibHac/Tools/FsSystem/RomFs/RomFsDirectory.cs @@ -2,9 +2,10 @@ using System.Text; using LibHac.Fs; using LibHac.Fs.Fsa; +using LibHac.FsSystem; using LibHac.Util; -namespace LibHac.FsSystem.RomFs; +namespace LibHac.Tools.FsSystem.RomFs; public class RomFsDirectory : IDirectory { @@ -85,4 +86,4 @@ public class RomFsDirectory : IDirectory return Result.Success; } -} +} \ No newline at end of file diff --git a/src/LibHac/FsSystem/RomFs/RomFsEntries.cs b/src/LibHac/Tools/FsSystem/RomFs/RomFsEntries.cs similarity index 84% rename from src/LibHac/FsSystem/RomFs/RomFsEntries.cs rename to src/LibHac/Tools/FsSystem/RomFs/RomFsEntries.cs index 23fecaab..43634bad 100644 --- a/src/LibHac/FsSystem/RomFs/RomFsEntries.cs +++ b/src/LibHac/Tools/FsSystem/RomFs/RomFsEntries.cs @@ -1,7 +1,7 @@ using System; using System.Runtime.InteropServices; -namespace LibHac.FsSystem.RomFs; +namespace LibHac.Tools.FsSystem.RomFs; internal ref struct RomEntryKey { @@ -32,9 +32,7 @@ internal ref struct RomEntryKey } } -// todo: Change constraint to "unmanaged" after updating to -// a newer SDK https://github.com/dotnet/csharplang/issues/1937 -internal ref struct RomKeyValuePair where T : struct +internal ref struct RomKeyValuePair where T : unmanaged { public RomEntryKey Key; public int Offset; @@ -58,4 +56,4 @@ public struct FindPosition public int NextDirectory; /// The ID of the next file to be enumerated. public int NextFile; -} +} \ No newline at end of file diff --git a/src/LibHac/FsSystem/RomFs/RomFsFile.cs b/src/LibHac/Tools/FsSystem/RomFs/RomFsFile.cs similarity index 97% rename from src/LibHac/FsSystem/RomFs/RomFsFile.cs rename to src/LibHac/Tools/FsSystem/RomFs/RomFsFile.cs index 6fd1d9ab..a9a85d67 100644 --- a/src/LibHac/FsSystem/RomFs/RomFsFile.cs +++ b/src/LibHac/Tools/FsSystem/RomFs/RomFsFile.cs @@ -3,7 +3,7 @@ using LibHac.Common; using LibHac.Fs; using LibHac.Fs.Fsa; -namespace LibHac.FsSystem.RomFs; +namespace LibHac.Tools.FsSystem.RomFs; public class RomFsFile : IFile { @@ -67,4 +67,4 @@ public class RomFsFile : IFile { return RomFsFileSystem.ConvertRomFsDriverPrivateResult(result); } -} +} \ No newline at end of file diff --git a/src/LibHac/FsSystem/RomFs/RomFsFileSystem.cs b/src/LibHac/Tools/FsSystem/RomFs/RomFsFileSystem.cs similarity index 99% rename from src/LibHac/FsSystem/RomFs/RomFsFileSystem.cs rename to src/LibHac/Tools/FsSystem/RomFs/RomFsFileSystem.cs index 7bc775c9..44b4d85b 100644 --- a/src/LibHac/FsSystem/RomFs/RomFsFileSystem.cs +++ b/src/LibHac/Tools/FsSystem/RomFs/RomFsFileSystem.cs @@ -2,8 +2,9 @@ using LibHac.Common; using LibHac.Fs; using LibHac.Fs.Fsa; +using LibHac.FsSystem; -namespace LibHac.FsSystem.RomFs; +namespace LibHac.Tools.FsSystem.RomFs; public class RomFsFileSystem : IFileSystem { @@ -317,4 +318,4 @@ public class RomfsHeader FileMetaTableSize = func(); DataOffset = func(); } -} +} \ No newline at end of file diff --git a/src/hactoolnet/ProcessFsBuild.cs b/src/hactoolnet/ProcessFsBuild.cs index 3f020c1d..98ad3bae 100644 --- a/src/hactoolnet/ProcessFsBuild.cs +++ b/src/hactoolnet/ProcessFsBuild.cs @@ -1,7 +1,7 @@ using System.IO; using LibHac.Fs; using LibHac.FsSystem; -using LibHac.FsSystem.RomFs; +using LibHac.Tools.FsSystem.RomFs; namespace hactoolnet; @@ -60,4 +60,4 @@ internal static class ProcessFsBuild ctx.Logger.LogMessage($"Finished writing {ctx.Options.OutFile}"); } -} +} \ No newline at end of file diff --git a/src/hactoolnet/ProcessRomfs.cs b/src/hactoolnet/ProcessRomfs.cs index 88e86962..3a6b5d10 100644 --- a/src/hactoolnet/ProcessRomfs.cs +++ b/src/hactoolnet/ProcessRomfs.cs @@ -1,7 +1,7 @@ using System.IO; using LibHac.Fs; using LibHac.FsSystem; -using LibHac.FsSystem.RomFs; +using LibHac.Tools.FsSystem.RomFs; namespace hactoolnet; @@ -42,4 +42,4 @@ internal static class ProcessRomfs romfs.Extract(ctx.Options.RomfsOutDir, ctx.Logger); } } -} +} \ No newline at end of file diff --git a/tests/LibHac.Tests/RomFsTests.cs b/tests/LibHac.Tests/RomFsTests.cs index 15e1d26c..0573f594 100644 --- a/tests/LibHac.Tests/RomFsTests.cs +++ b/tests/LibHac.Tests/RomFsTests.cs @@ -1,5 +1,5 @@ using System; -using LibHac.FsSystem.RomFs; +using LibHac.Tools.FsSystem.RomFs; using Xunit; namespace LibHac.Tests; @@ -200,4 +200,4 @@ public class RomFsTests Assert.Equal(itemC2, actualItemC2); Assert.Equal(itemC3, actualItemC3); } -} +} \ No newline at end of file