From c97c0f82973a0efc4454a4b989977bf2fdd72d4f Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Tue, 15 Nov 2022 20:21:36 -0700 Subject: [PATCH] Use UTF-8 literals where applicable --- .../Core/DeliveryCacheStorageManager.cs | 77 +-- src/LibHac/Boot/Package1.cs | 6 +- src/LibHac/Diag/Log.cs | 2 +- src/LibHac/Fs/AccessLog.cs | 529 ++++-------------- src/LibHac/Fs/Common/Path.cs | 13 +- src/LibHac/Fs/Common/PathFormatter.cs | 12 +- src/LibHac/Fs/Common/PathUtility.cs | 3 +- src/LibHac/Fs/CommonPaths.cs | 6 +- src/LibHac/Fs/Fsa/FileSystemAccessor.cs | 91 +-- src/LibHac/Fs/Fsa/UserFileSystem.cs | 4 +- src/LibHac/Fs/Fsa/UserFileSystemPrivate.cs | 2 +- src/LibHac/Fs/Impl/CommonMountNames.cs | 70 +-- src/LibHac/Fs/Shim/CustomStorage.cs | 7 +- src/LibHac/Fs/Shim/Host.cs | 3 +- src/LibHac/Fs/Shim/SignedSystemPartition.cs | 2 +- src/LibHac/FsSrv/AccessLogService.cs | 10 +- .../FsSrv/Impl/FileSystemInterfaceAdapter.cs | 2 +- src/LibHac/FsSrv/Impl/MultiCommitManager.cs | 3 +- src/LibHac/FsSrv/NcaFileSystemServiceImpl.cs | 29 +- src/LibHac/FsSrv/SaveDataFileSystemService.cs | 6 +- .../FsSrv/SaveDataFileSystemServiceImpl.cs | 11 +- src/LibHac/FsSrv/SaveDataIndexer.cs | 10 +- src/LibHac/FsSrv/SaveDataIndexerManager.cs | 28 +- .../FsSystem/ConcatenationFileSystem.cs | 2 +- .../FsSystem/DirectorySaveDataFileSystem.cs | 29 +- ...ierarchicalIntegrityVerificationStorage.cs | 66 +-- .../FsSystem/PartitionFileSystemCore.cs | 6 +- src/LibHac/FsSystem/Utility.cs | 2 +- src/LibHac/Kvdb/FlatMapKeyValueStore.cs | 7 +- 29 files changed, 237 insertions(+), 801 deletions(-) diff --git a/src/LibHac/Bcat/Impl/Service/Core/DeliveryCacheStorageManager.cs b/src/LibHac/Bcat/Impl/Service/Core/DeliveryCacheStorageManager.cs index c6252748..7eb45ba6 100644 --- a/src/LibHac/Bcat/Impl/Service/Core/DeliveryCacheStorageManager.cs +++ b/src/LibHac/Bcat/Impl/Service/Core/DeliveryCacheStorageManager.cs @@ -330,69 +330,36 @@ internal class DeliveryCacheStorageManager return 1; } - private static ReadOnlySpan DeliveryCacheMountNamePrefix => // bcat-dc- - new[] { (byte)'b', (byte)'c', (byte)'a', (byte)'t', (byte)'-', (byte)'d', (byte)'c', (byte)'-' }; + /// "bcat-dc-" + private static ReadOnlySpan DeliveryCacheMountNamePrefix => "bcat-dc-"u8; - private static ReadOnlySpan RootPath => // :/ - new[] { (byte)':', (byte)'/' }; + /// ":/" + private static ReadOnlySpan RootPath => ":/"u8; - private static ReadOnlySpan PassphrasePath => // :/passphrase.bin - new[] - { - (byte) ':', (byte) '/', (byte) 'p', (byte) 'a', (byte) 's', (byte) 's', (byte) 'p', (byte) 'h', - (byte) 'r', (byte) 'a', (byte) 's', (byte) 'e', (byte) '.', (byte) 'b', (byte) 'i', (byte) 'n' - }; + /// ":/passphrase.bin" + private static ReadOnlySpan PassphrasePath => ":/passphrase.bin"u8; - private static ReadOnlySpan DeliveryListPath => // :/list.msgpack - new[] - { - (byte) ':', (byte) '/', (byte) 'l', (byte) 'i', (byte) 's', (byte) 't', (byte) '.', (byte) 'm', - (byte) 's', (byte) 'g', (byte) 'p', (byte) 'a', (byte) 'c', (byte) 'k' - }; + /// ":/list.msgpack" + private static ReadOnlySpan DeliveryListPath => ":/list.msgpack"u8; - private static ReadOnlySpan EtagPath => // :/etag.bin - new[] - { - (byte) ':', (byte) '/', (byte) 'e', (byte) 't', (byte) 'a', (byte) 'g', (byte) '.', (byte) 'b', - (byte) 'i', (byte) 'n' - }; + /// ":/etag.bin" + private static ReadOnlySpan EtagPath => ":/etag.bin"u8; - private static ReadOnlySpan NaRequiredPath => // :/na_required - new[] - { - (byte) ':', (byte) '/', (byte) 'n', (byte) 'a', (byte) '_', (byte) 'r', (byte) 'e', (byte) 'q', - (byte) 'u', (byte) 'i', (byte) 'r', (byte) 'e', (byte) 'd' - }; + /// ":/na_required" + private static ReadOnlySpan NaRequiredPath => ":/na_required"u8; - private static ReadOnlySpan IndexLockPath => // :/index.lock - new[] - { - (byte) ':', (byte) '/', (byte) 'i', (byte) 'n', (byte) 'd', (byte) 'e', (byte) 'x', (byte) '.', - (byte) 'l', (byte) 'o', (byte) 'c', (byte) 'k' - }; + /// ":/index.lock" + private static ReadOnlySpan IndexLockPath => ":/index.lock"u8; - private static ReadOnlySpan DirectoriesPath => // :/directories - new[] - { - (byte) ':', (byte) '/', (byte) 'd', (byte) 'i', (byte) 'r', (byte) 'e', (byte) 'c', (byte) 't', - (byte) 'o', (byte) 'r', (byte) 'i', (byte) 'e', (byte) 's' - }; + /// ":/directories" + private static ReadOnlySpan DirectoriesPath => ":/directories"u8; - private static ReadOnlySpan FilesMetaFileName => // files.meta - new[] - { - (byte) 'f', (byte) 'i', (byte) 'l', (byte) 'e', (byte) 's', (byte) '.', (byte) 'm', (byte) 'e', - (byte) 't', (byte) 'a' - }; + /// "files.meta" + private static ReadOnlySpan FilesMetaFileName => "files.meta"u8; - private static ReadOnlySpan DirectoriesMetaPath => // :/directories.meta - new[] - { - (byte) ':', (byte) '/', (byte) 'd', (byte) 'i', (byte) 'r', (byte) 'e', (byte) 'c', (byte) 't', - (byte) 'o', (byte) 'r', (byte) 'i', (byte) 'e', (byte) 's', (byte) '.', (byte) 'm', (byte) 'e', - (byte) 't', (byte) 'a' - }; + /// ":/directories.meta" + private static ReadOnlySpan DirectoriesMetaPath => ":/directories.meta"u8; - private static ReadOnlySpan FilesDirectoryName => // files - new[] { (byte)'f', (byte)'i', (byte)'l', (byte)'e', (byte)'s' }; + /// "files" + private static ReadOnlySpan FilesDirectoryName => "files"u8; } \ No newline at end of file diff --git a/src/LibHac/Boot/Package1.cs b/src/LibHac/Boot/Package1.cs index d8ea2b19..58199121 100644 --- a/src/LibHac/Boot/Package1.cs +++ b/src/LibHac/Boot/Package1.cs @@ -537,9 +537,5 @@ public class Package1 return (Package1Section)(-1); } - private static ReadOnlySpan LegacyDateCutoff => // 20181107 - new[] - { - (byte) '2', (byte) '0', (byte) '1', (byte) '8', (byte) '1', (byte) '1', (byte) '0', (byte) '7' - }; + private static ReadOnlySpan LegacyDateCutoff => "20181107"u8; } \ No newline at end of file diff --git a/src/LibHac/Diag/Log.cs b/src/LibHac/Diag/Log.cs index 71eedf45..1fffe3f4 100644 --- a/src/LibHac/Diag/Log.cs +++ b/src/LibHac/Diag/Log.cs @@ -45,5 +45,5 @@ public static class Log } /// "$" - public static ReadOnlySpan EmptyModuleName => new[] { (byte)'$' }; // "$" + public static ReadOnlySpan EmptyModuleName => "$"u8; } \ No newline at end of file diff --git a/src/LibHac/Fs/AccessLog.cs b/src/LibHac/Fs/AccessLog.cs index c4809167..cd565514 100644 --- a/src/LibHac/Fs/AccessLog.cs +++ b/src/LibHac/Fs/AccessLog.cs @@ -165,6 +165,7 @@ namespace LibHac.Fs.Impl private Buffer32 _buffer; [UnscopedRef] + [MethodImpl(MethodImplOptions.NoInlining)] private ReadOnlySpan ToValueString(int value) { bool success = Utf8Formatter.TryFormat(value, _buffer.Bytes, out int length); @@ -180,9 +181,9 @@ namespace LibHac.Fs.Impl { switch (value) { - case Priority.Realtime: return new[] { (byte)'R', (byte)'e', (byte)'a', (byte)'l', (byte)'t', (byte)'i', (byte)'m', (byte)'e' }; - case Priority.Normal: return new[] { (byte)'N', (byte)'o', (byte)'r', (byte)'m', (byte)'a', (byte)'l' }; - case Priority.Low: return new[] { (byte)'L', (byte)'o', (byte)'w' }; + case Priority.Realtime: return "Realtime"u8; + case Priority.Normal: return "Normal"u8; + case Priority.Low: return "Low"u8; default: return ToValueString((int)value); } } @@ -192,10 +193,10 @@ namespace LibHac.Fs.Impl { switch (value) { - case PriorityRaw.Realtime: return new[] { (byte)'R', (byte)'e', (byte)'a', (byte)'l', (byte)'t', (byte)'i', (byte)'m', (byte)'e' }; - case PriorityRaw.Normal: return new[] { (byte)'N', (byte)'o', (byte)'r', (byte)'m', (byte)'a', (byte)'l' }; - case PriorityRaw.Low: return new[] { (byte)'L', (byte)'o', (byte)'w' }; - case PriorityRaw.Background: return new[] { (byte)'B', (byte)'a', (byte)'c', (byte)'k', (byte)'g', (byte)'r', (byte)'o', (byte)'u', (byte)'n', (byte)'d' }; + case PriorityRaw.Realtime: return "Realtime"u8; + case PriorityRaw.Normal: return "Normal"u8; + case PriorityRaw.Low: return "Low"u8; + case PriorityRaw.Background: return "Background"u8; default: return ToValueString((int)value); } } @@ -205,8 +206,8 @@ namespace LibHac.Fs.Impl { switch (value) { - case ImageDirectoryId.Nand: return new[] { (byte)'N', (byte)'a', (byte)'n', (byte)'d' }; - case ImageDirectoryId.SdCard: return new[] { (byte)'S', (byte)'d', (byte)'C', (byte)'a', (byte)'r', (byte)'d' }; + case ImageDirectoryId.Nand: return "Nand"u8; + case ImageDirectoryId.SdCard: return "SdCard"u8; default: return ToValueString((int)value); } } @@ -216,9 +217,9 @@ namespace LibHac.Fs.Impl { switch (value) { - case ContentStorageId.System: return new[] { (byte)'S', (byte)'y', (byte)'s', (byte)'t', (byte)'e', (byte)'m' }; - case ContentStorageId.User: return new[] { (byte)'U', (byte)'s', (byte)'e', (byte)'r' }; - case ContentStorageId.SdCard: return new[] { (byte)'S', (byte)'d', (byte)'C', (byte)'a', (byte)'r', (byte)'d' }; + case ContentStorageId.System: return "System"u8; + case ContentStorageId.User: return "User"u8; + case ContentStorageId.SdCard: return "SdCard"u8; default: return ToValueString((int)value); } } @@ -228,10 +229,10 @@ namespace LibHac.Fs.Impl { switch (value) { - case GameCardPartition.Update: return new[] { (byte)'U', (byte)'p', (byte)'d', (byte)'a', (byte)'t', (byte)'e' }; - case GameCardPartition.Normal: return new[] { (byte)'N', (byte)'o', (byte)'r', (byte)'m', (byte)'a', (byte)'l' }; - case GameCardPartition.Secure: return new[] { (byte)'S', (byte)'e', (byte)'c', (byte)'u', (byte)'r', (byte)'e' }; - case GameCardPartition.Logo: return new[] { (byte)'L', (byte)'o', (byte)'g', (byte)'o' }; + case GameCardPartition.Update: return "Update"u8; + case GameCardPartition.Normal: return "Normal"u8; + case GameCardPartition.Secure: return "Secure"u8; + case GameCardPartition.Logo: return "Logo"u8; default: return ToValueString((int)value); } } @@ -241,10 +242,10 @@ namespace LibHac.Fs.Impl { switch (value) { - case SaveDataSpaceId.System: return new[] { (byte)'S', (byte)'y', (byte)'s', (byte)'t', (byte)'e', (byte)'m' }; - case SaveDataSpaceId.User: return new[] { (byte)'U', (byte)'s', (byte)'e', (byte)'r' }; - case SaveDataSpaceId.SdSystem: return new[] { (byte)'S', (byte)'d', (byte)'S', (byte)'y', (byte)'s', (byte)'t', (byte)'e', (byte)'m' }; - case SaveDataSpaceId.ProperSystem: return new[] { (byte)'P', (byte)'r', (byte)'o', (byte)'p', (byte)'e', (byte)'r', (byte)'S', (byte)'y', (byte)'s', (byte)'t', (byte)'e', (byte)'m' }; + case SaveDataSpaceId.System: return "System"u8; + case SaveDataSpaceId.User: return "User"u8; + case SaveDataSpaceId.SdSystem: return "SdSystem"u8; + case SaveDataSpaceId.ProperSystem: return "ProperSystem"u8; default: return ToValueString((int)value); } } @@ -254,8 +255,8 @@ namespace LibHac.Fs.Impl { switch (value) { - case SaveDataFormatType.Normal: return new[] { (byte)'N', (byte)'o', (byte)'r', (byte)'m', (byte)'a', (byte)'l' }; - case SaveDataFormatType.NoJournal: return new[] { (byte)'N', (byte)'o', (byte)'J', (byte)'o', (byte)'u', (byte)'r', (byte)'n', (byte)'a', (byte)'l' }; + case SaveDataFormatType.Normal: return "Normal"u8; + case SaveDataFormatType.NoJournal: return "NoJournal"u8; default: return ToValueString((int)value); } } @@ -265,11 +266,11 @@ namespace LibHac.Fs.Impl { switch (value) { - case ContentType.Meta: return new[] { (byte)'M', (byte)'e', (byte)'t', (byte)'a' }; - case ContentType.Control: return new[] { (byte)'C', (byte)'o', (byte)'n', (byte)'t', (byte)'r', (byte)'o', (byte)'l' }; - case ContentType.Manual: return new[] { (byte)'M', (byte)'a', (byte)'n', (byte)'u', (byte)'a', (byte)'l' }; - case ContentType.Logo: return new[] { (byte)'L', (byte)'o', (byte)'g', (byte)'o' }; - case ContentType.Data: return new[] { (byte)'D', (byte)'a', (byte)'t', (byte)'a' }; + case ContentType.Meta: return "Meta"u8; + case ContentType.Control: return "Control"u8; + case ContentType.Manual: return "Manual"u8; + case ContentType.Logo: return "Logo"u8; + case ContentType.Data: return "Data"u8; default: return ToValueString((int)value); } } @@ -279,23 +280,23 @@ namespace LibHac.Fs.Impl { switch (value) { - case BisPartitionId.BootPartition1Root: return new[] { (byte)'B', (byte)'o', (byte)'o', (byte)'t', (byte)'P', (byte)'a', (byte)'r', (byte)'t', (byte)'i', (byte)'t', (byte)'i', (byte)'o', (byte)'n', (byte)'1', (byte)'R', (byte)'o', (byte)'o', (byte)'t' }; - case BisPartitionId.BootPartition2Root: return new[] { (byte)'B', (byte)'o', (byte)'o', (byte)'t', (byte)'P', (byte)'a', (byte)'r', (byte)'t', (byte)'i', (byte)'t', (byte)'i', (byte)'o', (byte)'n', (byte)'2', (byte)'R', (byte)'o', (byte)'o', (byte)'t' }; - case BisPartitionId.UserDataRoot: return new[] { (byte)'U', (byte)'s', (byte)'e', (byte)'r', (byte)'D', (byte)'a', (byte)'t', (byte)'a', (byte)'R', (byte)'o', (byte)'o', (byte)'t' }; - case BisPartitionId.BootConfigAndPackage2Part1: return new[] { (byte)'B', (byte)'o', (byte)'o', (byte)'t', (byte)'C', (byte)'o', (byte)'n', (byte)'f', (byte)'i', (byte)'g', (byte)'A', (byte)'n', (byte)'d', (byte)'P', (byte)'a', (byte)'c', (byte)'k', (byte)'a', (byte)'g', (byte)'e', (byte)'2', (byte)'P', (byte)'a', (byte)'r', (byte)'t', (byte)'1' }; - case BisPartitionId.BootConfigAndPackage2Part2: return new[] { (byte)'B', (byte)'o', (byte)'o', (byte)'t', (byte)'C', (byte)'o', (byte)'n', (byte)'f', (byte)'i', (byte)'g', (byte)'A', (byte)'n', (byte)'d', (byte)'P', (byte)'a', (byte)'c', (byte)'k', (byte)'a', (byte)'g', (byte)'e', (byte)'2', (byte)'P', (byte)'a', (byte)'r', (byte)'t', (byte)'2' }; - case BisPartitionId.BootConfigAndPackage2Part3: return new[] { (byte)'B', (byte)'o', (byte)'o', (byte)'t', (byte)'C', (byte)'o', (byte)'n', (byte)'f', (byte)'i', (byte)'g', (byte)'A', (byte)'n', (byte)'d', (byte)'P', (byte)'a', (byte)'c', (byte)'k', (byte)'a', (byte)'g', (byte)'e', (byte)'2', (byte)'P', (byte)'a', (byte)'r', (byte)'t', (byte)'3' }; - case BisPartitionId.BootConfigAndPackage2Part4: return new[] { (byte)'B', (byte)'o', (byte)'o', (byte)'t', (byte)'C', (byte)'o', (byte)'n', (byte)'f', (byte)'i', (byte)'g', (byte)'A', (byte)'n', (byte)'d', (byte)'P', (byte)'a', (byte)'c', (byte)'k', (byte)'a', (byte)'g', (byte)'e', (byte)'2', (byte)'P', (byte)'a', (byte)'r', (byte)'t', (byte)'4' }; - case BisPartitionId.BootConfigAndPackage2Part5: return new[] { (byte)'B', (byte)'o', (byte)'o', (byte)'t', (byte)'C', (byte)'o', (byte)'n', (byte)'f', (byte)'i', (byte)'g', (byte)'A', (byte)'n', (byte)'d', (byte)'P', (byte)'a', (byte)'c', (byte)'k', (byte)'a', (byte)'g', (byte)'e', (byte)'2', (byte)'P', (byte)'a', (byte)'r', (byte)'t', (byte)'5' }; - case BisPartitionId.BootConfigAndPackage2Part6: return new[] { (byte)'B', (byte)'o', (byte)'o', (byte)'t', (byte)'C', (byte)'o', (byte)'n', (byte)'f', (byte)'i', (byte)'g', (byte)'A', (byte)'n', (byte)'d', (byte)'P', (byte)'a', (byte)'c', (byte)'k', (byte)'a', (byte)'g', (byte)'e', (byte)'2', (byte)'P', (byte)'a', (byte)'r', (byte)'t', (byte)'6' }; - case BisPartitionId.CalibrationBinary: return new[] { (byte)'C', (byte)'a', (byte)'l', (byte)'i', (byte)'b', (byte)'r', (byte)'a', (byte)'t', (byte)'i', (byte)'o', (byte)'n', (byte)'B', (byte)'i', (byte)'n', (byte)'a', (byte)'r', (byte)'y' }; - case BisPartitionId.CalibrationFile: return new[] { (byte)'C', (byte)'a', (byte)'l', (byte)'i', (byte)'b', (byte)'r', (byte)'a', (byte)'t', (byte)'i', (byte)'o', (byte)'n', (byte)'F', (byte)'i', (byte)'l', (byte)'e' }; - case BisPartitionId.SafeMode: return new[] { (byte)'S', (byte)'a', (byte)'f', (byte)'e', (byte)'M', (byte)'o', (byte)'d', (byte)'e' }; - case BisPartitionId.User: return new[] { (byte)'U', (byte)'s', (byte)'e', (byte)'r' }; - case BisPartitionId.System: return new[] { (byte)'S', (byte)'y', (byte)'s', (byte)'t', (byte)'e', (byte)'m' }; - case BisPartitionId.SystemProperEncryption: return new[] { (byte)'S', (byte)'y', (byte)'s', (byte)'t', (byte)'e', (byte)'m', (byte)'P', (byte)'r', (byte)'o', (byte)'p', (byte)'e', (byte)'r', (byte)'E', (byte)'n', (byte)'c', (byte)'r', (byte)'y', (byte)'p', (byte)'t', (byte)'i', (byte)'o', (byte)'n' }; - case BisPartitionId.SystemProperPartition: return new[] { (byte)'S', (byte)'y', (byte)'s', (byte)'t', (byte)'e', (byte)'m', (byte)'P', (byte)'r', (byte)'o', (byte)'p', (byte)'e', (byte)'r', (byte)'P', (byte)'a', (byte)'r', (byte)'t', (byte)'i', (byte)'t', (byte)'i', (byte)'o', (byte)'n' }; - case (BisPartitionId)35: return new[] { (byte)'I', (byte)'n', (byte)'v', (byte)'a', (byte)'l', (byte)'i', (byte)'d' }; + case BisPartitionId.BootPartition1Root: return "BootPartition1Root"u8; + case BisPartitionId.BootPartition2Root: return "BootPartition2Root"u8; + case BisPartitionId.UserDataRoot: return "UserDataRoot"u8; + case BisPartitionId.BootConfigAndPackage2Part1: return "BootConfigAndPackage2Part1"u8; + case BisPartitionId.BootConfigAndPackage2Part2: return "BootConfigAndPackage2Part2"u8; + case BisPartitionId.BootConfigAndPackage2Part3: return "BootConfigAndPackage2Part3"u8; + case BisPartitionId.BootConfigAndPackage2Part4: return "BootConfigAndPackage2Part4"u8; + case BisPartitionId.BootConfigAndPackage2Part5: return "BootConfigAndPackage2Part5"u8; + case BisPartitionId.BootConfigAndPackage2Part6: return "BootConfigAndPackage2Part6"u8; + case BisPartitionId.CalibrationBinary: return "CalibrationBinary"u8; + case BisPartitionId.CalibrationFile: return "CalibrationFile"u8; + case BisPartitionId.SafeMode: return "SafeMode"u8; + case BisPartitionId.User: return "User"u8; + case BisPartitionId.System: return "System"u8; + case BisPartitionId.SystemProperEncryption: return "SystemProperEncryption"u8; + case BisPartitionId.SystemProperPartition: return "SystemProperPartition"u8; + case (BisPartitionId)35: return "Invalid"u8; default: return ToValueString((int)value); } } @@ -305,8 +306,8 @@ namespace LibHac.Fs.Impl { switch (value) { - case DirectoryEntryType.Directory: return new[] { (byte)'D', (byte)'i', (byte)'r', (byte)'e', (byte)'c', (byte)'t', (byte)'o', (byte)'r', (byte)'y' }; - case DirectoryEntryType.File: return new[] { (byte)'F', (byte)'i', (byte)'l', (byte)'e' }; + case DirectoryEntryType.Directory: return "Directory"u8; + case DirectoryEntryType.File: return "File"u8; default: return ToValueString((int)value); } } @@ -316,7 +317,7 @@ namespace LibHac.Fs.Impl { switch (value.Flags) { - case MountHostOptionFlag.PseudoCaseSensitive: return new[] { (byte)'M', (byte)'o', (byte)'u', (byte)'n', (byte)'t', (byte)'H', (byte)'o', (byte)'s', (byte)'t', (byte)'O', (byte)'p', (byte)'t', (byte)'i', (byte)'o', (byte)'n', (byte)'F', (byte)'l', (byte)'a', (byte)'g', (byte)'_', (byte)'P', (byte)'s', (byte)'e', (byte)'u', (byte)'d', (byte)'o', (byte)'C', (byte)'a', (byte)'s', (byte)'e', (byte)'S', (byte)'e', (byte)'n', (byte)'s', (byte)'i', (byte)'t', (byte)'i', (byte)'v', (byte)'e' }; + case MountHostOptionFlag.PseudoCaseSensitive: return "MountHostOptionFlag_PseudoCaseSensitive"u8; default: return ToValueString((int)value.Flags); } } @@ -326,12 +327,12 @@ namespace LibHac.Fs.Impl { switch (value) { - case MemoryCapacity.Capacity1GB: return new[] { (byte)'1', (byte)'G', (byte)'B' }; - case MemoryCapacity.Capacity2GB: return new[] { (byte)'2', (byte)'G', (byte)'B' }; - case MemoryCapacity.Capacity4GB: return new[] { (byte)'4', (byte)'G', (byte)'B' }; - case MemoryCapacity.Capacity8GB: return new[] { (byte)'8', (byte)'G', (byte)'B' }; - case MemoryCapacity.Capacity16GB: return new[] { (byte)'1', (byte)'6', (byte)'G', (byte)'B' }; - case MemoryCapacity.Capacity32GB: return new[] { (byte)'3', (byte)'2', (byte)'G', (byte)'B' }; + case MemoryCapacity.Capacity1GB: return "1GB"u8; + case MemoryCapacity.Capacity2GB: return "2GB"u8; + case MemoryCapacity.Capacity4GB: return "4GB"u8; + case MemoryCapacity.Capacity8GB: return "8GB"u8; + case MemoryCapacity.Capacity16GB: return "16GB"u8; + case MemoryCapacity.Capacity32GB: return "32GB"u8; default: return ToValueString((int)value); } } @@ -341,8 +342,8 @@ namespace LibHac.Fs.Impl { switch (value) { - case SelSec.T1: return new[] { (byte)'T', (byte)'1' }; - case SelSec.T2: return new[] { (byte)'T', (byte)'2' }; + case SelSec.T1: return "T1"u8; + case SelSec.T2: return "T2"u8; default: return ToValueString((int)value); } } @@ -352,8 +353,8 @@ namespace LibHac.Fs.Impl { switch (value) { - case KekIndex.Version0: return new[] { (byte)'V', (byte)'e', (byte)'r', (byte)'s', (byte)'i', (byte)'o', (byte)'n', (byte)'0' }; - case KekIndex.ForDev: return new[] { (byte)'V', (byte)'e', (byte)'r', (byte)'s', (byte)'i', (byte)'o', (byte)'n', (byte)'F', (byte)'o', (byte)'r', (byte)'D', (byte)'e', (byte)'v' }; + case KekIndex.Version0: return "Version0"u8; + case KekIndex.ForDev: return "VersionForDev"u8; default: return ToValueString((int)value); } } @@ -363,8 +364,8 @@ namespace LibHac.Fs.Impl { switch (value) { - case AccessControl1ClockRate.ClockRate25MHz: return new[] { (byte)'2', (byte)'5', (byte)' ', (byte)'M', (byte)'H', (byte)'z' }; - case AccessControl1ClockRate.ClockRate50MHz: return new[] { (byte)'5', (byte)'0', (byte)' ', (byte)'M', (byte)'H', (byte)'z' }; + case AccessControl1ClockRate.ClockRate25MHz: return "25 MHz"u8; + case AccessControl1ClockRate.ClockRate50MHz: return "50 MHz"u8; default: return ToValueString((int)value); } } @@ -374,12 +375,12 @@ namespace LibHac.Fs.Impl { switch (value) { - case FwVersion.ForDev: return new[] { (byte)'F', (byte)'o', (byte)'r', (byte)'D', (byte)'e', (byte)'v' }; - case FwVersion.Since1_0_0: return new[] { (byte)'1', (byte)'.', (byte)'0', (byte)'.', (byte)'0' }; - case FwVersion.Since4_0_0: return new[] { (byte)'4', (byte)'.', (byte)'0', (byte)'.', (byte)'0' }; - case FwVersion.Since9_0_0: return new[] { (byte)'9', (byte)'.', (byte)'0', (byte)'.', (byte)'0' }; - case FwVersion.Since11_0_0: return new[] { (byte)'1', (byte)'1', (byte)'.', (byte)'0', (byte)'.', (byte)'0' }; - case FwVersion.Since12_0_0: return new[] { (byte)'1', (byte)'2', (byte)'.', (byte)'0', (byte)'.', (byte)'0' }; + case FwVersion.ForDev: return "ForDev"u8; + case FwVersion.Since1_0_0: return "1.0.0"u8; + case FwVersion.Since4_0_0: return "4.0.0"u8; + case FwVersion.Since9_0_0: return "9.0.0"u8; + case FwVersion.Since11_0_0: return "11.0.0"u8; + case FwVersion.Since12_0_0: return "12.0.0"u8; default: return ToValueString((int)value); } } @@ -389,8 +390,8 @@ namespace LibHac.Fs.Impl { switch (value) { - case GameCardCompatibilityType.Normal: return new[] { (byte)'N', (byte)'o', (byte)'r', (byte)'m', (byte)'a', (byte)'l' }; - case GameCardCompatibilityType.Terra: return new[] { (byte)'T', (byte)'e', (byte)'r', (byte)'r', (byte)'a' }; + case GameCardCompatibilityType.Normal: return "Normal"u8; + case GameCardCompatibilityType.Terra: return "Terra"u8; default: return ToValueString((int)value); } } @@ -828,456 +829,174 @@ namespace LibHac.Fs.Impl internal static class AccessLogStrings { /// "$fs" - public static ReadOnlySpan FsModuleName => // "$fs" - new[] { (byte)'$', (byte)'f', (byte)'s' }; + public static ReadOnlySpan FsModuleName => "$fs"u8; /// "0.17.0" - public static ReadOnlySpan LogLibHacVersion => // "0.17.0" - new[] - { - (byte)'0', (byte)'.', (byte)'1', (byte)'7', (byte)'.', (byte)'0' - }; + public static ReadOnlySpan LogLibHacVersion => "0.17.0"u8; /// """ public static byte LogQuote => (byte)'"'; /// "true" - public static ReadOnlySpan LogTrue => // "true" - new[] { (byte)'t', (byte)'r', (byte)'u', (byte)'e' }; + public static ReadOnlySpan LogTrue => "true"u8; /// "false" - public static ReadOnlySpan LogFalse => // "false" - new[] { (byte)'f', (byte)'a', (byte)'l', (byte)'s', (byte)'e' }; + public static ReadOnlySpan LogFalse => "false"u8; /// ", entry_buffer_count: " - public static ReadOnlySpan LogEntryBufferCount => // ", entry_buffer_count: " - new[] - { - (byte)',', (byte)' ', (byte)'e', (byte)'n', (byte)'t', (byte)'r', (byte)'y', (byte)'_', - (byte)'b', (byte)'u', (byte)'f', (byte)'f', (byte)'e', (byte)'r', (byte)'_', (byte)'c', - (byte)'o', (byte)'u', (byte)'n', (byte)'t', (byte)':', (byte)' ' - }; + public static ReadOnlySpan LogEntryBufferCount => ", entry_buffer_count: "u8; /// ", entry_count: " - public static ReadOnlySpan LogEntryCount => // ", entry_count: " - new[] - { - (byte)',', (byte)' ', (byte)'e', (byte)'n', (byte)'t', (byte)'r', (byte)'y', (byte)'_', - (byte)'c', (byte)'o', (byte)'u', (byte)'n', (byte)'t', (byte)':', (byte)' ' - }; + public static ReadOnlySpan LogEntryCount => ", entry_count: "u8; /// ", offset: " - public static ReadOnlySpan LogOffset => // ", offset: " - new[] - { - (byte)',', (byte)' ', (byte)'o', (byte)'f', (byte)'f', (byte)'s', (byte)'e', (byte)'t', - (byte)':', (byte)' ' - }; + public static ReadOnlySpan LogOffset => ", offset: "u8; /// ", size: " - public static ReadOnlySpan LogSize => // ", size: " - new[] - { - (byte)',', (byte)' ', (byte)'s', (byte)'i', (byte)'z', (byte)'e', (byte)':', (byte)' ' - }; + public static ReadOnlySpan LogSize => ", size: "u8; /// ", read_size: " - public static ReadOnlySpan LogReadSize => // ", read_size: " - new[] - { - (byte)',', (byte)' ', (byte)'r', (byte)'e', (byte)'a', (byte)'d', (byte)'_', (byte)'s', - (byte)'i', (byte)'z', (byte)'e', (byte)':', (byte)' ' - }; + public static ReadOnlySpan LogReadSize => ", read_size: "u8; /// ", write_option: Flush" - public static ReadOnlySpan LogWriteOptionFlush => // ", write_option: Flush" - new[] - { - (byte)',', (byte)' ', (byte)'w', (byte)'r', (byte)'i', (byte)'t', (byte)'e', (byte)'_', - (byte)'o', (byte)'p', (byte)'t', (byte)'i', (byte)'o', (byte)'n', (byte)':', (byte)' ', - (byte)'F', (byte)'l', (byte)'u', (byte)'s', (byte)'h' - }; + public static ReadOnlySpan LogWriteOptionFlush => ", write_option: Flush"u8; /// ", open_mode: 0x" - public static ReadOnlySpan LogOpenMode => // ", open_mode: 0x" - new[] - { - (byte)',', (byte)' ', (byte)'o', (byte)'p', (byte)'e', (byte)'n', (byte)'_', (byte)'m', - (byte)'o', (byte)'d', (byte)'e', (byte)':', (byte)' ', (byte)'0', (byte)'x' - }; + public static ReadOnlySpan LogOpenMode => ", open_mode: 0x"u8; /// ", path: "" - public static ReadOnlySpan LogPath => // ", path: "" - new[] - { - (byte)',', (byte)' ', (byte)'p', (byte)'a', (byte)'t', (byte)'h', (byte)':', (byte)' ', - (byte)'"' - }; + public static ReadOnlySpan LogPath => ", path: \""u8; /// "", new_path: "" - public static ReadOnlySpan LogNewPath => // "", new_path: "" - new[] - { - (byte)'"', (byte)',', (byte)' ', (byte)'n', (byte)'e', (byte)'w', (byte)'_', (byte)'p', - (byte)'a', (byte)'t', (byte)'h', (byte)':', (byte)' ', (byte)'"' - }; + public static ReadOnlySpan LogNewPath => "\", new_path: \""u8; /// "", entry_type: " - public static ReadOnlySpan LogEntryType => // "", entry_type: " - new[] - { - (byte)'"', (byte)',', (byte)' ', (byte)'e', (byte)'n', (byte)'t', (byte)'r', (byte)'y', - (byte)'_', (byte)'t', (byte)'y', (byte)'p', (byte)'e', (byte)':', (byte)' ' - }; + public static ReadOnlySpan LogEntryType => "\", entry_type: "u8; /// ", name: "" - public static ReadOnlySpan LogName => // ", name: "" - new[] - { - (byte)',', (byte)' ', (byte)'n', (byte)'a', (byte)'m', (byte)'e', (byte)':', (byte)' ', - (byte)'"' - }; + public static ReadOnlySpan LogName => ", name: \""u8; /// "", commit_option: 0x" - public static ReadOnlySpan LogCommitOption => // "", commit_option: 0x" - new[] - { - (byte)'"', (byte)',', (byte)' ', (byte)'c', (byte)'o', (byte)'m', (byte)'m', (byte)'i', - (byte)'t', (byte)'_', (byte)'o', (byte)'p', (byte)'t', (byte)'i', (byte)'o', (byte)'n', - (byte)':', (byte)' ', (byte)'0', (byte)'x' - }; + public static ReadOnlySpan LogCommitOption => "\", commit_option: 0x"u8; /// "", is_mounted: "" - public static ReadOnlySpan LogIsMounted => // "", is_mounted: "" - new[] - { - (byte)'"', (byte)',', (byte)' ', (byte)'i', (byte)'s', (byte)'_', (byte)'m', (byte)'o', - (byte)'u', (byte)'n', (byte)'t', (byte)'e', (byte)'d', (byte)':', (byte)' ', (byte)'"' - }; + public static ReadOnlySpan LogIsMounted => "\", is_mounted: \""u8; /// ", applicationid: 0x" - public static ReadOnlySpan LogApplicationId => // ", applicationid: 0x" - new[] - { - (byte)',', (byte)' ', (byte)'a', (byte)'p', (byte)'p', (byte)'l', (byte)'i', (byte)'c', - (byte)'a', (byte)'t', (byte)'i', (byte)'o', (byte)'n', (byte)'i', (byte)'d', (byte)':', - (byte)' ', (byte)'0', (byte)'x' - }; + public static ReadOnlySpan LogApplicationId => ", applicationid: 0x"u8; /// ", programid: 0x" - public static ReadOnlySpan LogProgramId => // ", programid: 0x" - new[] - { - (byte)',', (byte)' ', (byte)'p', (byte)'r', (byte)'o', (byte)'g', (byte)'r', (byte)'a', - (byte)'m', (byte)'i', (byte)'d', (byte)':', (byte)' ', (byte)'0', (byte)'x' - }; + public static ReadOnlySpan LogProgramId => ", programid: 0x"u8; /// ", dataid: 0x" - public static ReadOnlySpan LogDataId => // ", dataid: 0x" - new[] - { - (byte)',', (byte)' ', (byte)'d', (byte)'a', (byte)'t', (byte)'a', (byte)'i', (byte)'d', - (byte)':', (byte)' ', (byte)'0', (byte)'x' - }; + public static ReadOnlySpan LogDataId => ", dataid: 0x"u8; /// ", bispartitionid: " - public static ReadOnlySpan LogBisPartitionId => // ", bispartitionid: " - new[] - { - (byte)',', (byte)' ', (byte)'b', (byte)'i', (byte)'s', (byte)'p', (byte)'a', (byte)'r', - (byte)'t', (byte)'i', (byte)'t', (byte)'i', (byte)'o', (byte)'n', (byte)'i', (byte)'d', - (byte)':', (byte)' ' - }; + public static ReadOnlySpan LogBisPartitionId => ", bispartitionid: "u8; /// ", content_type: " - public static ReadOnlySpan LogContentType => // ", content_type: " - new[] - { - (byte)',', (byte)' ', (byte)'c', (byte)'o', (byte)'n', (byte)'t', (byte)'e', (byte)'n', - (byte)'t', (byte)'_', (byte)'t', (byte)'y', (byte)'p', (byte)'e', (byte)':', (byte)' ' - }; + public static ReadOnlySpan LogContentType => ", content_type: "u8; /// ", contentstorageid: " - public static ReadOnlySpan LogContentStorageId => // ", contentstorageid: " - new[] - { - (byte)',', (byte)' ', (byte)'c', (byte)'o', (byte)'n', (byte)'t', (byte)'e', (byte)'n', - (byte)'t', (byte)'s', (byte)'t', (byte)'o', (byte)'r', (byte)'a', (byte)'g', (byte)'e', - (byte)'i', (byte)'d', (byte)':', (byte)' ' - }; + public static ReadOnlySpan LogContentStorageId => ", contentstorageid: "u8; /// ", imagedirectoryid: " - public static ReadOnlySpan LogImageDirectoryId => // ", imagedirectoryid: " - new[] - { - (byte)',', (byte)' ', (byte)'i', (byte)'m', (byte)'a', (byte)'g', (byte)'e', (byte)'d', - (byte)'i', (byte)'r', (byte)'e', (byte)'c', (byte)'t', (byte)'o', (byte)'r', (byte)'y', - (byte)'i', (byte)'d', (byte)':', (byte)' ' - }; + public static ReadOnlySpan LogImageDirectoryId => ", imagedirectoryid: "u8; /// ", gamecard_handle: 0x" - public static ReadOnlySpan LogGameCardHandle => // ", gamecard_handle: 0x" - new[] - { - (byte)',', (byte)' ', (byte)'g', (byte)'a', (byte)'m', (byte)'e', (byte)'c', (byte)'a', - (byte)'r', (byte)'d', (byte)'_', (byte)'h', (byte)'a', (byte)'n', (byte)'d', (byte)'l', - (byte)'e', (byte)':', (byte)' ', (byte)'0', (byte)'x' - }; + public static ReadOnlySpan LogGameCardHandle => ", gamecard_handle: 0x"u8; /// ", gamecard_partition: " - public static ReadOnlySpan LogGameCardPartition => // ", gamecard_partition: " - new[] - { - (byte)',', (byte)' ', (byte)'g', (byte)'a', (byte)'m', (byte)'e', (byte)'c', (byte)'a', - (byte)'r', (byte)'d', (byte)'_', (byte)'p', (byte)'a', (byte)'r', (byte)'t', (byte)'i', - (byte)'t', (byte)'i', (byte)'o', (byte)'n', (byte)':', (byte)' ' - }; + public static ReadOnlySpan LogGameCardPartition => ", gamecard_partition: "u8; /// ", mount_host_option: " - public static ReadOnlySpan LogMountHostOption => // ", mount_host_option: " - new[] - { - (byte)',', (byte)' ', (byte)'m', (byte)'o', (byte)'u', (byte)'n', (byte)'t', (byte)'_', - (byte)'h', (byte)'o', (byte)'s', (byte)'t', (byte)'_', (byte)'o', (byte)'p', (byte)'t', - (byte)'i', (byte)'o', (byte)'n', (byte)':', (byte)' ' - }; + public static ReadOnlySpan LogMountHostOption => ", mount_host_option: "u8; /// ", root_path: "" - public static ReadOnlySpan LogRootPath => // ", root_path: "" - new[] - { - (byte)',', (byte)' ', (byte)'r', (byte)'o', (byte)'o', (byte)'t', (byte)'_', (byte)'p', - (byte)'a', (byte)'t', (byte)'h', (byte)':', (byte)' ', (byte)'"' - }; + public static ReadOnlySpan LogRootPath => ", root_path: \""u8; /// ", userid: 0x" - public static ReadOnlySpan LogUserId => // ", userid: 0x" - new[] - { - (byte)',', (byte)' ', (byte)'u', (byte)'s', (byte)'e', (byte)'r', (byte)'i', (byte)'d', - (byte)':', (byte)' ', (byte)'0', (byte)'x' - }; + public static ReadOnlySpan LogUserId => ", userid: 0x"u8; /// ", index: " - public static ReadOnlySpan LogIndex => // ", index: " - new[] - { - (byte)',', (byte)' ', (byte)'i', (byte)'n', (byte)'d', (byte)'e', (byte)'x', (byte)':', - (byte)' ' - }; + public static ReadOnlySpan LogIndex => ", index: "u8; /// ", save_data_owner_id: 0x" - public static ReadOnlySpan LogSaveDataOwnerId => // ", save_data_owner_id: 0x" - new[] - { - (byte)',', (byte)' ', (byte)'s', (byte)'a', (byte)'v', (byte)'e', (byte)'_', (byte)'d', - (byte)'a', (byte)'t', (byte)'a', (byte)'_', (byte)'o', (byte)'w', (byte)'n', (byte)'e', - (byte)'r', (byte)'_', (byte)'i', (byte)'d', (byte)':', (byte)' ', (byte)'0', (byte)'x' - }; + public static ReadOnlySpan LogSaveDataOwnerId => ", save_data_owner_id: 0x"u8; /// ", save_data_size: " - public static ReadOnlySpan LogSaveDataSize => // ", save_data_size: " - new[] - { - (byte)',', (byte)' ', (byte)'s', (byte)'a', (byte)'v', (byte)'e', (byte)'_', (byte)'d', - (byte)'a', (byte)'t', (byte)'a', (byte)'_', (byte)'s', (byte)'i', (byte)'z', (byte)'e', - (byte)':', (byte)' ' - }; + public static ReadOnlySpan LogSaveDataSize => ", save_data_size: "u8; /// ", save_data_journal_size: " - public static ReadOnlySpan LogSaveDataJournalSize => // ", save_data_journal_size: " - new[] - { - (byte)',', (byte)' ', (byte)'s', (byte)'a', (byte)'v', (byte)'e', (byte)'_', (byte)'d', - (byte)'a', (byte)'t', (byte)'a', (byte)'_', (byte)'j', (byte)'o', (byte)'u', (byte)'r', - (byte)'n', (byte)'a', (byte)'l', (byte)'_', (byte)'s', (byte)'i', (byte)'z', (byte)'e', - (byte)':', (byte)' ' - }; + public static ReadOnlySpan LogSaveDataJournalSize => ", save_data_journal_size: "u8; /// ", save_data_flags: 0x" - public static ReadOnlySpan LogSaveDataFlags => // ", save_data_flags: 0x" - new[] - { - (byte)',', (byte)' ', (byte)'s', (byte)'a', (byte)'v', (byte)'e', (byte)'_', (byte)'d', - (byte)'a', (byte)'t', (byte)'a', (byte)'_', (byte)'f', (byte)'l', (byte)'a', (byte)'g', - (byte)'s', (byte)':', (byte)' ', (byte)'0', (byte)'x' - }; + public static ReadOnlySpan LogSaveDataFlags => ", save_data_flags: 0x"u8; /// ", savedataid: 0x" - public static ReadOnlySpan LogSaveDataId => // ", savedataid: 0x" - new[] - { - (byte)',', (byte)' ', (byte)'s', (byte)'a', (byte)'v', (byte)'e', (byte)'d', (byte)'a', - (byte)'t', (byte)'a', (byte)'i', (byte)'d', (byte)':', (byte)' ', (byte)'0', (byte)'x' - }; + public static ReadOnlySpan LogSaveDataId => ", savedataid: 0x"u8; /// ", savedataspaceid: " - public static ReadOnlySpan LogSaveDataSpaceId => // ", savedataspaceid: " - new[] - { - (byte)',', (byte)' ', (byte)'s', (byte)'a', (byte)'v', (byte)'e', (byte)'d', (byte)'a', - (byte)'t', (byte)'a', (byte)'s', (byte)'p', (byte)'a', (byte)'c', (byte)'e', (byte)'i', - (byte)'d', (byte)':', (byte)' ' - }; + public static ReadOnlySpan LogSaveDataSpaceId => ", savedataspaceid: "u8; /// ", save_data_format_type: " - public static ReadOnlySpan LogSaveDataFormatType => // ", save_data_format_type: " - new[] - { - (byte)',', (byte)' ', (byte)'s', (byte)'a', (byte)'v', (byte)'e', (byte)'_', (byte)'d', - (byte)'a', (byte)'t', (byte)'a', (byte)'_', (byte)'f', (byte)'o', (byte)'r', (byte)'m', - (byte)'a', (byte)'t', (byte)'_', (byte)'t', (byte)'y', (byte)'p', (byte)'e', (byte)':', - (byte)' ' - }; + public static ReadOnlySpan LogSaveDataFormatType => ", save_data_format_type: "u8; /// ", save_data_time_stamp: " - public static ReadOnlySpan LogSaveDataTimeStamp => // ", save_data_time_stamp: " - new[] - { - (byte)',', (byte)' ', (byte)'s', (byte)'a', (byte)'v', (byte)'e', (byte)'_', (byte)'d', - (byte)'a', (byte)'t', (byte)'a', (byte)'_', (byte)'t', (byte)'i', (byte)'m', (byte)'e', - (byte)'_', (byte)'s', (byte)'t', (byte)'a', (byte)'m', (byte)'p', (byte)':', (byte)' ' - }; + public static ReadOnlySpan LogSaveDataTimeStamp => ", save_data_time_stamp: "u8; /// ", save_data_commit_id: 0x" - public static ReadOnlySpan LogSaveDataCommitId => // ", save_data_commit_id: 0x" - new[] - { - (byte)',', (byte)' ', (byte)'s', (byte)'a', (byte)'v', (byte)'e', (byte)'_', (byte)'d', - (byte)'a', (byte)'t', (byte)'a', (byte)'_', (byte)'c', (byte)'o', (byte)'m', (byte)'m', - (byte)'i', (byte)'t', (byte)'_', (byte)'i', (byte)'d', (byte)':', (byte)' ', (byte)'0', - (byte)'x' - }; + public static ReadOnlySpan LogSaveDataCommitId => ", save_data_commit_id: 0x"u8; /// ", restore_flag: " - public static ReadOnlySpan LogRestoreFlag => // ", restore_flag: " - new[] - { - (byte)',', (byte)' ', (byte)'r', (byte)'e', (byte)'s', (byte)'t', (byte)'o', (byte)'r', - (byte)'e', (byte)'_', (byte)'f', (byte)'l', (byte)'a', (byte)'g', (byte)':', (byte)' ' - }; + public static ReadOnlySpan LogRestoreFlag => ", restore_flag: "u8; /// "sdk_version: " - public static ReadOnlySpan LogSdkVersion => // "sdk_version: " - new[] - { - (byte)'s', (byte)'d', (byte)'k', (byte)'_', (byte)'v', (byte)'e', (byte)'r', (byte)'s', - (byte)'i', (byte)'o', (byte)'n', (byte)':', (byte)' ' - }; + public static ReadOnlySpan LogSdkVersion => "sdk_version: "u8; /// ", spec: " - public static ReadOnlySpan LogSpec => // ", spec: " - new[] - { - (byte)',', (byte)' ', (byte)'s', (byte)'p', (byte)'e', (byte)'c', (byte)':', (byte)' ' - }; + public static ReadOnlySpan LogSpec => ", spec: "u8; /// "NX" - public static ReadOnlySpan LogNx => // "NX" - new[] { (byte)'N', (byte)'X' }; + public static ReadOnlySpan LogNx => "NX"u8; /// ", program_index: " - public static ReadOnlySpan LogProgramIndex => // ", program_index: " - new[] - { - (byte)',', (byte)' ', (byte)'p', (byte)'r', (byte)'o', (byte)'g', (byte)'r', (byte)'a', - (byte)'m', (byte)'_', (byte)'i', (byte)'n', (byte)'d', (byte)'e', (byte)'x', (byte)':', - (byte)' ' - }; + public static ReadOnlySpan LogProgramIndex => ", program_index: "u8; /// ", for_system: true" - public static ReadOnlySpan LogForSystem => // ", for_system: true" - new[] - { - (byte)',', (byte)' ', (byte)'f', (byte)'o', (byte)'r', (byte)'_', (byte)'s', (byte)'y', - (byte)'s', (byte)'t', (byte)'e', (byte)'m', (byte)':', (byte)' ', (byte)'t', (byte)'r', - (byte)'u', (byte)'e' - }; + public static ReadOnlySpan LogForSystem => ", for_system: true"u8; /// ""FS_ACCESS: { " - public static ReadOnlySpan LogLineStart => // "FS_ACCESS: { " - new[] - { - (byte)'F', (byte)'S', (byte)'_', (byte)'A', (byte)'C', (byte)'C', (byte)'E', (byte)'S', - (byte)'S', (byte)':', (byte)' ', (byte)'{', (byte)' ' - }; + public static ReadOnlySpan LogLineStart => "FS_ACCESS: { "u8; /// " }\n" - public static ReadOnlySpan LogLineEnd => // " }\n" - new[] { (byte)' ', (byte)'}', (byte)'\n' }; + public static ReadOnlySpan LogLineEnd => " }\n"u8; /// "start: " - public static ReadOnlySpan LogStart => // "start: " - new[] - { - (byte)'s', (byte)'t', (byte)'a', (byte)'r', (byte)'t', (byte)':', (byte)' ' - }; + public static ReadOnlySpan LogStart => "start: "u8; /// ", end: " - public static ReadOnlySpan LogEnd => // ", end: " - new[] - { - (byte)',', (byte)' ', (byte)'e', (byte)'n', (byte)'d', (byte)':', (byte)' ' - }; + public static ReadOnlySpan LogEnd => ", end: "u8; /// ", result: 0x" - public static ReadOnlySpan LogResult => // ", result: 0x" - new[] - { - (byte)',', (byte)' ', (byte)'r', (byte)'e', (byte)'s', (byte)'u', (byte)'l', (byte)'t', - (byte)':', (byte)' ', (byte)'0', (byte)'x' - }; + public static ReadOnlySpan LogResult => ", result: 0x"u8; /// ", handle: 0x" - public static ReadOnlySpan LogHandle => // ", handle: 0x" - new[] - { - (byte)',', (byte)' ', (byte)'h', (byte)'a', (byte)'n', (byte)'d', (byte)'l', (byte)'e', - (byte)':', (byte)' ', (byte)'0', (byte)'x' - }; + public static ReadOnlySpan LogHandle => ", handle: 0x"u8; /// ", priority: " - public static ReadOnlySpan LogPriority => // ", priority: " - new[] - { - (byte)',', (byte)' ', (byte)'p', (byte)'r', (byte)'i', (byte)'o', (byte)'r', (byte)'i', - (byte)'t', (byte)'y', (byte)':', (byte)' ' - }; + public static ReadOnlySpan LogPriority => ", priority: "u8; /// ", function: "" - public static ReadOnlySpan LogFunction => // ", function: "" - new[] - { - (byte)',', (byte)' ', (byte)'f', (byte)'u', (byte)'n', (byte)'c', (byte)'t', (byte)'i', - (byte)'o', (byte)'n', (byte)':', (byte)' ', (byte)'"' - }; + public static ReadOnlySpan LogFunction => ", function: \""u8; /// ", cachestoragelist_handle: 0x" - public static ReadOnlySpan LogCacheStorageListHandle => - new[] - { - (byte)',', (byte)' ', (byte)'c', (byte)'a', (byte)'c', (byte)'h', (byte)'e', (byte)'s', - (byte)'t', (byte)'o', (byte)'r', (byte)'a', (byte)'g', (byte)'e', (byte)'l', (byte)'i', - (byte)'s', (byte)'t', (byte)'_', (byte)'h', (byte)'a', (byte)'n', (byte)'d', (byte)'l', - (byte)'e', (byte)':', (byte)' ', (byte)'0', (byte)'x' - }; + public static ReadOnlySpan LogCacheStorageListHandle => ", cachestoragelist_handle: 0x"u8; /// ", infobuffercount: 0x" - public static ReadOnlySpan LogInfoBufferCount => - new[] - { - (byte)',', (byte)' ', (byte)'i', (byte)'n', (byte)'f', (byte)'o', (byte)'b', (byte)'u', - (byte)'f', (byte)'f', (byte)'e', (byte)'r', (byte)'c', (byte)'o', (byte)'u', (byte)'n', - (byte)'t', (byte)':', (byte)' ', (byte)'0', (byte)'x' - }; + public static ReadOnlySpan LogInfoBufferCount => ", infobuffercount: 0x"u8; /// ", cache_storage_count: " - public static ReadOnlySpan LogCacheStorageCount => - new[] - { - (byte)',', (byte)' ', (byte)'c', (byte)'a', (byte)'c', (byte)'h', (byte)'e', (byte)'_', - (byte)'s', (byte)'t', (byte)'o', (byte)'r', (byte)'a', (byte)'g', (byte)'e', (byte)'_', - (byte)'c', (byte)'o', (byte)'u', (byte)'n', (byte)'t', (byte)':', (byte)' ' - }; + public static ReadOnlySpan LogCacheStorageCount => ", cache_storage_count: "u8; } } \ No newline at end of file diff --git a/src/LibHac/Fs/Common/Path.cs b/src/LibHac/Fs/Common/Path.cs index 353ffe8f..6009689c 100644 --- a/src/LibHac/Fs/Common/Path.cs +++ b/src/LibHac/Fs/Common/Path.cs @@ -673,7 +673,7 @@ public ref struct Path Span writeBuffer = GetWriteBuffer(); - ReadOnlySpan search = new[] { (byte)':', (byte)'/', (byte)'/', (byte)'/' }; // ":///" + ReadOnlySpan search = ":///"u8; int index = StringUtils.Find(writeBuffer, search); if (index >= 0) { @@ -681,8 +681,7 @@ public ref struct Path writeBuffer[index + 3] = AltDirectorySeparator; } - ReadOnlySpan hostMountUnc = new[] // "@Host://" - { (byte)'@', (byte)'H', (byte)'o', (byte)'s', (byte)'t', (byte)':', (byte)'/', (byte)'/' }; + ReadOnlySpan hostMountUnc = "@Host://"u8; if (StringUtils.Compare(writeBuffer, hostMountUnc, 8) == 0) { writeBuffer[6] = AltDirectorySeparator; @@ -1258,7 +1257,7 @@ public static class PathFunctions /// : was too small to contain the built path. internal static Result SetUpFixedPathSaveMetaName(scoped ref Path path, Span pathBuffer, uint metaType) { - ReadOnlySpan metaExtension = new[] { (byte)'.', (byte)'m', (byte)'e', (byte)'t', (byte)'a' }; // ".meta" + ReadOnlySpan metaExtension = ".meta"u8; var sb = new U8StringBuilder(pathBuffer); sb.Append((byte)'/').AppendFormat(metaType, 'x', 8).Append(metaExtension); @@ -1280,11 +1279,7 @@ public static class PathFunctions /// : was too small to contain the built path. internal static Result SetUpFixedPathSaveMetaDir(scoped ref Path path, Span pathBuffer, ulong saveDataId) { - ReadOnlySpan metaDirectoryName = new[] - { - (byte)'/', (byte)'s', (byte)'a', (byte)'v', (byte)'e', (byte)'M', (byte)'e', (byte)'t', - (byte)'a', (byte)'/' - }; + ReadOnlySpan metaDirectoryName = "/saveMeta/"u8; var sb = new U8StringBuilder(pathBuffer); sb.Append(metaDirectoryName).AppendFormat(saveDataId, 'x', 16); diff --git a/src/LibHac/Fs/Common/PathFormatter.cs b/src/LibHac/Fs/Common/PathFormatter.cs index 6f5a8c72..4636e467 100644 --- a/src/LibHac/Fs/Common/PathFormatter.cs +++ b/src/LibHac/Fs/Common/PathFormatter.cs @@ -16,15 +16,9 @@ namespace LibHac.Fs; /// Based on nnSdk 13.4.0 (FS 13.1.0) public static class PathFormatter { - private static ReadOnlySpan InvalidCharacter => - new[] { (byte)':', (byte)'*', (byte)'?', (byte)'<', (byte)'>', (byte)'|' }; - - private static ReadOnlySpan InvalidCharacterForHostName => - new[] { (byte)':', (byte)'*', (byte)'<', (byte)'>', (byte)'|', (byte)'$' }; - - private static ReadOnlySpan InvalidCharacterForMountName => - new[] { (byte)'*', (byte)'?', (byte)'<', (byte)'>', (byte)'|' }; - + private static ReadOnlySpan InvalidCharacter => ":*?<>|"u8; + private static ReadOnlySpan InvalidCharacterForHostName => ":*<>|$"u8; + private static ReadOnlySpan InvalidCharacterForMountName => "*?<>|"u8; [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Result CheckHostName(ReadOnlySpan name) diff --git a/src/LibHac/Fs/Common/PathUtility.cs b/src/LibHac/Fs/Common/PathUtility.cs index 70981d0e..7b363caa 100644 --- a/src/LibHac/Fs/Common/PathUtility.cs +++ b/src/LibHac/Fs/Common/PathUtility.cs @@ -126,8 +126,7 @@ public static class PathUtility /* The optimized code is equivalent to this: - ReadOnlySpan invalidChars = new[] - {(byte) ':', (byte) '*', (byte) '?', (byte) '<', (byte) '>', (byte) '|'}; + ReadOnlySpan invalidChars = ":*?<>|"u8; for (int i = 0; i < invalidChars.Length; i++) { diff --git a/src/LibHac/Fs/CommonPaths.cs b/src/LibHac/Fs/CommonPaths.cs index 333cfeab..c2f3305b 100644 --- a/src/LibHac/Fs/CommonPaths.cs +++ b/src/LibHac/Fs/CommonPaths.cs @@ -24,9 +24,5 @@ internal static class CommonPaths public const char GameCardFileSystemMountNameNormalSuffix = 'N'; public const char GameCardFileSystemMountNameSecureSuffix = 'S'; - public static ReadOnlySpan SdCardNintendoRootDirectoryName => // Nintendo - new[] - { - (byte)'N', (byte)'i', (byte)'n', (byte)'t', (byte)'e', (byte)'n', (byte)'d', (byte)'o' - }; + public static ReadOnlySpan SdCardNintendoRootDirectoryName => "Nintendo"u8; } \ No newline at end of file diff --git a/src/LibHac/Fs/Fsa/FileSystemAccessor.cs b/src/LibHac/Fs/Fsa/FileSystemAccessor.cs index 362dd0a2..6286e889 100644 --- a/src/LibHac/Fs/Fsa/FileSystemAccessor.cs +++ b/src/LibHac/Fs/Fsa/FileSystemAccessor.cs @@ -527,107 +527,46 @@ internal class FileSystemAccessor : IDisposable } /// "$fs" - private static ReadOnlySpan LogFsModuleName => new[] { (byte)'$', (byte)'f', (byte)'s' }; // "$fs" + private static ReadOnlySpan LogFsModuleName => "$fs"u8; /// "------ FS ERROR INFORMATION ------\n" - private static ReadOnlySpan LogFsErrorInfo => // "------ FS ERROR INFORMATION ------\n" - new[] - { - (byte)'-', (byte)'-', (byte)'-', (byte)'-', (byte)'-', (byte)'-', (byte)' ', (byte)'F', - (byte)'S', (byte)' ', (byte)'E', (byte)'R', (byte)'R', (byte)'O', (byte)'R', (byte)' ', - (byte)'I', (byte)'N', (byte)'F', (byte)'O', (byte)'R', (byte)'M', (byte)'A', (byte)'T', - (byte)'I', (byte)'O', (byte)'N', (byte)' ', (byte)'-', (byte)'-', (byte)'-', (byte)'-', - (byte)'-', (byte)'-', (byte)'\n' - }; + private static ReadOnlySpan LogFsErrorInfo => "------ FS ERROR INFORMATION ------\n"u8; /// "Error: File not closed" - private static ReadOnlySpan LogFileNotClosed => // "Error: File not closed" - new[] - { - (byte)'E', (byte)'r', (byte)'r', (byte)'o', (byte)'r', (byte)':', (byte)' ', (byte)'F', - (byte)'i', (byte)'l', (byte)'e', (byte)' ', (byte)'n', (byte)'o', (byte)'t', (byte)' ', - (byte)'c', (byte)'l', (byte)'o', (byte)'s', (byte)'e', (byte)'d' - }; + private static ReadOnlySpan LogFileNotClosed => "Error: File not closed"u8; /// "Error: Directory not closed" - private static ReadOnlySpan LogDirectoryNotClosed => // "Error: Directory not closed" - new[] - { - (byte)'E', (byte)'r', (byte)'r', (byte)'o', (byte)'r', (byte)':', (byte)' ', (byte)'D', - (byte)'i', (byte)'r', (byte)'e', (byte)'c', (byte)'t', (byte)'o', (byte)'r', (byte)'y', - (byte)' ', (byte)'n', (byte)'o', (byte)'t', (byte)' ', (byte)'c', (byte)'l', (byte)'o', - (byte)'s', (byte)'e', (byte)'d' - }; + private static ReadOnlySpan LogDirectoryNotClosed => "Error: Directory not closed"u8; /// " (mount_name: "" - private static ReadOnlySpan LogMountName => // " (mount_name: "" - new[] - { - (byte)' ', (byte)'(', (byte)'m', (byte)'o', (byte)'u', (byte)'n', (byte)'t', (byte)'_', - (byte)'n', (byte)'a', (byte)'m', (byte)'e', (byte)':', (byte)' ', (byte)'"' - }; + private static ReadOnlySpan LogMountName => " (mount_name: \""u8; /// "", count: " - private static ReadOnlySpan LogCount => // "", count: " - new[] - { - (byte)'"', (byte)',', (byte)' ', (byte)'c', (byte)'o', (byte)'u', (byte)'n', (byte)'t', - (byte)':', (byte)' ' - }; + private static ReadOnlySpan LogCount => "\", count: "u8; /// ")\n" - public static ReadOnlySpan LogLineEnd => new[] { (byte)')', (byte)'\n' }; // ")\n" + public static ReadOnlySpan LogLineEnd => ")\n"u8; /// " | " - public static ReadOnlySpan LogOrOperator => new[] { (byte)' ', (byte)'|', (byte)' ' }; // " | " + public static ReadOnlySpan LogOrOperator => " | "u8; /// "OpenMode_Read" - private static ReadOnlySpan LogOpenModeRead => // "OpenMode_Read" - new[] - { - (byte)'O', (byte)'p', (byte)'e', (byte)'n', (byte)'M', (byte)'o', (byte)'d', (byte)'e', - (byte)'_', (byte)'R', (byte)'e', (byte)'a', (byte)'d' - }; + private static ReadOnlySpan LogOpenModeRead => "OpenMode_Read"u8; /// "OpenMode_Write" - private static ReadOnlySpan LogOpenModeWrite => // "OpenMode_Write" - new[] - { - (byte)'O', (byte)'p', (byte)'e', (byte)'n', (byte)'M', (byte)'o', (byte)'d', (byte)'e', - (byte)'_', (byte)'W', (byte)'r', (byte)'i', (byte)'t', (byte)'e' - }; + private static ReadOnlySpan LogOpenModeWrite => "OpenMode_Write"u8; /// "OpenMode_AllowAppend" - private static ReadOnlySpan LogOpenModeAppend => // "OpenMode_AllowAppend" - new[] - { - (byte)'O', (byte)'p', (byte)'e', (byte)'n', (byte)'M', (byte)'o', (byte)'d', (byte)'e', - (byte)'_', (byte)'A', (byte)'l', (byte)'l', (byte)'o', (byte)'w', (byte)'A', (byte)'p', - (byte)'p', (byte)'e', (byte)'n', (byte)'d' - }; + private static ReadOnlySpan LogOpenModeAppend => "OpenMode_AllowAppend"u8; /// " handle: 0x" - private static ReadOnlySpan LogHandle => // " handle: 0x" - new[] - { - (byte)' ', (byte)' ', (byte)' ', (byte)' ', (byte)' ', (byte)'h', (byte)'a', (byte)'n', - (byte)'d', (byte)'l', (byte)'e', (byte)':', (byte)' ', (byte)'0', (byte)'x' - }; + private static ReadOnlySpan LogHandle => " handle: 0x"u8; /// ", open_mode: " - private static ReadOnlySpan LogOpenMode => // ", open_mode: " - new[] - { - (byte)',', (byte)' ', (byte)'o', (byte)'p', (byte)'e', (byte)'n', (byte)'_', (byte)'m', - (byte)'o', (byte)'d', (byte)'e', (byte)':', (byte)' ' - }; + private static ReadOnlySpan LogOpenMode => ", open_mode: "u8; - /// ", size:" - private static ReadOnlySpan LogSize => // ", size: " - new[] - { - (byte)',', (byte)' ', (byte)'s', (byte)'i', (byte)'z', (byte)'e', (byte)':', (byte)' ' - }; + /// ", size: " + private static ReadOnlySpan LogSize => ", size: "u8; private void DumpUnclosedAccessorList(OpenMode fileOpenModeMask, OpenDirectoryMode directoryOpenModeMask) { diff --git a/src/LibHac/Fs/Fsa/UserFileSystem.cs b/src/LibHac/Fs/Fsa/UserFileSystem.cs index 771bb9fe..e40c0658 100644 --- a/src/LibHac/Fs/Fsa/UserFileSystem.cs +++ b/src/LibHac/Fs/Fsa/UserFileSystem.cs @@ -458,10 +458,10 @@ public static class UserFileSystem { UnsafeHelpers.SkipParamInit(out freeSpace); - if (subPath.IsEmpty() && StringUtils.Compare(subPath, new[] { (byte)'/' }) != 0) + if (subPath.IsEmpty() && StringUtils.Compare(subPath, "/"u8) != 0) return ResultFs.InvalidMountName.Log(); - return fileSystem.GetFreeSpaceSize(out freeSpace, new U8Span(new[] { (byte)'/' })); + return fileSystem.GetFreeSpaceSize(out freeSpace, new U8Span("/"u8)); } if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog()) diff --git a/src/LibHac/Fs/Fsa/UserFileSystemPrivate.cs b/src/LibHac/Fs/Fsa/UserFileSystemPrivate.cs index d216d515..c857831a 100644 --- a/src/LibHac/Fs/Fsa/UserFileSystemPrivate.cs +++ b/src/LibHac/Fs/Fsa/UserFileSystemPrivate.cs @@ -93,7 +93,7 @@ public static class UserFileSystemPrivate if (res.IsFailure()) return res.Miss(); res = fileSystem.QueryEntry(SpanHelpers.AsByteSpan(ref info), ReadOnlySpan.Empty, - QueryId.QueryUnpreparedFileInformation, new U8Span(new[] { (byte)'/' })); + QueryId.QueryUnpreparedFileInformation, new U8Span("/"u8)); fs.Impl.AbortIfNeeded(res); return res; } diff --git a/src/LibHac/Fs/Impl/CommonMountNames.cs b/src/LibHac/Fs/Impl/CommonMountNames.cs index 63e10a9b..4b0a3df9 100644 --- a/src/LibHac/Fs/Impl/CommonMountNames.cs +++ b/src/LibHac/Fs/Impl/CommonMountNames.cs @@ -8,88 +8,50 @@ public static class CommonMountNames // Filesystem names. /// "@Host" - public static ReadOnlySpan HostRootFileSystemMountName => // "@Host" - new[] { (byte)'@', (byte)'H', (byte)'o', (byte)'s', (byte)'t' }; + public static ReadOnlySpan HostRootFileSystemMountName => "@Host"u8; /// "@Sdcard" - public static ReadOnlySpan SdCardFileSystemMountName => // "@Sdcard" - new[] { (byte)'@', (byte)'S', (byte)'d', (byte)'c', (byte)'a', (byte)'r', (byte)'d' }; + public static ReadOnlySpan SdCardFileSystemMountName => "@Sdcard"u8; /// "@Gc" - public static ReadOnlySpan GameCardFileSystemMountName => // "@Gc" - new[] { (byte)'@', (byte)'G', (byte)'c' }; + public static ReadOnlySpan GameCardFileSystemMountName => "@Gc"u8; /// "U" - public static ReadOnlySpan GameCardFileSystemMountNameUpdateSuffix => // "U" - new[] { (byte)'U' }; + public static ReadOnlySpan GameCardFileSystemMountNameUpdateSuffix => "U"u8; /// "N" - public static ReadOnlySpan GameCardFileSystemMountNameNormalSuffix => // "N" - new[] { (byte)'N' }; + public static ReadOnlySpan GameCardFileSystemMountNameNormalSuffix => "N"u8; /// "S" - public static ReadOnlySpan GameCardFileSystemMountNameSecureSuffix => // "S" - new[] { (byte)'S' }; + public static ReadOnlySpan GameCardFileSystemMountNameSecureSuffix => "S"u8; // Built-in storage names. /// "@CalibFile" - public static ReadOnlySpan BisCalibrationFilePartitionMountName => // "@CalibFile" - new[] - { - (byte)'@', (byte)'C', (byte)'a', (byte)'l', (byte)'i', (byte)'b', (byte)'F', (byte)'i', - (byte)'l', (byte)'e' - }; + public static ReadOnlySpan BisCalibrationFilePartitionMountName => "@CalibFile"u8; /// "@Safe" - public static ReadOnlySpan BisSafeModePartitionMountName => // "@Safe" - new[] { (byte)'@', (byte)'S', (byte)'a', (byte)'f', (byte)'e' }; + public static ReadOnlySpan BisSafeModePartitionMountName => "@Safe"u8; /// "@User" - public static ReadOnlySpan BisUserPartitionMountName => // "@User" - new[] { (byte)'@', (byte)'U', (byte)'s', (byte)'e', (byte)'r' }; + public static ReadOnlySpan BisUserPartitionMountName => "@User"u8; /// "@System" - public static ReadOnlySpan BisSystemPartitionMountName => // "@System" - new[] { (byte)'@', (byte)'S', (byte)'y', (byte)'s', (byte)'t', (byte)'e', (byte)'m' }; + public static ReadOnlySpan BisSystemPartitionMountName => "@System"u8; //Content storage names. /// "@SystemContent" - public static ReadOnlySpan ContentStorageSystemMountName => // "@SystemContent" - new[] - { - (byte)'@', (byte)'S', (byte)'y', (byte)'s', (byte)'t', (byte)'e', (byte)'m', (byte)'C', - (byte)'o', (byte)'n', (byte)'t', (byte)'e', (byte)'n', (byte)'t' - }; + public static ReadOnlySpan ContentStorageSystemMountName => "@SystemContent"u8; /// "@UserContent" - public static ReadOnlySpan ContentStorageUserMountName => // "@UserContent" - new[] - { - (byte)'@', (byte)'U', (byte)'s', (byte)'e', (byte)'r', (byte)'C', (byte)'o', (byte)'n', - (byte)'t', (byte)'e', (byte)'n', (byte)'t' - }; + public static ReadOnlySpan ContentStorageUserMountName => "@UserContent"u8; /// "@SdCardContent" - public static ReadOnlySpan ContentStorageSdCardMountName => // "@SdCardContent" - new[] - { - (byte)'@', (byte)'S', (byte)'d', (byte)'C', (byte)'a', (byte)'r', (byte)'d', (byte)'C', - (byte)'o', (byte)'n', (byte)'t', (byte)'e', (byte)'n', (byte)'t' - }; + public static ReadOnlySpan ContentStorageSdCardMountName => "@SdCardContent"u8; // Registered update partition /// "@RegUpdate" - public static ReadOnlySpan RegisteredUpdatePartitionMountName => // "@RegUpdate" - new[] - { - (byte)'@', (byte)'R', (byte)'e', (byte)'g', (byte)'U', (byte)'p', (byte)'d', (byte)'a', - (byte)'t', (byte)'e' - }; + public static ReadOnlySpan RegisteredUpdatePartitionMountName => "@RegUpdate"u8; - /// "@Nintendo" - public static ReadOnlySpan SdCardNintendoRootDirectoryName => // "Nintendo" - new[] - { - (byte)'N', (byte)'i', (byte)'n', (byte)'t', (byte)'e', (byte)'n', (byte)'d', (byte)'o' - }; + /// "Nintendo" + public static ReadOnlySpan SdCardNintendoRootDirectoryName => "Nintendo"u8; } \ No newline at end of file diff --git a/src/LibHac/Fs/Shim/CustomStorage.cs b/src/LibHac/Fs/Shim/CustomStorage.cs index 12d898b3..d1d38242 100644 --- a/src/LibHac/Fs/Shim/CustomStorage.cs +++ b/src/LibHac/Fs/Shim/CustomStorage.cs @@ -61,10 +61,5 @@ public static class CustomStorage } /// "CustomStorage0" - private static ReadOnlySpan CustomStorageDirectoryName => - new[] - { - (byte)'C', (byte)'u', (byte)'s', (byte)'t', (byte)'o', (byte)'m', (byte)'S', (byte)'t', - (byte)'o', (byte)'r', (byte)'a', (byte)'g', (byte)'e', (byte)'0' - }; + private static ReadOnlySpan CustomStorageDirectoryName => "CustomStorage0"u8; } \ No newline at end of file diff --git a/src/LibHac/Fs/Shim/Host.cs b/src/LibHac/Fs/Shim/Host.cs index 97d79627..11b8c171 100644 --- a/src/LibHac/Fs/Shim/Host.cs +++ b/src/LibHac/Fs/Shim/Host.cs @@ -24,8 +24,7 @@ namespace LibHac.Fs.Shim; public static class Host { /// "@Host:/" - private static ReadOnlySpan HostRootFileSystemPath => - new[] { (byte)'@', (byte)'H', (byte)'o', (byte)'s', (byte)'t', (byte)':', (byte)'/' }; + private static ReadOnlySpan HostRootFileSystemPath => "@Host:/"u8; private const int HostRootFileSystemPathLength = 7; diff --git a/src/LibHac/Fs/Shim/SignedSystemPartition.cs b/src/LibHac/Fs/Shim/SignedSystemPartition.cs index f39a69ce..fc5b7428 100644 --- a/src/LibHac/Fs/Shim/SignedSystemPartition.cs +++ b/src/LibHac/Fs/Shim/SignedSystemPartition.cs @@ -29,7 +29,7 @@ public static class SignedSystemPartition static Result Operate(ref bool isValid, FileSystemAccessor fileSystem) { Result res = fileSystem.QueryEntry(SpanHelpers.AsByteSpan(ref isValid), ReadOnlySpan.Empty, - QueryId.IsSignedSystemPartition, new U8Span(new[] { (byte)'/' })); + QueryId.IsSignedSystemPartition, new U8Span("/"u8)); if (res.IsFailure()) { diff --git a/src/LibHac/FsSrv/AccessLogService.cs b/src/LibHac/FsSrv/AccessLogService.cs index 8857000b..e81e3018 100644 --- a/src/LibHac/FsSrv/AccessLogService.cs +++ b/src/LibHac/FsSrv/AccessLogService.cs @@ -64,13 +64,5 @@ internal readonly struct AccessLogService } /// "FS_ACCESS: { multi_program_tag: true }\n" - private static ReadOnlySpan MultiProgramTag => // FS_ACCESS: { multi_program_tag: true }\n - new[] - { - (byte)'F', (byte)'S', (byte)'_', (byte)'A', (byte)'C', (byte)'C', (byte)'E', (byte)'S', - (byte)'S', (byte)':', (byte)' ', (byte)'{', (byte)' ', (byte)'m', (byte)'u', (byte)'l', - (byte)'t', (byte)'i', (byte)'_', (byte)'p', (byte)'r', (byte)'o', (byte)'g', (byte)'r', - (byte)'a', (byte)'m', (byte)'_', (byte)'t', (byte)'a', (byte)'g', (byte)':', (byte)' ', - (byte)'t', (byte)'r', (byte)'u', (byte)'e', (byte)' ', (byte)'}', (byte)'\n' - }; + private static ReadOnlySpan MultiProgramTag => "FS_ACCESS: { multi_program_tag: true }\n"u8; } \ No newline at end of file diff --git a/src/LibHac/FsSrv/Impl/FileSystemInterfaceAdapter.cs b/src/LibHac/FsSrv/Impl/FileSystemInterfaceAdapter.cs index a5ce5c89..2814c968 100644 --- a/src/LibHac/FsSrv/Impl/FileSystemInterfaceAdapter.cs +++ b/src/LibHac/FsSrv/Impl/FileSystemInterfaceAdapter.cs @@ -292,7 +292,7 @@ public class FileSystemInterfaceAdapter : IFileSystemSf _baseFileSystem.Destroy(); } - private static ReadOnlySpan RootDir => new[] { (byte)'/' }; + private static ReadOnlySpan RootDir => "/"u8; private Result SetUpPath(ref Path fsPath, in PathSf sfPath) { diff --git a/src/LibHac/FsSrv/Impl/MultiCommitManager.cs b/src/LibHac/FsSrv/Impl/MultiCommitManager.cs index 6b63e195..479fb4b7 100644 --- a/src/LibHac/FsSrv/Impl/MultiCommitManager.cs +++ b/src/LibHac/FsSrv/Impl/MultiCommitManager.cs @@ -55,8 +55,7 @@ internal class MultiCommitManager : IMultiCommitManager private const long CommitContextFileSize = 0x200; /// "/commitinfo" - private static ReadOnlySpan CommitContextFileName => - new[] { (byte)'/', (byte)'c', (byte)'o', (byte)'m', (byte)'m', (byte)'i', (byte)'t', (byte)'i', (byte)'n', (byte)'f', (byte)'o' }; + private static ReadOnlySpan CommitContextFileName => "/commitinfo"u8; private SharedRef _multiCommitInterface; private readonly SharedRef[] _fileSystems; diff --git a/src/LibHac/FsSrv/NcaFileSystemServiceImpl.cs b/src/LibHac/FsSrv/NcaFileSystemServiceImpl.cs index bd514132..1aedfd31 100644 --- a/src/LibHac/FsSrv/NcaFileSystemServiceImpl.cs +++ b/src/LibHac/FsSrv/NcaFileSystemServiceImpl.cs @@ -480,7 +480,7 @@ public class NcaFileSystemServiceImpl { UnsafeHelpers.SkipParamInit(out isDirectory); - ReadOnlySpan mountSeparator = new[] { (byte)':', (byte)'/' }; + ReadOnlySpan mountSeparator = ":/"u8; if (StringUtils.Compare(mountSeparator, path, mountSeparator.Length) != 0) { @@ -502,8 +502,8 @@ public class NcaFileSystemServiceImpl ReadOnlySpan fileExtension = path.Value.Slice(pathLen - 4); - ReadOnlySpan ncaExtension = new[] { (byte)'.', (byte)'n', (byte)'c', (byte)'a' }; - ReadOnlySpan nspExtension = new[] { (byte)'.', (byte)'n', (byte)'s', (byte)'p' }; + ReadOnlySpan ncaExtension = ".nca"u8; + ReadOnlySpan nspExtension = ".nsp"u8; if (StringUtils.CompareCaseInsensitive(fileExtension, ncaExtension) == 0 || StringUtils.CompareCaseInsensitive(fileExtension, nspExtension) == 0) @@ -531,8 +531,7 @@ public class NcaFileSystemServiceImpl using var pathRoot = new Path(); using var pathData = new Path(); - Result res = PathFunctions.SetUpFixedPath(ref pathData.Ref(), - new[] { (byte)'/', (byte)'d', (byte)'a', (byte)'t', (byte)'a' }); + Result res = PathFunctions.SetUpFixedPath(ref pathData.Ref(), "/data"u8); if (res.IsFailure()) return res.Miss(); res = pathRoot.Combine(in path, in pathData); @@ -551,7 +550,7 @@ public class NcaFileSystemServiceImpl private Result ParseNsp(ref U8Span path, ref SharedRef outFileSystem, ref SharedRef baseFileSystem) { - ReadOnlySpan nspExtension = new[] { (byte)'.', (byte)'n', (byte)'s', (byte)'p' }; + ReadOnlySpan nspExtension = ".nsp"u8; // Search for the end of the nsp part of the path int nspPathLen = 0; @@ -648,17 +647,17 @@ public class NcaFileSystemServiceImpl return Result.Success; case FileSystemProxyType.Code: - dirName = new[] { (byte)'/', (byte)'c', (byte)'o', (byte)'d', (byte)'e', (byte)'/' }; + dirName = "/code/"u8; break; case FileSystemProxyType.Rom: case FileSystemProxyType.Control: case FileSystemProxyType.Manual: case FileSystemProxyType.Meta: case FileSystemProxyType.RegisteredUpdate: - dirName = new[] { (byte)'/', (byte)'d', (byte)'a', (byte)'t', (byte)'a', (byte)'/' }; + dirName = "/data/"u8; break; case FileSystemProxyType.Logo: - dirName = new[] { (byte)'/', (byte)'l', (byte)'o', (byte)'g', (byte)'o', (byte)'/' }; + dirName = "/logo/"u8; break; default: @@ -905,17 +904,9 @@ public class NcaFileSystemServiceImpl } } - private static ReadOnlySpan SdCardNintendoRootDirectoryName => // Nintendo - new[] - { - (byte)'N', (byte)'i', (byte)'n', (byte)'t', (byte)'e', (byte)'n', (byte)'d', (byte)'o' - }; + private static ReadOnlySpan SdCardNintendoRootDirectoryName => "Nintendo"u8; - private static ReadOnlySpan ContentStorageDirectoryName => // Contents - new[] - { - (byte)'C', (byte)'o', (byte)'n', (byte)'t', (byte)'e', (byte)'n', (byte)'t', (byte)'s' - }; + private static ReadOnlySpan ContentStorageDirectoryName => "Contents"u8; } public readonly struct InternalProgramIdRangeForSpeedEmulation diff --git a/src/LibHac/FsSrv/SaveDataFileSystemService.cs b/src/LibHac/FsSrv/SaveDataFileSystemService.cs index 8f8d2cb5..7d46776a 100644 --- a/src/LibHac/FsSrv/SaveDataFileSystemService.cs +++ b/src/LibHac/FsSrv/SaveDataFileSystemService.cs @@ -621,7 +621,7 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave if (res.IsFailure()) return res.Miss(); using var pathRoot = new Path(); - res = PathFunctions.SetUpFixedPath(ref pathRoot.Ref(), new[] { (byte)'/' }); + res = PathFunctions.SetUpFixedPath(ref pathRoot.Ref(), "/"u8); if (res.IsFailure()) return res.Miss(); fileSystem.Get.GetFreeSpaceSize(out long freeSpaceSize, in pathRoot); @@ -854,7 +854,7 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave if (path.Str[0] == NullTerminator) { - res = saveDataRootPath.Initialize(new[] { (byte)'.' }); + res = saveDataRootPath.Initialize("."u8); if (res.IsFailure()) return res.Miss(); } else @@ -2583,7 +2583,7 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave if (res.IsFailure()) return res.Miss(); using var pathRoot = new Path(); - res = PathFunctions.SetUpFixedPath(ref pathRoot.Ref(), new[] { (byte)'/' }); + res = PathFunctions.SetUpFixedPath(ref pathRoot.Ref(), "/"u8); if (res.IsFailure()) return res.Miss(); res = fileSystem.Get.CleanDirectoryRecursively(in pathRoot); diff --git a/src/LibHac/FsSrv/SaveDataFileSystemServiceImpl.cs b/src/LibHac/FsSrv/SaveDataFileSystemServiceImpl.cs index 4f31102f..20196246 100644 --- a/src/LibHac/FsSrv/SaveDataFileSystemServiceImpl.cs +++ b/src/LibHac/FsSrv/SaveDataFileSystemServiceImpl.cs @@ -346,12 +346,7 @@ public class SaveDataFileSystemServiceImpl : IDisposable public Result DeleteAllSaveDataMetas(ulong saveDataId, SaveDataSpaceId spaceId) { - ReadOnlySpan metaDirName = // /saveMeta - new[] - { - (byte)'/', (byte)'s', (byte)'a', (byte)'v', (byte)'e', (byte)'M', (byte)'e', (byte)'t', - (byte)'a' - }; + ReadOnlySpan metaDirName = "/saveMeta"u8; Unsafe.SkipInit(out Array18 saveDataIdDirectoryNameBuffer); @@ -697,11 +692,11 @@ public class SaveDataFileSystemServiceImpl : IDisposable if (spaceId == SaveDataSpaceId.Temporary) { - saveDirName = new[] { (byte)'/', (byte)'t', (byte)'e', (byte)'m', (byte)'p' }; // /temp + saveDirName = "/temp"u8; } else { - saveDirName = new[] { (byte)'/', (byte)'s', (byte)'a', (byte)'v', (byte)'e' }; // /save + saveDirName = "/save"u8; } res = PathFunctions.SetUpFixedPath(ref saveDataAreaDirectoryName.Ref(), saveDirName); diff --git a/src/LibHac/FsSrv/SaveDataIndexer.cs b/src/LibHac/FsSrv/SaveDataIndexer.cs index 748dc909..85ddfcc2 100644 --- a/src/LibHac/FsSrv/SaveDataIndexer.cs +++ b/src/LibHac/FsSrv/SaveDataIndexer.cs @@ -37,15 +37,9 @@ public class SaveDataIndexer : ISaveDataIndexer private const long LastPublishedIdFileSize = sizeof(long); private const int MaxPathLength = 0x30; - private static ReadOnlySpan LastPublishedIdFileName => // lastPublishedId - new[] - { - (byte)'l', (byte)'a', (byte)'s', (byte)'t', (byte)'P', (byte)'u', (byte)'b', (byte)'l', - (byte)'i', (byte)'s', (byte)'h', (byte)'e', (byte)'d', (byte)'I', (byte)'d' - }; + private static ReadOnlySpan LastPublishedIdFileName => "lastPublishedId"u8; - private static ReadOnlySpan MountDelimiter => // :/ - new[] { (byte)':', (byte)'/' }; + private static ReadOnlySpan MountDelimiter => ":/"u8; private delegate void SaveDataValueTransform(ref SaveDataIndexerValue value, ReadOnlySpan updateData); diff --git a/src/LibHac/FsSrv/SaveDataIndexerManager.cs b/src/LibHac/FsSrv/SaveDataIndexerManager.cs index c199a3b5..1ac7e343 100644 --- a/src/LibHac/FsSrv/SaveDataIndexerManager.cs +++ b/src/LibHac/FsSrv/SaveDataIndexerManager.cs @@ -231,36 +231,16 @@ internal class SaveDataIndexerManager : ISaveDataIndexerManager, IDisposable } /// "saveDataIxrDb" - private static ReadOnlySpan BisIndexerMountName => - new[] - { - (byte)'s', (byte)'a', (byte)'v', (byte)'e', (byte)'D', (byte)'a', (byte)'t', (byte)'a', - (byte)'I', (byte)'x', (byte)'r', (byte)'D', (byte)'b' - }; + private static ReadOnlySpan BisIndexerMountName => "saveDataIxrDb"u8; /// "saveDataIxrDbSd" - private static ReadOnlySpan SdCardIndexerMountName => - new[] - { - (byte)'s', (byte)'a', (byte)'v', (byte)'e', (byte)'D', (byte)'a', (byte)'t', (byte)'a', - (byte)'I', (byte)'x', (byte)'r', (byte)'D', (byte)'b', (byte)'S', (byte)'d' - }; + private static ReadOnlySpan SdCardIndexerMountName => "saveDataIxrDbSd"u8; /// "saveDataIxrDbPr" - private static ReadOnlySpan ProperBisIndexerMountName => - new[] - { - (byte)'s', (byte)'a', (byte)'v', (byte)'e', (byte)'D', (byte)'a', (byte)'t', (byte)'a', - (byte)'I', (byte)'x', (byte)'r', (byte)'D', (byte)'b', (byte)'P', (byte)'r' - }; + private static ReadOnlySpan ProperBisIndexerMountName => "saveDataIxrDbPr"u8; /// "saveDataIxrDbSf" - private static ReadOnlySpan SafeModeIndexerMountName => - new[] - { - (byte)'s', (byte)'a', (byte)'v', (byte)'e', (byte)'D', (byte)'a', (byte)'t', (byte)'a', - (byte)'I', (byte)'x', (byte)'r', (byte)'D', (byte)'b', (byte)'S', (byte)'f' - }; + private static ReadOnlySpan SafeModeIndexerMountName => "saveDataIxrDbSf"u8; } /// diff --git a/src/LibHac/FsSystem/ConcatenationFileSystem.cs b/src/LibHac/FsSystem/ConcatenationFileSystem.cs index 261eaaf6..469e00eb 100644 --- a/src/LibHac/FsSystem/ConcatenationFileSystem.cs +++ b/src/LibHac/FsSystem/ConcatenationFileSystem.cs @@ -525,7 +525,7 @@ public class ConcatenationFileSystem : IFileSystem base.Dispose(); } - private static ReadOnlySpan RootPath => new[] { (byte)'/' }; + private static ReadOnlySpan RootPath => "/"u8; /// /// Appends the two-digit-padded to the given . diff --git a/src/LibHac/FsSystem/DirectorySaveDataFileSystem.cs b/src/LibHac/FsSystem/DirectorySaveDataFileSystem.cs index 91eda922..b097a2d7 100644 --- a/src/LibHac/FsSystem/DirectorySaveDataFileSystem.cs +++ b/src/LibHac/FsSystem/DirectorySaveDataFileSystem.cs @@ -30,10 +30,10 @@ public class DirectorySaveDataFileSystem : ISaveDataFileSystem { private const int IdealWorkBufferSize = 0x100000; // 1 MiB - private static ReadOnlySpan CommittedDirectoryName => new[] { (byte)'/', (byte)'0' }; - private static ReadOnlySpan ModifiedDirectoryName => new[] { (byte)'/', (byte)'1' }; - private static ReadOnlySpan SynchronizingDirectoryName => new[] { (byte)'/', (byte)'_' }; - private static ReadOnlySpan LockFileName => new[] { (byte)'/', (byte)'.', (byte)'l', (byte)'o', (byte)'c', (byte)'k' }; + private static ReadOnlySpan CommittedDirectoryName => "/0"u8; + private static ReadOnlySpan ModifiedDirectoryName => "/1"u8; + private static ReadOnlySpan SynchronizingDirectoryName => "/_"u8; + private static ReadOnlySpan LockFileName => "/.lock"u8; private IFileSystem _baseFs; private SdkMutexType _mutex; @@ -735,26 +735,11 @@ public class DirectorySaveDataFileSystem : ISaveDataFileSystem // always writing the extra data directly to the /extradata file. // Everything below this point is a LibHac extension. - private static ReadOnlySpan CommittedExtraDataName => // "/ExtraData0" - new[] - { - (byte)'/', (byte)'E', (byte)'x', (byte)'t', (byte)'r', (byte)'a', (byte)'D', (byte)'a', - (byte)'t', (byte)'a', (byte)'0' - }; + private static ReadOnlySpan CommittedExtraDataName => "/ExtraData0"u8; - private static ReadOnlySpan ModifiedExtraDataName => // "/ExtraData1" - new[] - { - (byte)'/', (byte)'E', (byte)'x', (byte)'t', (byte)'r', (byte)'a', (byte)'D', (byte)'a', - (byte)'t', (byte)'a', (byte)'1' - }; + private static ReadOnlySpan ModifiedExtraDataName => "/ExtraData1"u8; - private static ReadOnlySpan SynchronizingExtraDataName => // "/ExtraData_" - new[] - { - (byte)'/', (byte)'E', (byte)'x', (byte)'t', (byte)'r', (byte)'a', (byte)'D', (byte)'a', - (byte)'t', (byte)'a', (byte)'_' - }; + private static ReadOnlySpan SynchronizingExtraDataName => "/ExtraData_"u8; /// /// Initializes the save data's extra data files. diff --git a/src/LibHac/FsSystem/HierarchicalIntegrityVerificationStorage.cs b/src/LibHac/FsSystem/HierarchicalIntegrityVerificationStorage.cs index c591b296..31da2bac 100644 --- a/src/LibHac/FsSystem/HierarchicalIntegrityVerificationStorage.cs +++ b/src/LibHac/FsSystem/HierarchicalIntegrityVerificationStorage.cs @@ -744,74 +744,20 @@ public class HierarchicalIntegrityVerificationStorage : IStorage } /// "HierarchicalIntegrityVerificationStorage::Master" - public static ReadOnlySpan MasterKey => // "HierarchicalIntegrityVerificationStorage::Master" - new[] - { - (byte)'H', (byte)'i', (byte)'e', (byte)'r', (byte)'a', (byte)'r', (byte)'c', (byte)'h', - (byte)'i', (byte)'c', (byte)'a', (byte)'l', (byte)'I', (byte)'n', (byte)'t', (byte)'e', - (byte)'g', (byte)'r', (byte)'i', (byte)'t', (byte)'y', (byte)'V', (byte)'e', (byte)'r', - (byte)'i', (byte)'f', (byte)'i', (byte)'c', (byte)'a', (byte)'t', (byte)'i', (byte)'o', - (byte)'n', (byte)'S', (byte)'t', (byte)'o', (byte)'r', (byte)'a', (byte)'g', (byte)'e', - (byte)':', (byte)':', (byte)'M', (byte)'a', (byte)'s', (byte)'t', (byte)'e', (byte)'r' - }; + public static ReadOnlySpan MasterKey => "HierarchicalIntegrityVerificationStorage::Master"u8; /// "HierarchicalIntegrityVerificationStorage::L1" - public static ReadOnlySpan L1Key => // "HierarchicalIntegrityVerificationStorage::L1" - new[] - { - (byte)'H', (byte)'i', (byte)'e', (byte)'r', (byte)'a', (byte)'r', (byte)'c', (byte)'h', - (byte)'i', (byte)'c', (byte)'a', (byte)'l', (byte)'I', (byte)'n', (byte)'t', (byte)'e', - (byte)'g', (byte)'r', (byte)'i', (byte)'t', (byte)'y', (byte)'V', (byte)'e', (byte)'r', - (byte)'i', (byte)'f', (byte)'i', (byte)'c', (byte)'a', (byte)'t', (byte)'i', (byte)'o', - (byte)'n', (byte)'S', (byte)'t', (byte)'o', (byte)'r', (byte)'a', (byte)'g', (byte)'e', - (byte)':', (byte)':', (byte)'L', (byte)'1' - }; + public static ReadOnlySpan L1Key => "HierarchicalIntegrityVerificationStorage::L1"u8; /// "HierarchicalIntegrityVerificationStorage::L2" - public static ReadOnlySpan L2Key => // "HierarchicalIntegrityVerificationStorage::L2" - new[] - { - (byte)'H', (byte)'i', (byte)'e', (byte)'r', (byte)'a', (byte)'r', (byte)'c', (byte)'h', - (byte)'i', (byte)'c', (byte)'a', (byte)'l', (byte)'I', (byte)'n', (byte)'t', (byte)'e', - (byte)'g', (byte)'r', (byte)'i', (byte)'t', (byte)'y', (byte)'V', (byte)'e', (byte)'r', - (byte)'i', (byte)'f', (byte)'i', (byte)'c', (byte)'a', (byte)'t', (byte)'i', (byte)'o', - (byte)'n', (byte)'S', (byte)'t', (byte)'o', (byte)'r', (byte)'a', (byte)'g', (byte)'e', - (byte)':', (byte)':', (byte)'L', (byte)'2' - }; + public static ReadOnlySpan L2Key => "HierarchicalIntegrityVerificationStorage::L2"u8; /// "HierarchicalIntegrityVerificationStorage::L3" - public static ReadOnlySpan L3Key => // "HierarchicalIntegrityVerificationStorage::L3" - new[] - { - (byte)'H', (byte)'i', (byte)'e', (byte)'r', (byte)'a', (byte)'r', (byte)'c', (byte)'h', - (byte)'i', (byte)'c', (byte)'a', (byte)'l', (byte)'I', (byte)'n', (byte)'t', (byte)'e', - (byte)'g', (byte)'r', (byte)'i', (byte)'t', (byte)'y', (byte)'V', (byte)'e', (byte)'r', - (byte)'i', (byte)'f', (byte)'i', (byte)'c', (byte)'a', (byte)'t', (byte)'i', (byte)'o', - (byte)'n', (byte)'S', (byte)'t', (byte)'o', (byte)'r', (byte)'a', (byte)'g', (byte)'e', - (byte)':', (byte)':', (byte)'L', (byte)'3' - }; + public static ReadOnlySpan L3Key => "HierarchicalIntegrityVerificationStorage::L3"u8; /// "HierarchicalIntegrityVerificationStorage::L4" - public static ReadOnlySpan L4Key => // "HierarchicalIntegrityVerificationStorage::L4" - new[] - { - (byte)'H', (byte)'i', (byte)'e', (byte)'r', (byte)'a', (byte)'r', (byte)'c', (byte)'h', - (byte)'i', (byte)'c', (byte)'a', (byte)'l', (byte)'I', (byte)'n', (byte)'t', (byte)'e', - (byte)'g', (byte)'r', (byte)'i', (byte)'t', (byte)'y', (byte)'V', (byte)'e', (byte)'r', - (byte)'i', (byte)'f', (byte)'i', (byte)'c', (byte)'a', (byte)'t', (byte)'i', (byte)'o', - (byte)'n', (byte)'S', (byte)'t', (byte)'o', (byte)'r', (byte)'a', (byte)'g', (byte)'e', - (byte)':', (byte)':', (byte)'L', (byte)'4' - }; + public static ReadOnlySpan L4Key => "HierarchicalIntegrityVerificationStorage::L4"u8; /// "HierarchicalIntegrityVerificationStorage::L5" - public static ReadOnlySpan L5Key => // "HierarchicalIntegrityVerificationStorage::L5" - new[] - { - (byte)'H', (byte)'i', (byte)'e', (byte)'r', (byte)'a', (byte)'r', (byte)'c', (byte)'h', - (byte)'i', (byte)'c', (byte)'a', (byte)'l', (byte)'I', (byte)'n', (byte)'t', (byte)'e', - (byte)'g', (byte)'r', (byte)'i', (byte)'t', (byte)'y', (byte)'V', (byte)'e', (byte)'r', - (byte)'i', (byte)'f', (byte)'i', (byte)'c', (byte)'a', (byte)'t', (byte)'i', (byte)'o', - (byte)'n', (byte)'S', (byte)'t', (byte)'o', (byte)'r', (byte)'a', (byte)'g', (byte)'e', - (byte)':', (byte)':', (byte)'L', (byte)'5' - }; + public static ReadOnlySpan L5Key => "HierarchicalIntegrityVerificationStorage::L5"u8; } \ No newline at end of file diff --git a/src/LibHac/FsSystem/PartitionFileSystemCore.cs b/src/LibHac/FsSystem/PartitionFileSystemCore.cs index 75c95c2e..45359ebc 100644 --- a/src/LibHac/FsSystem/PartitionFileSystemCore.cs +++ b/src/LibHac/FsSystem/PartitionFileSystemCore.cs @@ -55,9 +55,7 @@ public class PartitionFileSystemCore : IFileSystem where T : unmanaged, IPart if (!_isInitialized) return ResultFs.PreconditionViolation.Log(); - ReadOnlySpan rootPath = new[] { (byte)'/' }; - - if (path != rootPath) + if (path != "/"u8) return ResultFs.PathNotFound.Log(); outDirectory.Reset(new PartitionDirectory(this, mode)); @@ -95,7 +93,7 @@ public class PartitionFileSystemCore : IFileSystem where T : unmanaged, IPart if (path.IsEmpty() || pathStr[0] != '/') return ResultFs.InvalidPathFormat.Log(); - ReadOnlySpan rootPath = new[] { (byte)'/' }; + ReadOnlySpan rootPath = "/"u8; if (StringUtils.Compare(rootPath, pathStr, 2) == 0) { diff --git a/src/LibHac/FsSystem/Utility.cs b/src/LibHac/FsSystem/Utility.cs index b084370c..536a8271 100644 --- a/src/LibHac/FsSystem/Utility.cs +++ b/src/LibHac/FsSystem/Utility.cs @@ -33,7 +33,7 @@ internal static class Utility public IFileSystem DestFileSystem; } - private static ReadOnlySpan RootPath => new[] { (byte)'/' }; + private static ReadOnlySpan RootPath => "/"u8; private static Result IterateDirectoryRecursivelyInternal(IFileSystem fs, ref Path workPath, ref DirectoryEntry dirEntry, FsIterationTask onEnterDir, FsIterationTask onExitDir, FsIterationTask onFile, diff --git a/src/LibHac/Kvdb/FlatMapKeyValueStore.cs b/src/LibHac/Kvdb/FlatMapKeyValueStore.cs index 1f09997c..35251edf 100644 --- a/src/LibHac/Kvdb/FlatMapKeyValueStore.cs +++ b/src/LibHac/Kvdb/FlatMapKeyValueStore.cs @@ -24,12 +24,7 @@ public class FlatMapKeyValueStore : IDisposable where TKey : unmanaged, IE private MemoryResource _memoryResource; private MemoryResource _memoryResourceForAutoBuffers; - private static ReadOnlySpan ArchiveFileName => // /imkvdb.arc - new[] - { - (byte)'/', (byte)'i', (byte)'m', (byte)'k', (byte)'v', (byte)'d', (byte)'b', (byte)'.', - (byte)'a', (byte)'r', (byte)'c' - }; + private static ReadOnlySpan ArchiveFileName => "/imkvdb.arc"u8; public int Count => _index.Count;