diff --git a/build/CodeGen/Stage2/KeysCodeGen.cs b/build/CodeGen/Stage2/KeysCodeGen.cs index 07621c3f..06557425 100644 --- a/build/CodeGen/Stage2/KeysCodeGen.cs +++ b/build/CodeGen/Stage2/KeysCodeGen.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using System.Security.Cryptography; -using LibHac; using LibHac.Common; using LibHac.Common.Keys; using LibHac.Crypto; @@ -388,4 +387,4 @@ public static class KeysCodeGen 0xE7, 0x86, 0x3B, 0x4F, 0x8E, 0x13, 0x09, 0x47, 0x32, 0x0E, 0x04, 0xB8, 0x4D, 0x5B, 0xB0, 0x46, 0x71, 0xB0, 0x5C, 0xF4, 0xAD, 0x63, 0x4F, 0xC5, 0xE2, 0xAC, 0x1E, 0xC4, 0x33, 0x96, 0x09, 0x7B }; -} +} \ No newline at end of file diff --git a/build/CodeGen/Stage2/RunStage2.cs b/build/CodeGen/Stage2/RunStage2.cs index 49f4d54b..fb01b94c 100644 --- a/build/CodeGen/Stage2/RunStage2.cs +++ b/build/CodeGen/Stage2/RunStage2.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using Octokit; namespace LibHacBuild.CodeGen.Stage2; @@ -22,4 +21,4 @@ public static class RunStage2 return 0; } -} +} \ No newline at end of file diff --git a/src/LibHac/Fs/Common/PathFormatter.cs b/src/LibHac/Fs/Common/PathFormatter.cs index 43638349..24b961f8 100644 --- a/src/LibHac/Fs/Common/PathFormatter.cs +++ b/src/LibHac/Fs/Common/PathFormatter.cs @@ -4,7 +4,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using LibHac.Common; using LibHac.Diag; -using LibHac.FsSystem; using LibHac.Util; using static LibHac.Fs.StringTraits; @@ -58,8 +57,8 @@ public static class PathFormatter newPath = default; int maxMountLength = outMountNameBuffer.Length == 0 - ? PathTools.MountNameLengthMax + 1 - : Math.Min(outMountNameBuffer.Length, PathTools.MountNameLengthMax + 1); + ? PathTool.MountNameLengthMax + 1 + : Math.Min(outMountNameBuffer.Length, PathTool.MountNameLengthMax + 1); int mountLength; for (mountLength = 0; mountLength < maxMountLength && path.At(mountLength) != 0; mountLength++) @@ -631,4 +630,4 @@ public static class PathFormatter { return Result.Success; } -} +} \ No newline at end of file diff --git a/src/LibHac/Fs/Common/PathNormalizer.cs b/src/LibHac/Fs/Common/PathNormalizer.cs index 5e14cc5b..197728dd 100644 --- a/src/LibHac/Fs/Common/PathNormalizer.cs +++ b/src/LibHac/Fs/Common/PathNormalizer.cs @@ -1,7 +1,6 @@ using System; using LibHac.Common; using LibHac.Diag; -using LibHac.FsSystem; using static LibHac.Fs.PathUtility; using static LibHac.Fs.StringTraits; @@ -48,7 +47,7 @@ public static class PathNormalizer if (IsParentDirectoryPathReplacementNeeded(currentPath)) { // Allocate a buffer to hold the replacement path. - convertedPath = new RentedArray(PathTools.MaxPathLength + 1); + convertedPath = new RentedArray(PathTool.EntryNameLengthMax + 1); // Replace the path. ReplaceParentDirectoryPath(convertedPath.Span, currentPath); @@ -368,4 +367,4 @@ public static class PathNormalizer dest[i] = NullTerminator; } -} +} \ No newline at end of file diff --git a/src/LibHac/Fs/DirectoryEntry.cs b/src/LibHac/Fs/DirectoryEntry.cs index 07c46b11..7b36417a 100644 --- a/src/LibHac/Fs/DirectoryEntry.cs +++ b/src/LibHac/Fs/DirectoryEntry.cs @@ -30,7 +30,7 @@ public struct DirectoryEntry [FieldOffset(0x304)] public DirectoryEntryType Type; [FieldOffset(0x308)] public long Size; - public Span Name => SpanHelpers.CreateSpan(ref _name, PathTools.MaxPathLength + 1); + public Span Name => SpanHelpers.CreateSpan(ref _name, PathTool.EntryNameLengthMax + 1); } public enum DirectoryEntryType : byte @@ -45,4 +45,4 @@ public enum NxFileAttributes : byte None = 0, Directory = 1 << 0, Archive = 1 << 1 -} +} \ No newline at end of file diff --git a/src/LibHac/Fs/Fsa/MountUtility.cs b/src/LibHac/Fs/Fsa/MountUtility.cs index da334694..09182350 100644 --- a/src/LibHac/Fs/Fsa/MountUtility.cs +++ b/src/LibHac/Fs/Fsa/MountUtility.cs @@ -2,7 +2,6 @@ using LibHac.Common; using LibHac.Diag; using LibHac.Fs.Impl; -using LibHac.FsSystem; using LibHac.Os; using LibHac.Util; using static LibHac.Fs.StringTraits; @@ -18,12 +17,12 @@ public static class MountUtility subPath = default; int mountLen = 0; - int maxMountLen = Math.Min(path.Length, PathTools.MountNameLengthMax); + int maxMountLen = Math.Min(path.Length, PathTool.MountNameLengthMax); if (WindowsPath.IsWindowsDrive(path) || WindowsPath.IsUncPath(path)) { StringUtils.Copy(mountName.Name, CommonPaths.HostRootFileSystemMountName); - mountName.Name[PathTools.MountNameLengthMax] = StringTraits.NullTerminator; + mountName.Name[PathTool.MountNameLengthMax] = StringTraits.NullTerminator; subPath = path; return Result.Success; @@ -31,7 +30,7 @@ public static class MountUtility for (int i = 0; i <= maxMountLen; i++) { - if (path[i] == PathTools.MountSeparator) + if (path[i] == StringTraits.DriveSeparator) { mountLen = i; break; @@ -79,7 +78,7 @@ public static class MountUtility if (name[i] == DriveSeparator || name[i] == DirectorySeparator) return false; - if (++length > PathTools.MountNameLengthMax) + if (++length > PathTool.MountNameLengthMax) return false; } @@ -254,4 +253,4 @@ public static class MountUtility StringUtils.Copy(commonPathBuffer.Slice(commonPathLength), subPath); return Result.Success; } -} +} \ No newline at end of file diff --git a/src/LibHac/Fs/InMemoryFileSystem.cs b/src/LibHac/Fs/InMemoryFileSystem.cs index cf635388..60634766 100644 --- a/src/LibHac/Fs/InMemoryFileSystem.cs +++ b/src/LibHac/Fs/InMemoryFileSystem.cs @@ -251,7 +251,7 @@ public class InMemoryFileSystem : IAttributeFileSystem ref DirectoryEntry entry = ref entryBuffer[i]; StringUtils.Copy(entry.Name, CurrentDir.Name); - entry.Name[PathTools.MaxPathLength] = 0; + entry.Name[PathTool.EntryNameLengthMax] = 0; entry.Type = DirectoryEntryType.Directory; entry.Attributes = CurrentDir.Attributes; @@ -269,7 +269,7 @@ public class InMemoryFileSystem : IAttributeFileSystem ref DirectoryEntry entry = ref entryBuffer[i]; StringUtils.Copy(entry.Name, CurrentFile.Name); - entry.Name[PathTools.MaxPathLength] = 0; + entry.Name[PathTool.EntryNameLengthMax] = 0; entry.Type = DirectoryEntryType.File; entry.Attributes = CurrentFile.Attributes; @@ -793,4 +793,4 @@ public class InMemoryFileSystem : IAttributeFileSystem return false; } } -} +} \ No newline at end of file diff --git a/src/LibHac/Fs/Shim/Bis.cs b/src/LibHac/Fs/Shim/Bis.cs index 43fff17a..614678ea 100644 --- a/src/LibHac/Fs/Shim/Bis.cs +++ b/src/LibHac/Fs/Shim/Bis.cs @@ -6,7 +6,6 @@ using LibHac.Fs.Fsa; using LibHac.Fs.Impl; using LibHac.FsSrv.Sf; using LibHac.Os; -using LibHac.FsSystem; using LibHac.Util; using static LibHac.Fs.Impl.CommonMountNames; using static LibHac.Fs.Impl.AccessLogStrings; @@ -40,7 +39,7 @@ public static class Bis ReadOnlySpan mountName = GetBisMountName(_partitionId); // Add 2 for the mount name separator and null terminator - int requiredNameBufferSize = StringUtils.GetLength(mountName, PathTools.MountNameLengthMax) + 2; + int requiredNameBufferSize = StringUtils.GetLength(mountName, PathTool.MountNameLengthMax) + 2; Assert.SdkRequiresGreaterEqual(nameBuffer.Length, requiredNameBufferSize); @@ -194,4 +193,4 @@ public static class Bis return Result.Success; } -} +} \ No newline at end of file diff --git a/src/LibHac/FsSystem/LocalDirectory.cs b/src/LibHac/FsSystem/LocalDirectory.cs index f737139b..2b6c1a06 100644 --- a/src/LibHac/FsSystem/LocalDirectory.cs +++ b/src/LibHac/FsSystem/LocalDirectory.cs @@ -41,7 +41,7 @@ public class LocalDirectory : IDirectory long length = isDir ? 0 : ((FileInfo)localEntry).Length; StringUtils.Copy(entryBuffer[i].Name, name); - entryBuffer[i].Name[PathTools.MaxPathLength] = 0; + entryBuffer[i].Name[PathTool.EntryNameLengthMax] = 0; entryBuffer[i].Attributes = localEntry.Attributes.ToNxAttributes(); entryBuffer[i].Type = type; diff --git a/src/LibHac/FsSystem/PartitionDirectory.cs b/src/LibHac/FsSystem/PartitionDirectory.cs index e3197d9f..6876dd5f 100644 --- a/src/LibHac/FsSystem/PartitionDirectory.cs +++ b/src/LibHac/FsSystem/PartitionDirectory.cs @@ -47,7 +47,7 @@ public class PartitionDirectory : IDirectory entry.Size = fileEntry.Size; StringUtils.Copy(entry.Name, nameUtf8); - entry.Name[PathTools.MaxPathLength] = 0; + entry.Name[PathTool.EntryNameLengthMax] = 0; CurrentIndex++; } @@ -68,4 +68,4 @@ public class PartitionDirectory : IDirectory entryCount = count; return Result.Success; } -} +} \ No newline at end of file diff --git a/src/LibHac/FsSystem/PathTools.cs b/src/LibHac/FsSystem/PathTools.cs index 37aa753d..d21f03c7 100644 --- a/src/LibHac/FsSystem/PathTools.cs +++ b/src/LibHac/FsSystem/PathTools.cs @@ -12,12 +12,8 @@ namespace LibHac.FsSystem; public static class PathTools { // todo: Consolidate these - internal const char DirectorySeparator = '/'; - internal const char MountSeparator = ':'; - internal const int MountNameLengthMax = 0xF; - - // Todo: Remove - internal const int MaxPathLength = 0x300; + private const char DirectorySeparator = '/'; + private const char MountSeparator = ':'; public static string Normalize(string inPath) { @@ -27,7 +23,7 @@ public static class PathTools var sb = new ValueStringBuilder(initialBuffer); int rootLen = 0; - int maxMountLen = Math.Min(inPath.Length, MountNameLengthMax); + int maxMountLen = Math.Min(inPath.Length, PathTool.MountNameLengthMax); for (int i = 0; i < maxMountLen; i++) { @@ -480,7 +476,7 @@ public static class PathTools { UnsafeHelpers.SkipParamInit(out length); - int maxLen = Math.Min(path.Length, MountNameLengthMax); + int maxLen = Math.Min(path.Length, PathTool.MountNameLengthMax); for (int i = 0; i < maxLen; i++) { @@ -518,4 +514,4 @@ public static class PathTools MountName, MountDelimiter } -} +} \ No newline at end of file diff --git a/src/LibHac/Tools/FsSystem/RomFs/RomFsDirectory.cs b/src/LibHac/Tools/FsSystem/RomFs/RomFsDirectory.cs index e6866cc7..ed2e593c 100644 --- a/src/LibHac/Tools/FsSystem/RomFs/RomFsDirectory.cs +++ b/src/LibHac/Tools/FsSystem/RomFs/RomFsDirectory.cs @@ -2,7 +2,6 @@ using System.Text; using LibHac.Fs; using LibHac.Fs.Fsa; -using LibHac.FsSystem; using LibHac.Util; namespace LibHac.Tools.FsSystem.RomFs; @@ -52,7 +51,7 @@ public class RomFsDirectory : IDirectory Span nameUtf8 = Encoding.UTF8.GetBytes(name); StringUtils.Copy(entry.Name, nameUtf8); - entry.Name[PathTools.MaxPathLength] = 0; + entry.Name[PathTool.EntryNameLengthMax] = 0; entry.Type = DirectoryEntryType.Directory; entry.Size = 0; @@ -72,7 +71,7 @@ public class RomFsDirectory : IDirectory Span nameUtf8 = Encoding.UTF8.GetBytes(name); StringUtils.Copy(entry.Name, nameUtf8); - entry.Name[PathTools.MaxPathLength] = 0; + entry.Name[PathTool.EntryNameLengthMax] = 0; entry.Type = DirectoryEntryType.File; entry.Size = info.Length;