diff --git a/src/LibHac/Common/U8Span.cs b/src/LibHac/Common/U8Span.cs index c5758105..f7a5fd9c 100644 --- a/src/LibHac/Common/U8Span.cs +++ b/src/LibHac/Common/U8Span.cs @@ -64,6 +64,7 @@ public readonly ref struct U8Span } public static implicit operator ReadOnlySpan(in U8Span value) => value.Value; + public static implicit operator U8Span(ReadOnlySpan value) => new U8Span(value); public static explicit operator string(in U8Span value) => value.ToString(); public static explicit operator U8Span(string value) => new U8Span(value); diff --git a/src/LibHac/Diag/LogObserver.cs b/src/LibHac/Diag/LogObserver.cs index 74cf2064..b9c8a86e 100644 --- a/src/LibHac/Diag/LogObserver.cs +++ b/src/LibHac/Diag/LogObserver.cs @@ -101,7 +101,7 @@ namespace LibHac.Diag namespace LibHac.Diag.Impl { - // Todo: Make fields references once C# 10 is released + // Todo: Use ref fields once C# 12? is released internal ref struct LogObserverContext { public LogMetaData MetaData; diff --git a/src/LibHac/Fs/CommonDirNames.cs b/src/LibHac/Fs/CommonDirNames.cs new file mode 100644 index 00000000..099536a1 --- /dev/null +++ b/src/LibHac/Fs/CommonDirNames.cs @@ -0,0 +1,12 @@ +using System; + +namespace LibHac.Fs; + +internal static class CommonDirNames +{ + /// "Nintendo" + public static ReadOnlySpan SdCardNintendoRootDirectoryName => "Nintendo"u8; + + /// "Contents" + public static ReadOnlySpan ContentStorageDirectoryName => "Contents"u8; +} \ No newline at end of file diff --git a/src/LibHac/Fs/CommonPaths.cs b/src/LibHac/Fs/CommonPaths.cs deleted file mode 100644 index c2f3305b..00000000 --- a/src/LibHac/Fs/CommonPaths.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using LibHac.Common; - -namespace LibHac.Fs; - -// Todo: Migrate to LibHac.Fs.Impl.CommonMountNames and remove -internal static class CommonPaths -{ - public const char ReservedMountNamePrefixCharacter = '@'; - - public static readonly U8String GameCardFileSystemMountName = new U8String("@Gc"); - public static readonly U8String ContentStorageSystemMountName = new U8String("@SystemContent"); - public static readonly U8String ContentStorageUserMountName = new U8String("@UserContent"); - public static readonly U8String ContentStorageSdCardMountName = new U8String("@SdCardContent"); - public static readonly U8String BisCalibrationFilePartitionMountName = new U8String("@CalibFile"); - public static readonly U8String BisSafeModePartitionMountName = new U8String("@Safe"); - public static readonly U8String BisUserPartitionMountName = new U8String("@User"); - public static readonly U8String BisSystemPartitionMountName = new U8String("@System"); - public static readonly U8String SdCardFileSystemMountName = new U8String("@Sdcard"); - public static readonly U8String HostRootFileSystemMountName = new U8String("@Host"); - public static readonly U8String RegisteredUpdatePartitionMountName = new U8String("@RegUpdate"); - - public const char GameCardFileSystemMountNameUpdateSuffix = 'U'; - public const char GameCardFileSystemMountNameNormalSuffix = 'N'; - public const char GameCardFileSystemMountNameSecureSuffix = 'S'; - - public static ReadOnlySpan SdCardNintendoRootDirectoryName => "Nintendo"u8; -} \ No newline at end of file diff --git a/src/LibHac/Fs/Fsa/MountUtility.cs b/src/LibHac/Fs/Fsa/MountUtility.cs index df863e0e..f7fb917f 100644 --- a/src/LibHac/Fs/Fsa/MountUtility.cs +++ b/src/LibHac/Fs/Fsa/MountUtility.cs @@ -7,6 +7,7 @@ using LibHac.Fs.Shim; using LibHac.Os; using LibHac.Util; using static LibHac.Fs.Impl.AccessLogStrings; +using static LibHac.Fs.Impl.CommonMountNames; using static LibHac.Fs.StringTraits; namespace LibHac.Fs.Fsa; @@ -40,7 +41,7 @@ public static class MountUtility if (WindowsPath.IsWindowsDrive(path) || WindowsPath.IsUncPath(path)) { - StringUtils.Copy(mountName.Name, CommonPaths.HostRootFileSystemMountName); + StringUtils.Copy(mountName.Name, HostRootFileSystemMountName); mountName.Name[PathTool.MountNameLengthMax] = NullTerminator; subPath = path; @@ -106,7 +107,7 @@ public static class MountUtility public static bool IsUsedReservedMountName(this FileSystemClientImpl fs, U8Span name) { - return name.Length > 0 && name[0] == CommonPaths.ReservedMountNamePrefixCharacter; + return name.Length > 0 && name[0] == ReservedMountNamePrefixCharacter; } internal static Result FindFileSystem(this FileSystemClientImpl fs, out FileSystemAccessor fileSystem, @@ -118,8 +119,8 @@ public static class MountUtility if (path.IsNull()) return ResultFs.NullptrArgument.Log(); - int hostMountNameLen = StringUtils.GetLength(CommonPaths.HostRootFileSystemMountName); - if (StringUtils.Compare(path, CommonPaths.HostRootFileSystemMountName, hostMountNameLen) == 0) + int hostMountNameLen = StringUtils.GetLength(HostRootFileSystemMountName); + if (StringUtils.Compare(path, HostRootFileSystemMountName, hostMountNameLen) == 0) { return ResultFs.NotMounted.Log(); } @@ -214,6 +215,7 @@ public static class MountUtility { res = fs.Impl.Unmount(mountName); } + fs.Impl.LogResultErrorMessage(res); Abort.DoAbortUnless(res.IsSuccess()); } @@ -240,6 +242,7 @@ public static class MountUtility { res = fs.Impl.IsMounted(out isMounted, mountName); } + fs.Impl.LogResultErrorMessage(res); Abort.DoAbortUnless(res.IsSuccess()); diff --git a/src/LibHac/Fs/Impl/CommonMountNames.cs b/src/LibHac/Fs/Impl/CommonMountNames.cs index 4b0a3df9..5fce8a99 100644 --- a/src/LibHac/Fs/Impl/CommonMountNames.cs +++ b/src/LibHac/Fs/Impl/CommonMountNames.cs @@ -17,13 +17,13 @@ public static class CommonMountNames public static ReadOnlySpan GameCardFileSystemMountName => "@Gc"u8; /// "U" - public static ReadOnlySpan GameCardFileSystemMountNameUpdateSuffix => "U"u8; + public static ReadOnlySpan GameCardFileSystemMountNameSuffixUpdate => "U"u8; /// "N" - public static ReadOnlySpan GameCardFileSystemMountNameNormalSuffix => "N"u8; + public static ReadOnlySpan GameCardFileSystemMountNameSuffixNormal => "N"u8; /// "S" - public static ReadOnlySpan GameCardFileSystemMountNameSecureSuffix => "S"u8; + public static ReadOnlySpan GameCardFileSystemMountNameSuffixSecure => "S"u8; // Built-in storage names. /// "@CalibFile" @@ -51,7 +51,4 @@ public static class CommonMountNames // Registered update partition /// "@RegUpdate" public static ReadOnlySpan RegisteredUpdatePartitionMountName => "@RegUpdate"u8; - - /// "Nintendo" - public static ReadOnlySpan SdCardNintendoRootDirectoryName => "Nintendo"u8; } \ No newline at end of file diff --git a/src/LibHac/Fs/Shim/GameCard.cs b/src/LibHac/Fs/Shim/GameCard.cs index a4faf518..30cc5d0c 100644 --- a/src/LibHac/Fs/Shim/GameCard.cs +++ b/src/LibHac/Fs/Shim/GameCard.cs @@ -28,9 +28,9 @@ public static class GameCard { switch (partition) { - case GameCardPartition.Update: return CommonMountNames.GameCardFileSystemMountNameUpdateSuffix; - case GameCardPartition.Normal: return CommonMountNames.GameCardFileSystemMountNameNormalSuffix; - case GameCardPartition.Secure: return CommonMountNames.GameCardFileSystemMountNameSecureSuffix; + case GameCardPartition.Update: return CommonMountNames.GameCardFileSystemMountNameSuffixUpdate; + case GameCardPartition.Normal: return CommonMountNames.GameCardFileSystemMountNameSuffixNormal; + case GameCardPartition.Secure: return CommonMountNames.GameCardFileSystemMountNameSuffixSecure; default: Abort.UnexpectedDefault(); return default; diff --git a/src/LibHac/FsSrv/FileSystemProxyCoreImpl.cs b/src/LibHac/FsSrv/FileSystemProxyCoreImpl.cs index a3e79290..76ee198b 100644 --- a/src/LibHac/FsSrv/FileSystemProxyCoreImpl.cs +++ b/src/LibHac/FsSrv/FileSystemProxyCoreImpl.cs @@ -56,7 +56,7 @@ public class FileSystemProxyCoreImpl using scoped var path = new Path(); res = PathFunctions.SetUpFixedPathDoubleEntry(ref path.Ref(), pathBuffer.Items, - CommonPaths.SdCardNintendoRootDirectoryName, + CommonDirNames.SdCardNintendoRootDirectoryName, CustomStorage.GetCustomStorageDirectoryName(CustomStorageId.System)); if (res.IsFailure()) return res.Miss(); diff --git a/src/LibHac/FsSrv/FsCreator/EmulatedBisFileSystemCreator.cs b/src/LibHac/FsSrv/FsCreator/EmulatedBisFileSystemCreator.cs index 9d4c3fd1..e9027caf 100644 --- a/src/LibHac/FsSrv/FsCreator/EmulatedBisFileSystemCreator.cs +++ b/src/LibHac/FsSrv/FsCreator/EmulatedBisFileSystemCreator.cs @@ -74,7 +74,7 @@ public class EmulatedBisFileSystemCreator : IBuiltInStorageFileSystemCreator } using var bisRootPath = new Path(); - Result res = bisRootPath.Initialize(GetPartitionPath(partitionId).ToU8String()); + Result res = bisRootPath.Initialize(GetPartitionPath(partitionId).ToU8Span()); if (res.IsFailure()) return res.Miss(); var pathFlags = new PathFlags(); diff --git a/src/LibHac/FsSrv/NcaFileSystemServiceImpl.cs b/src/LibHac/FsSrv/NcaFileSystemServiceImpl.cs index 1aedfd31..d858599a 100644 --- a/src/LibHac/FsSrv/NcaFileSystemServiceImpl.cs +++ b/src/LibHac/FsSrv/NcaFileSystemServiceImpl.cs @@ -13,6 +13,7 @@ using LibHac.Os; using LibHac.Spl; using LibHac.Tools.FsSystem.NcaUtils; using LibHac.Util; +using static LibHac.Fs.Impl.CommonMountNames; using NcaFsHeader = LibHac.Tools.FsSystem.NcaUtils.NcaFsHeader; using RightsId = LibHac.Fs.RightsId; using Utility = LibHac.FsSystem.Utility; @@ -245,13 +246,13 @@ public class NcaFileSystemServiceImpl if (contentStorageId == ContentStorageId.SdCard) { var sb = new U8StringBuilder(contentStoragePathBuffer.Items); - sb.Append(StringTraits.DirectorySeparator).Append(SdCardNintendoRootDirectoryName); - sb.Append(StringTraits.DirectorySeparator).Append(ContentStorageDirectoryName); + sb.Append(StringTraits.DirectorySeparator).Append(CommonDirNames.SdCardNintendoRootDirectoryName); + sb.Append(StringTraits.DirectorySeparator).Append(CommonDirNames.ContentStorageDirectoryName); } else { var sb = new U8StringBuilder(contentStoragePathBuffer.Items); - sb.Append(StringTraits.DirectorySeparator).Append(ContentStorageDirectoryName); + sb.Append(StringTraits.DirectorySeparator).Append(CommonDirNames.ContentStorageDirectoryName); } using var contentStoragePath = new Path(); @@ -319,29 +320,23 @@ public class NcaFileSystemServiceImpl info = new MountInfo(); shouldContinue = true; - if (StringUtils.Compare(path, CommonPaths.GameCardFileSystemMountName, - CommonPaths.GameCardFileSystemMountName.Length) == 0) + if (StringUtils.Compare(path, GameCardFileSystemMountName, + GameCardFileSystemMountName.Length) == 0) { - path = path.Slice(CommonPaths.GameCardFileSystemMountName.Length); + path = path.Slice(GameCardFileSystemMountName.Length); if (StringUtils.GetLength(path.Value, 9) < 9) return ResultFs.InvalidPath.Log(); GameCardPartition partition; - switch ((char)path[0]) - { - case CommonPaths.GameCardFileSystemMountNameUpdateSuffix: - partition = GameCardPartition.Update; - break; - case CommonPaths.GameCardFileSystemMountNameNormalSuffix: - partition = GameCardPartition.Normal; - break; - case CommonPaths.GameCardFileSystemMountNameSecureSuffix: - partition = GameCardPartition.Secure; - break; - default: - return ResultFs.InvalidPath.Log(); - } + if (StringUtils.CompareCaseInsensitive(path, GameCardFileSystemMountNameSuffixUpdate) == 0) + partition = GameCardPartition.Update; + else if (StringUtils.CompareCaseInsensitive(path, GameCardFileSystemMountNameSuffixNormal) == 0) + partition = GameCardPartition.Normal; + else if (StringUtils.CompareCaseInsensitive(path, GameCardFileSystemMountNameSuffixSecure) == 0) + partition = GameCardPartition.Secure; + else + return ResultFs.InvalidPath.Log(); path = path.Slice(1); bool handleParsed = Utf8Parser.TryParse(path, out int handle, out int bytesConsumed); @@ -359,10 +354,10 @@ public class NcaFileSystemServiceImpl info.CanMountNca = true; } - else if (StringUtils.Compare(path, CommonPaths.ContentStorageSystemMountName, - CommonPaths.ContentStorageSystemMountName.Length) == 0) + else if (StringUtils.Compare(path, ContentStorageSystemMountName, + ContentStorageSystemMountName.Length) == 0) { - path = path.Slice(CommonPaths.ContentStorageSystemMountName.Length); + path = path.Slice(ContentStorageSystemMountName.Length); Result res = OpenContentStorageFileSystem(ref outFileSystem, ContentStorageId.System); if (res.IsFailure()) return res.Miss(); @@ -370,10 +365,10 @@ public class NcaFileSystemServiceImpl info.CanMountNca = true; } - else if (StringUtils.Compare(path, CommonPaths.ContentStorageUserMountName, - CommonPaths.ContentStorageUserMountName.Length) == 0) + else if (StringUtils.Compare(path, ContentStorageUserMountName, + ContentStorageUserMountName.Length) == 0) { - path = path.Slice(CommonPaths.ContentStorageUserMountName.Length); + path = path.Slice(ContentStorageUserMountName.Length); Result res = OpenContentStorageFileSystem(ref outFileSystem, ContentStorageId.User); if (res.IsFailure()) return res.Miss(); @@ -381,10 +376,10 @@ public class NcaFileSystemServiceImpl info.CanMountNca = true; } - else if (StringUtils.Compare(path, CommonPaths.ContentStorageSdCardMountName, - CommonPaths.ContentStorageSdCardMountName.Length) == 0) + else if (StringUtils.Compare(path, ContentStorageSdCardMountName, + ContentStorageSdCardMountName.Length) == 0) { - path = path.Slice(CommonPaths.ContentStorageSdCardMountName.Length); + path = path.Slice(ContentStorageSdCardMountName.Length); Result res = OpenContentStorageFileSystem(ref outFileSystem, ContentStorageId.SdCard); if (res.IsFailure()) return res.Miss(); @@ -392,55 +387,55 @@ public class NcaFileSystemServiceImpl info.CanMountNca = true; } - else if (StringUtils.Compare(path, CommonPaths.BisCalibrationFilePartitionMountName, - CommonPaths.BisCalibrationFilePartitionMountName.Length) == 0) + else if (StringUtils.Compare(path, BisCalibrationFilePartitionMountName, + BisCalibrationFilePartitionMountName.Length) == 0) { - path = path.Slice(CommonPaths.BisCalibrationFilePartitionMountName.Length); + path = path.Slice(BisCalibrationFilePartitionMountName.Length); Result res = _config.BaseFsService.OpenBisFileSystem(ref outFileSystem, BisPartitionId.CalibrationFile); if (res.IsFailure()) return res.Miss(); } - else if (StringUtils.Compare(path, CommonPaths.BisSafeModePartitionMountName, - CommonPaths.BisSafeModePartitionMountName.Length) == 0) + else if (StringUtils.Compare(path, BisSafeModePartitionMountName, + BisSafeModePartitionMountName.Length) == 0) { - path = path.Slice(CommonPaths.BisSafeModePartitionMountName.Length); + path = path.Slice(BisSafeModePartitionMountName.Length); Result res = _config.BaseFsService.OpenBisFileSystem(ref outFileSystem, BisPartitionId.SafeMode); if (res.IsFailure()) return res.Miss(); } - else if (StringUtils.Compare(path, CommonPaths.BisUserPartitionMountName, - CommonPaths.BisUserPartitionMountName.Length) == 0) + else if (StringUtils.Compare(path, BisUserPartitionMountName, + BisUserPartitionMountName.Length) == 0) { - path = path.Slice(CommonPaths.BisUserPartitionMountName.Length); + path = path.Slice(BisUserPartitionMountName.Length); Result res = _config.BaseFsService.OpenBisFileSystem(ref outFileSystem, BisPartitionId.User); if (res.IsFailure()) return res.Miss(); } - else if (StringUtils.Compare(path, CommonPaths.BisSystemPartitionMountName, - CommonPaths.BisSystemPartitionMountName.Length) == 0) + else if (StringUtils.Compare(path, BisSystemPartitionMountName, + BisSystemPartitionMountName.Length) == 0) { - path = path.Slice(CommonPaths.BisSystemPartitionMountName.Length); + path = path.Slice(BisSystemPartitionMountName.Length); Result res = _config.BaseFsService.OpenBisFileSystem(ref outFileSystem, BisPartitionId.System); if (res.IsFailure()) return res.Miss(); } - else if (StringUtils.Compare(path, CommonPaths.SdCardFileSystemMountName, - CommonPaths.SdCardFileSystemMountName.Length) == 0) + else if (StringUtils.Compare(path, SdCardFileSystemMountName, + SdCardFileSystemMountName.Length) == 0) { - path = path.Slice(CommonPaths.SdCardFileSystemMountName.Length); + path = path.Slice(SdCardFileSystemMountName.Length); Result res = _config.BaseFsService.OpenSdCardProxyFileSystem(ref outFileSystem); if (res.IsFailure()) return res.Miss(); } - else if (StringUtils.Compare(path, CommonPaths.HostRootFileSystemMountName, - CommonPaths.HostRootFileSystemMountName.Length) == 0) + else if (StringUtils.Compare(path, HostRootFileSystemMountName, + HostRootFileSystemMountName.Length) == 0) { - path = path.Slice(CommonPaths.HostRootFileSystemMountName.Length); + path = path.Slice(HostRootFileSystemMountName.Length); using var rootPathEmpty = new Path(); Result res = rootPathEmpty.InitializeAsEmpty(); @@ -453,10 +448,10 @@ public class NcaFileSystemServiceImpl if (res.IsFailure()) return res.Miss(); } - else if (StringUtils.Compare(path, CommonPaths.RegisteredUpdatePartitionMountName, - CommonPaths.RegisteredUpdatePartitionMountName.Length) == 0) + else if (StringUtils.Compare(path, RegisteredUpdatePartitionMountName, + RegisteredUpdatePartitionMountName.Length) == 0) { - path = path.Slice(CommonPaths.RegisteredUpdatePartitionMountName.Length); + path = path.Slice(RegisteredUpdatePartitionMountName.Length); info.CanMountNca = true; @@ -903,10 +898,6 @@ public class NcaFileSystemServiceImpl return ResultFs.InvalidArgument.Log(); } } - - private static ReadOnlySpan SdCardNintendoRootDirectoryName => "Nintendo"u8; - - 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 7d46776a..e2e81c7d 100644 --- a/src/LibHac/FsSrv/SaveDataFileSystemService.cs +++ b/src/LibHac/FsSrv/SaveDataFileSystemService.cs @@ -680,7 +680,7 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave if (res.IsFailure()) { Hos.Diag.Impl.LogImpl(Log.EmptyModuleName, LogSeverity.Info, - "[fs] Error: Failed to rollback save data indexer.\n".ToU8Span()); + "[fs] Error: Failed to rollback save data indexer.\n"u8); } } } diff --git a/src/LibHac/FsSrv/SaveDataFileSystemServiceImpl.cs b/src/LibHac/FsSrv/SaveDataFileSystemServiceImpl.cs index 20196246..d56ad3d6 100644 --- a/src/LibHac/FsSrv/SaveDataFileSystemServiceImpl.cs +++ b/src/LibHac/FsSrv/SaveDataFileSystemServiceImpl.cs @@ -759,7 +759,7 @@ public class SaveDataFileSystemServiceImpl : IDisposable using scoped var pathParent = new Path(); res = PathFunctions.SetUpFixedPathSingleEntry(ref pathParent.Ref(), pathParentBuffer.Items, - CommonPaths.SdCardNintendoRootDirectoryName); + CommonDirNames.SdCardNintendoRootDirectoryName); if (res.IsFailure()) return res.Miss(); using scoped var pathSdRoot = new Path(); diff --git a/src/LibHac/FsSystem/Utility.cs b/src/LibHac/FsSystem/Utility.cs index 536a8271..f8e91a95 100644 --- a/src/LibHac/FsSystem/Utility.cs +++ b/src/LibHac/FsSystem/Utility.cs @@ -22,7 +22,7 @@ internal static class Utility /// It contains various fields that can used if needed to pass references to methods. /// The main shortcomings are that every type that might possibly be passed must have a field in the struct. /// The struct must also be manually passed through the method. - /// And because ref fields aren't as thing as of C# 10, some ref structs may have to be copied into the closure struct. + /// And because ref fields to ref structs aren't as thing as of C# 11, some ref structs may have to be copied into the closure struct. /// [NonCopyable] public ref struct FsIterationTaskClosure diff --git a/src/LibHac/Tools/Fs/SwitchFs.cs b/src/LibHac/Tools/Fs/SwitchFs.cs index c3f73a8c..1fa08694 100644 --- a/src/LibHac/Tools/Fs/SwitchFs.cs +++ b/src/LibHac/Tools/Fs/SwitchFs.cs @@ -48,10 +48,10 @@ public class SwitchFs : IDisposable var concatFs = new ConcatenationFileSystem(ref fileSystem); using var contentDirPath = new LibHac.Fs.Path(); - PathFunctions.SetUpFixedPath(ref contentDirPath.Ref(), "/Nintendo/Contents".ToU8String()).ThrowIfFailure(); + PathFunctions.SetUpFixedPath(ref contentDirPath.Ref(), "/Nintendo/Contents"u8).ThrowIfFailure(); using var saveDirPath = new LibHac.Fs.Path(); - PathFunctions.SetUpFixedPath(ref saveDirPath.Ref(), "/Nintendo/save".ToU8String()).ThrowIfFailure(); + PathFunctions.SetUpFixedPath(ref saveDirPath.Ref(), "/Nintendo/save"u8).ThrowIfFailure(); var contentDirFs = new SubdirectoryFileSystem(concatFs); contentDirFs.Initialize(in contentDirPath).ThrowIfFailure(); @@ -79,14 +79,14 @@ public class SwitchFs : IDisposable if (concatFs.DirectoryExists("/save")) { using var savePath = new LibHac.Fs.Path(); - PathFunctions.SetUpFixedPath(ref savePath.Ref(), "/save".ToU8String()); + PathFunctions.SetUpFixedPath(ref savePath.Ref(), "/save"u8); saveDirFs = new SubdirectoryFileSystem(concatFs); saveDirFs.Initialize(in savePath).ThrowIfFailure(); } using var contentsPath = new LibHac.Fs.Path(); - PathFunctions.SetUpFixedPath(ref contentsPath.Ref(), "/Contents".ToU8String()); + PathFunctions.SetUpFixedPath(ref contentsPath.Ref(), "/Contents"u8); contentDirFs = new SubdirectoryFileSystem(concatFs); contentDirFs.Initialize(in contentsPath).ThrowIfFailure(); @@ -227,7 +227,7 @@ public class SwitchFs : IDisposable using (var control = new UniqueRef()) { - romfs.OpenFile(ref control.Ref(), "/control.nacp".ToU8Span(), OpenMode.Read).ThrowIfFailure(); + romfs.OpenFile(ref control.Ref(), "/control.nacp"u8, OpenMode.Read).ThrowIfFailure(); control.Get.Read(out _, 0, title.Control.ByteSpan).ThrowIfFailure(); } diff --git a/src/hactoolnet/ProcessDelta.cs b/src/hactoolnet/ProcessDelta.cs index 7d965b0e..f7ec5a58 100644 --- a/src/hactoolnet/ProcessDelta.cs +++ b/src/hactoolnet/ProcessDelta.cs @@ -38,7 +38,7 @@ internal static class ProcessDelta } using var deltaFragmentFile = new UniqueRef(); - fs.OpenFile(ref deltaFragmentFile.Ref(), FragmentFileName.ToU8String(), OpenMode.Read).ThrowIfFailure(); + fs.OpenFile(ref deltaFragmentFile.Ref(), FragmentFileName.ToU8Span(), OpenMode.Read).ThrowIfFailure(); deltaStorage = deltaFragmentFile.Release().AsStorage(); } diff --git a/src/hactoolnet/ProcessNca.cs b/src/hactoolnet/ProcessNca.cs index 6029be02..ecaf5524 100644 --- a/src/hactoolnet/ProcessNca.cs +++ b/src/hactoolnet/ProcessNca.cs @@ -77,15 +77,15 @@ internal static class ProcessNca using var outputFs = new UniqueRef(new LocalFileSystem(ctx.Options.SectionOutDir[i])); fs.Register(mountName.ToU8Span(), ref inputFs.Ref()); - fs.Register("output".ToU8Span(), ref outputFs.Ref()); + fs.Register("output"u8, ref outputFs.Ref()); fs.Impl.EnableFileSystemAccessorAccessLog(mountName.ToU8Span()); - fs.Impl.EnableFileSystemAccessorAccessLog("output".ToU8Span()); + fs.Impl.EnableFileSystemAccessorAccessLog("output"u8); - FsUtils.CopyDirectoryWithProgress(fs, (mountName + ":/").ToU8Span(), "output:/".ToU8Span(), logger: ctx.Logger).ThrowIfFailure(); + FsUtils.CopyDirectoryWithProgress(fs, (mountName + ":/").ToU8Span(), "output:/"u8, logger: ctx.Logger).ThrowIfFailure(); fs.Unmount(mountName.ToU8Span()); - fs.Unmount("output".ToU8Span()); + fs.Unmount("output"u8); } if (ctx.Options.Validate && nca.SectionExists(i)) @@ -131,16 +131,16 @@ internal static class ProcessNca using var inputFs = new UniqueRef(OpenFileSystemByType(NcaSectionType.Data)); using var outputFs = new UniqueRef(new LocalFileSystem(ctx.Options.RomfsOutDir)); - fs.Register("rom".ToU8Span(), ref inputFs.Ref()); - fs.Register("output".ToU8Span(), ref outputFs.Ref()); + fs.Register("rom"u8, ref inputFs.Ref()); + fs.Register("output"u8, ref outputFs.Ref()); - fs.Impl.EnableFileSystemAccessorAccessLog("rom".ToU8Span()); - fs.Impl.EnableFileSystemAccessorAccessLog("output".ToU8Span()); + fs.Impl.EnableFileSystemAccessorAccessLog("rom"u8); + fs.Impl.EnableFileSystemAccessorAccessLog("output"u8); - FsUtils.CopyDirectoryWithProgress(fs, "rom:/".ToU8Span(), "output:/".ToU8Span(), logger: ctx.Logger).ThrowIfFailure(); + FsUtils.CopyDirectoryWithProgress(fs, "rom:/"u8, "output:/"u8, logger: ctx.Logger).ThrowIfFailure(); - fs.Unmount("rom".ToU8Span()); - fs.Unmount("output".ToU8Span()); + fs.Unmount("rom"u8); + fs.Unmount("output"u8); } if (ctx.Options.ReadBench) @@ -194,16 +194,16 @@ internal static class ProcessNca using var inputFs = new UniqueRef(OpenFileSystemByType(NcaSectionType.Code)); using var outputFs = new UniqueRef(new LocalFileSystem(ctx.Options.ExefsOutDir)); - fs.Register("code".ToU8Span(), ref inputFs.Ref()); - fs.Register("output".ToU8Span(), ref outputFs.Ref()); + fs.Register("code"u8, ref inputFs.Ref()); + fs.Register("output"u8, ref outputFs.Ref()); - fs.Impl.EnableFileSystemAccessorAccessLog("code".ToU8Span()); - fs.Impl.EnableFileSystemAccessorAccessLog("output".ToU8Span()); + fs.Impl.EnableFileSystemAccessorAccessLog("code"u8); + fs.Impl.EnableFileSystemAccessorAccessLog("output"u8); - FsUtils.CopyDirectoryWithProgress(fs, "code:/".ToU8Span(), "output:/".ToU8Span(), logger: ctx.Logger).ThrowIfFailure(); + FsUtils.CopyDirectoryWithProgress(fs, "code:/"u8, "output:/"u8, logger: ctx.Logger).ThrowIfFailure(); - fs.Unmount("code".ToU8Span()); - fs.Unmount("output".ToU8Span()); + fs.Unmount("code"u8); + fs.Unmount("output"u8); } } @@ -260,7 +260,7 @@ internal static class ProcessNca if (!pfs.FileExists("main.npdm")) return Validity.Unchecked; using var npdmFile = new UniqueRef(); - pfs.OpenFile(ref npdmFile.Ref(), "main.npdm".ToU8String(), OpenMode.Read).ThrowIfFailure(); + pfs.OpenFile(ref npdmFile.Ref(), "main.npdm"u8, OpenMode.Read).ThrowIfFailure(); var npdm = new NpdmBinary(npdmFile.Release().AsStream()); return nca.Header.VerifySignature2(npdm.AciD.Rsa2048Modulus); @@ -293,7 +293,7 @@ internal static class ProcessNca IFileSystem fs = nca.OpenFileSystem(NcaSectionType.Code, IntegrityCheckLevel.None); using var file = new UniqueRef(); - Result res = fs.OpenFile(ref file.Ref(), "/main.npdm".ToU8String(), OpenMode.Read); + Result res = fs.OpenFile(ref file.Ref(), "/main.npdm"u8, OpenMode.Read); if (res.IsSuccess()) { var npdm = new NpdmBinary(file.Release().AsStream(), null); diff --git a/src/hactoolnet/ProcessSave.cs b/src/hactoolnet/ProcessSave.cs index fb16f87f..d65ce3a8 100644 --- a/src/hactoolnet/ProcessSave.cs +++ b/src/hactoolnet/ProcessSave.cs @@ -37,8 +37,8 @@ internal static class ProcessSave FileSystemClient fs = ctx.Horizon.Fs; using var saveUnique = new UniqueRef(save); - fs.Register("save".ToU8Span(), ref saveUnique.Ref()); - fs.Impl.EnableFileSystemAccessorAccessLog("save".ToU8Span()); + fs.Register("save"u8, ref saveUnique.Ref()); + fs.Impl.EnableFileSystemAccessorAccessLog("save"u8); if (ctx.Options.Validate) { @@ -48,12 +48,12 @@ internal static class ProcessSave if (ctx.Options.OutDir != null) { using var outputFs = new UniqueRef(new LocalFileSystem(ctx.Options.OutDir)); - fs.Register("output".ToU8Span(), ref outputFs.Ref()); - fs.Impl.EnableFileSystemAccessorAccessLog("output".ToU8Span()); + fs.Register("output"u8, ref outputFs.Ref()); + fs.Impl.EnableFileSystemAccessorAccessLog("output"u8); - FsUtils.CopyDirectoryWithProgress(fs, "save:/".ToU8Span(), "output:/".ToU8Span(), logger: ctx.Logger).ThrowIfFailure(); + FsUtils.CopyDirectoryWithProgress(fs, "save:/"u8, "output:/"u8, logger: ctx.Logger).ThrowIfFailure(); - fs.Unmount("output".ToU8Span()); + fs.Unmount("output"u8); } if (ctx.Options.DebugOutDir != null) @@ -73,7 +73,7 @@ internal static class ProcessSave using var inFile = new UniqueRef(new LocalFile(ctx.Options.ReplaceFileSource, OpenMode.Read)); using var outFile = new UniqueRef(); - save.OpenFile(ref outFile.Ref(), destFilename.ToU8String(), OpenMode.ReadWrite).ThrowIfFailure(); + save.OpenFile(ref outFile.Ref(), destFilename.ToU8Span(), OpenMode.ReadWrite).ThrowIfFailure(); inFile.Get.GetSize(out long inFileSize).ThrowIfFailure(); outFile.Get.GetSize(out long outFileSize).ThrowIfFailure(); @@ -93,16 +93,16 @@ internal static class ProcessSave if (ctx.Options.RepackSource != null) { using var inputFs = new UniqueRef(new LocalFileSystem(ctx.Options.RepackSource)); - fs.Register("input".ToU8Span(), ref inputFs.Ref()); - fs.Impl.EnableFileSystemAccessorAccessLog("input".ToU8Span()); + fs.Register("input"u8, ref inputFs.Ref()); + fs.Impl.EnableFileSystemAccessorAccessLog("input"u8); - fs.CleanDirectoryRecursively("save:/".ToU8Span()); - fs.Commit("save".ToU8Span()); + fs.CleanDirectoryRecursively("save:/"u8); + fs.Commit("save"u8); - FsUtils.CopyDirectoryWithProgress(fs, "input:/".ToU8Span(), "save:/".ToU8Span(), logger: ctx.Logger).ThrowIfFailure(); + FsUtils.CopyDirectoryWithProgress(fs, "input:/"u8, "save:/"u8, logger: ctx.Logger).ThrowIfFailure(); - fs.Commit("save".ToU8Span()); - fs.Unmount("input".ToU8Span()); + fs.Commit("save"u8); + fs.Unmount("input"u8); signNeeded = true; } @@ -144,7 +144,7 @@ internal static class ProcessSave ctx.Logger.LogMessage("Unable to sign save file. Do you have all the required keys?"); } - fs.Unmount("save".ToU8Span()); + fs.Unmount("save"u8); return; } @@ -159,7 +159,7 @@ internal static class ProcessSave ctx.Logger.LogMessage(save.Print(ctx.KeySet)); //ctx.Logger.LogMessage(PrintFatLayout(save.SaveDataFileSystemCore)); - fs.Unmount("save".ToU8Span()); + fs.Unmount("save"u8); } } diff --git a/tests/LibHac.Tests/Fs/FileSystemClientTests/ShimTests/BcatSaveData.cs b/tests/LibHac.Tests/Fs/FileSystemClientTests/ShimTests/BcatSaveData.cs index 1053da2c..7459eac8 100644 --- a/tests/LibHac.Tests/Fs/FileSystemClientTests/ShimTests/BcatSaveData.cs +++ b/tests/LibHac.Tests/Fs/FileSystemClientTests/ShimTests/BcatSaveData.cs @@ -1,5 +1,4 @@ -using LibHac.Common; -using LibHac.Fs; +using LibHac.Fs; using LibHac.Fs.Fsa; using LibHac.Fs.Shim; using Xunit; @@ -14,7 +13,7 @@ public class BcatSaveData var applicationId = new Ncm.ApplicationId(1); FileSystemClient fs = FileSystemServerFactory.CreateClient(true); - Assert.Result(ResultFs.TargetNotFound, fs.MountBcatSaveData("bcat_test".ToU8Span(), applicationId)); + Assert.Result(ResultFs.TargetNotFound, fs.MountBcatSaveData("bcat_test"u8, applicationId)); } [Fact] @@ -24,7 +23,7 @@ public class BcatSaveData FileSystemClient fs = FileSystemServerFactory.CreateClient(true); Assert.Success(fs.CreateBcatSaveData(applicationId, 0x400000)); - Assert.Success(fs.MountBcatSaveData("bcat_test".ToU8Span(), applicationId)); + Assert.Success(fs.MountBcatSaveData("bcat_test"u8, applicationId)); } [Fact] @@ -34,17 +33,17 @@ public class BcatSaveData FileSystemClient fs = FileSystemServerFactory.CreateClient(true); Assert.Success(fs.CreateBcatSaveData(applicationId, 0x400000)); - Assert.Success(fs.MountBcatSaveData("bcat_test".ToU8Span(), applicationId)); + Assert.Success(fs.MountBcatSaveData("bcat_test"u8, applicationId)); // Check that the path doesn't exist - Assert.Result(ResultFs.PathNotFound, fs.GetEntryType(out _, "bcat_test:/file".ToU8Span())); + Assert.Result(ResultFs.PathNotFound, fs.GetEntryType(out _, "bcat_test:/file"u8)); - fs.CreateFile("bcat_test:/file".ToU8Span(), 0); - fs.Commit("bcat_test".ToU8Span()); - fs.Unmount("bcat_test".ToU8Span()); + fs.CreateFile("bcat_test:/file"u8, 0); + fs.Commit("bcat_test"u8); + fs.Unmount("bcat_test"u8); - Assert.Success(fs.MountBcatSaveData("bcat_test".ToU8Span(), applicationId)); - Assert.Success(fs.GetEntryType(out DirectoryEntryType type, "bcat_test:/file".ToU8Span())); + Assert.Success(fs.MountBcatSaveData("bcat_test"u8, applicationId)); + Assert.Success(fs.GetEntryType(out DirectoryEntryType type, "bcat_test:/file"u8)); Assert.Equal(DirectoryEntryType.File, type); } } \ No newline at end of file diff --git a/tests/LibHac.Tests/Fs/FileSystemClientTests/ShimTests/Bis.cs b/tests/LibHac.Tests/Fs/FileSystemClientTests/ShimTests/Bis.cs index 785bd34d..a92abac5 100644 --- a/tests/LibHac.Tests/Fs/FileSystemClientTests/ShimTests/Bis.cs +++ b/tests/LibHac.Tests/Fs/FileSystemClientTests/ShimTests/Bis.cs @@ -1,5 +1,4 @@ -using LibHac.Common; -using LibHac.Fs; +using LibHac.Fs; using LibHac.Fs.Fsa; using LibHac.Fs.Shim; using Xunit; @@ -13,13 +12,13 @@ public class Bis { FileSystemClient fs = FileSystemServerFactory.CreateClient(out IFileSystem rootFs); - Assert.Success(fs.MountBis("calib".ToU8Span(), BisPartitionId.CalibrationFile)); + Assert.Success(fs.MountBis("calib"u8, BisPartitionId.CalibrationFile)); // Create a file in the opened file system - Assert.Success(fs.CreateFile("calib:/file".ToU8Span(), 0)); + Assert.Success(fs.CreateFile("calib:/file"u8, 0)); // Make sure the file exists on the root file system - Assert.Success(rootFs.GetEntryType(out DirectoryEntryType type, "/bis/cal/file".ToU8Span())); + Assert.Success(rootFs.GetEntryType(out DirectoryEntryType type, "/bis/cal/file"u8)); Assert.Equal(DirectoryEntryType.File, type); } @@ -28,13 +27,13 @@ public class Bis { FileSystemClient fs = FileSystemServerFactory.CreateClient(out IFileSystem rootFs); - Assert.Success(fs.MountBis("safe".ToU8Span(), BisPartitionId.SafeMode)); + Assert.Success(fs.MountBis("safe"u8, BisPartitionId.SafeMode)); // Create a file in the opened file system - Assert.Success(fs.CreateFile("safe:/file".ToU8Span(), 0)); + Assert.Success(fs.CreateFile("safe:/file"u8, 0)); // Make sure the file exists on the root file system - Assert.Success(rootFs.GetEntryType(out DirectoryEntryType type, "/bis/safe/file".ToU8Span())); + Assert.Success(rootFs.GetEntryType(out DirectoryEntryType type, "/bis/safe/file"u8)); Assert.Equal(DirectoryEntryType.File, type); } @@ -43,13 +42,13 @@ public class Bis { FileSystemClient fs = FileSystemServerFactory.CreateClient(out IFileSystem rootFs); - Assert.Success(fs.MountBis("system".ToU8Span(), BisPartitionId.System)); + Assert.Success(fs.MountBis("system"u8, BisPartitionId.System)); // Create a file in the opened file system - Assert.Success(fs.CreateFile("system:/file".ToU8Span(), 0)); + Assert.Success(fs.CreateFile("system:/file"u8, 0)); // Make sure the file exists on the root file system - Assert.Success(rootFs.GetEntryType(out DirectoryEntryType type, "/bis/system/file".ToU8Span())); + Assert.Success(rootFs.GetEntryType(out DirectoryEntryType type, "/bis/system/file"u8)); Assert.Equal(DirectoryEntryType.File, type); } @@ -58,13 +57,13 @@ public class Bis { FileSystemClient fs = FileSystemServerFactory.CreateClient(out IFileSystem rootFs); - Assert.Success(fs.MountBis("user".ToU8Span(), BisPartitionId.User)); + Assert.Success(fs.MountBis("user"u8, BisPartitionId.User)); // Create a file in the opened file system - Assert.Success(fs.CreateFile("user:/file".ToU8Span(), 0)); + Assert.Success(fs.CreateFile("user:/file"u8, 0)); // Make sure the file exists on the root file system - Assert.Success(rootFs.GetEntryType(out DirectoryEntryType type, "/bis/user/file".ToU8Span())); + Assert.Success(rootFs.GetEntryType(out DirectoryEntryType type, "/bis/user/file"u8)); Assert.Equal(DirectoryEntryType.File, type); } @@ -73,16 +72,16 @@ public class Bis { FileSystemClient fs = FileSystemServerFactory.CreateClient(out IFileSystem rootFs); - Assert.Success(fs.MountBis(BisPartitionId.User, "/sub".ToU8Span())); + Assert.Success(fs.MountBis(BisPartitionId.User, "/sub"u8)); // Create a file in the opened file system - Assert.Success(fs.CreateFile("@User:/file".ToU8Span(), 0)); + Assert.Success(fs.CreateFile("@User:/file"u8, 0)); // Make sure the file wasn't created in the sub path - Assert.Result(ResultFs.PathNotFound, rootFs.GetEntryType(out _, "/bis/user/sub/file".ToU8Span())); + Assert.Result(ResultFs.PathNotFound, rootFs.GetEntryType(out _, "/bis/user/sub/file"u8)); // Make sure the file was created in the main path - Assert.Success(rootFs.GetEntryType(out DirectoryEntryType type, "/bis/user/file".ToU8Span())); + Assert.Success(rootFs.GetEntryType(out DirectoryEntryType type, "/bis/user/file"u8)); Assert.Equal(DirectoryEntryType.File, type); } @@ -91,6 +90,6 @@ public class Bis { FileSystemClient fs = FileSystemServerFactory.CreateClient(out IFileSystem _); - Assert.Result(ResultFs.InvalidArgument, fs.MountBis("boot1".ToU8Span(), BisPartitionId.BootPartition1Root)); + Assert.Result(ResultFs.InvalidArgument, fs.MountBis("boot1"u8, BisPartitionId.BootPartition1Root)); } } \ No newline at end of file diff --git a/tests/LibHac.Tests/Fs/FileSystemClientTests/ShimTests/DeviceSaveData.cs b/tests/LibHac.Tests/Fs/FileSystemClientTests/ShimTests/DeviceSaveData.cs index ef205047..56491c1f 100644 --- a/tests/LibHac.Tests/Fs/FileSystemClientTests/ShimTests/DeviceSaveData.cs +++ b/tests/LibHac.Tests/Fs/FileSystemClientTests/ShimTests/DeviceSaveData.cs @@ -1,5 +1,4 @@ -using LibHac.Common; -using LibHac.Fs; +using LibHac.Fs; using LibHac.Fs.Shim; using LibHac.FsSrv.Impl; using Xunit; @@ -14,8 +13,8 @@ public class DeviceSaveData var applicationId = new Ncm.ApplicationId(1234); HorizonServerSet hos = FileSystemServerFactory.CreateHorizon(applicationId, fsAcBits: AccessControlBits.Bits.FullPermission); - Assert.Result(ResultFs.TargetNotFound, hos.Client.Fs.MountDeviceSaveData("device".ToU8Span(), applicationId)); - Assert.Result(ResultFs.TargetNotFound, hos.Client.Fs.MountDeviceSaveData("device2".ToU8Span())); + Assert.Result(ResultFs.TargetNotFound, hos.Client.Fs.MountDeviceSaveData("device"u8, applicationId)); + Assert.Result(ResultFs.TargetNotFound, hos.Client.Fs.MountDeviceSaveData("device2"u8)); } [Fact] @@ -25,8 +24,8 @@ public class DeviceSaveData HorizonServerSet hos = FileSystemServerFactory.CreateHorizon(applicationId, fsAcBits: AccessControlBits.Bits.FullPermission); Assert.Success(hos.Client.Fs.CreateDeviceSaveData(applicationId, applicationId.Value, 0, 0, SaveDataFlags.None)); - Assert.Success(hos.Client.Fs.MountDeviceSaveData("device".ToU8Span())); - Assert.Success(hos.Client.Fs.MountDeviceSaveData("device2".ToU8Span(), applicationId)); + Assert.Success(hos.Client.Fs.MountDeviceSaveData("device"u8)); + Assert.Success(hos.Client.Fs.MountDeviceSaveData("device2"u8, applicationId)); } [Fact] @@ -37,10 +36,10 @@ public class DeviceSaveData HorizonServerSet hos = FileSystemServerFactory.CreateHorizon(ownApplicationId, fsAcBits: AccessControlBits.Bits.FullPermission); Assert.Success(hos.Client.Fs.CreateDeviceSaveData(otherApplicationId, otherApplicationId.Value, 0, 0, SaveDataFlags.None)); - Assert.Success(hos.Client.Fs.MountDeviceSaveData("device".ToU8Span(), otherApplicationId)); + Assert.Success(hos.Client.Fs.MountDeviceSaveData("device"u8, otherApplicationId)); // Try to open missing own device save data - Assert.Result(ResultFs.TargetNotFound, hos.Client.Fs.MountDeviceSaveData("device2".ToU8Span())); + Assert.Result(ResultFs.TargetNotFound, hos.Client.Fs.MountDeviceSaveData("device2"u8)); } [Fact] diff --git a/tests/LibHac.Tests/Fs/FileSystemClientTests/ShimTests/SaveData.cs b/tests/LibHac.Tests/Fs/FileSystemClientTests/ShimTests/SaveData.cs index a54043f9..be2bf16e 100644 --- a/tests/LibHac.Tests/Fs/FileSystemClientTests/ShimTests/SaveData.cs +++ b/tests/LibHac.Tests/Fs/FileSystemClientTests/ShimTests/SaveData.cs @@ -1,5 +1,4 @@ -using LibHac.Common; -using LibHac.Fs; +using LibHac.Fs; using LibHac.Fs.Fsa; using LibHac.Fs.Shim; using Xunit; @@ -16,7 +15,7 @@ public class SaveData fs.CreateCacheStorage(applicationId, SaveDataSpaceId.User, applicationId.Value, 0, 0, SaveDataFlags.None); - Assert.Success(fs.MountCacheStorage("cache".ToU8Span(), applicationId)); + Assert.Success(fs.MountCacheStorage("cache"u8, applicationId)); } [Fact] @@ -26,14 +25,14 @@ public class SaveData FileSystemClient fs = FileSystemServerFactory.CreateClient(true); fs.CreateCacheStorage(applicationId, SaveDataSpaceId.SdUser, applicationId.Value, 0, 0, SaveDataFlags.None); - fs.MountCacheStorage("cache".ToU8Span(), applicationId); + fs.MountCacheStorage("cache"u8, applicationId); - fs.CreateFile("cache:/file".ToU8Span(), 0); - fs.Commit("cache".ToU8Span()); - fs.Unmount("cache".ToU8Span()); + fs.CreateFile("cache:/file"u8, 0); + fs.Commit("cache"u8); + fs.Unmount("cache"u8); - Assert.Success(fs.MountCacheStorage("cache".ToU8Span(), applicationId)); - Assert.Success(fs.GetEntryType(out DirectoryEntryType type, "cache:/file".ToU8Span())); + Assert.Success(fs.MountCacheStorage("cache"u8, applicationId)); + Assert.Success(fs.GetEntryType(out DirectoryEntryType type, "cache:/file"u8)); Assert.Equal(DirectoryEntryType.File, type); } @@ -44,24 +43,24 @@ public class SaveData FileSystemClient fs = FileSystemServerFactory.CreateClient(true); Assert.Success(fs.CreateCacheStorage(applicationId, SaveDataSpaceId.SdUser, applicationId.Value, 0, 0, SaveDataFlags.None)); - Assert.Success(fs.MountCacheStorage("cache".ToU8Span(), applicationId)); - fs.CreateFile("cache:/sd".ToU8Span(), 0); - fs.Commit("cache".ToU8Span()); - fs.Unmount("cache".ToU8Span()); + Assert.Success(fs.MountCacheStorage("cache"u8, applicationId)); + fs.CreateFile("cache:/sd"u8, 0); + fs.Commit("cache"u8); + fs.Unmount("cache"u8); // Turn off the SD card so the User save is mounted fs.SetSdCardAccessibility(false); fs.CreateCacheStorage(applicationId, SaveDataSpaceId.User, applicationId.Value, 0, 0, SaveDataFlags.None); - fs.MountCacheStorage("cache".ToU8Span(), applicationId); - fs.CreateFile("cache:/bis".ToU8Span(), 0); - fs.Commit("cache".ToU8Span()); - fs.Unmount("cache".ToU8Span()); + fs.MountCacheStorage("cache"u8, applicationId); + fs.CreateFile("cache:/bis"u8, 0); + fs.Commit("cache"u8); + fs.Unmount("cache"u8); fs.SetSdCardAccessibility(true); - Assert.Success(fs.MountCacheStorage("cache".ToU8String(), applicationId)); - Assert.Success(fs.GetEntryType(out _, "cache:/sd".ToU8Span())); - Assert.Failure(fs.GetEntryType(out _, "cache:/bis".ToU8Span())); + Assert.Success(fs.MountCacheStorage("cache"u8, applicationId)); + Assert.Success(fs.GetEntryType(out _, "cache:/sd"u8)); + Assert.Failure(fs.GetEntryType(out _, "cache:/bis"u8)); } } \ No newline at end of file diff --git a/tests/LibHac.Tests/Fs/FileSystemClientTests/ShimTests/SdCard.cs b/tests/LibHac.Tests/Fs/FileSystemClientTests/ShimTests/SdCard.cs index 8896e3b2..63acfe99 100644 --- a/tests/LibHac.Tests/Fs/FileSystemClientTests/ShimTests/SdCard.cs +++ b/tests/LibHac.Tests/Fs/FileSystemClientTests/ShimTests/SdCard.cs @@ -1,5 +1,4 @@ -using LibHac.Common; -using LibHac.Fs; +using LibHac.Fs; using LibHac.Fs.Fsa; using LibHac.Fs.Shim; using Xunit; @@ -13,7 +12,7 @@ public class SdCard { FileSystemClient fs = FileSystemServerFactory.CreateClient(true); - Assert.Success(fs.MountSdCard("sdcard".ToU8Span())); + Assert.Success(fs.MountSdCard("sdcard"u8)); } [Fact] @@ -21,7 +20,7 @@ public class SdCard { FileSystemClient fs = FileSystemServerFactory.CreateClient(false); - Assert.Result(ResultFs.PortSdCardNoDevice, fs.MountSdCard("sdcard".ToU8Span())); + Assert.Result(ResultFs.PortSdCardNoDevice, fs.MountSdCard("sdcard"u8)); } [Fact] @@ -29,9 +28,9 @@ public class SdCard { FileSystemClient fs = FileSystemServerFactory.CreateClient(true); - fs.MountSdCard("sdcard".ToU8String()); + fs.MountSdCard("sdcard"u8); - Assert.Success(fs.CreateFile("sdcard:/file".ToU8Span(), 100, CreateFileOptions.None)); + Assert.Success(fs.CreateFile("sdcard:/file"u8, 100, CreateFileOptions.None)); } [Fact] diff --git a/tests/LibHac.Tests/Fs/IFileSystemTestBase/IFileSystemTests.GetEntryType.cs b/tests/LibHac.Tests/Fs/IFileSystemTestBase/IFileSystemTests.GetEntryType.cs index 537d8e44..84c8dfe2 100644 --- a/tests/LibHac.Tests/Fs/IFileSystemTestBase/IFileSystemTests.GetEntryType.cs +++ b/tests/LibHac.Tests/Fs/IFileSystemTestBase/IFileSystemTests.GetEntryType.cs @@ -1,5 +1,4 @@ -using LibHac.Common; -using LibHac.Fs; +using LibHac.Fs; using LibHac.Fs.Fsa; using Xunit; @@ -12,7 +11,7 @@ public abstract partial class IFileSystemTests { IFileSystem fs = CreateFileSystem(); - Assert.Success(fs.GetEntryType(out DirectoryEntryType type, "/".ToU8Span())); + Assert.Success(fs.GetEntryType(out DirectoryEntryType type, "/"u8)); Assert.Equal(DirectoryEntryType.Directory, type); } @@ -22,6 +21,6 @@ public abstract partial class IFileSystemTests { IFileSystem fs = CreateFileSystem(); - Assert.Result(ResultFs.PathNotFound, fs.GetEntryType(out _, "/path".ToU8Span())); + Assert.Result(ResultFs.PathNotFound, fs.GetEntryType(out _, "/path"u8)); } } \ No newline at end of file diff --git a/tests/LibHac.Tests/Fs/SubdirectoryFileSystemTests.cs b/tests/LibHac.Tests/Fs/SubdirectoryFileSystemTests.cs index 5770ee8e..4a6a3f1a 100644 --- a/tests/LibHac.Tests/Fs/SubdirectoryFileSystemTests.cs +++ b/tests/LibHac.Tests/Fs/SubdirectoryFileSystemTests.cs @@ -1,5 +1,4 @@ -using LibHac.Common; -using LibHac.Fs; +using LibHac.Fs; using LibHac.Fs.Fsa; using LibHac.FsSystem; using LibHac.Tests.Fs.IFileSystemTestBase; @@ -22,7 +21,7 @@ public class SubdirectoryFileSystemTests : IFileSystemTests baseFs.CreateDirectory("/sub/path"); using var rootPath = new Path(); - PathFunctions.SetUpFixedPath(ref rootPath.Ref(), "/sub/path".ToU8String()); + PathFunctions.SetUpFixedPath(ref rootPath.Ref(), "/sub/path"u8); var subFs = new SubdirectoryFileSystem(baseFs); subFs.Initialize(in rootPath).ThrowIfFailure(); @@ -60,7 +59,7 @@ public class SubdirectoryFileSystemTestsRoot : IFileSystemTests var baseFs = new InMemoryFileSystem(); using var rootPath = new Path(); - PathFunctions.SetUpFixedPath(ref rootPath.Ref(), "/".ToU8String()); + PathFunctions.SetUpFixedPath(ref rootPath.Ref(), "/"u8); var subFs = new SubdirectoryFileSystem(baseFs); subFs.Initialize(in rootPath).ThrowIfFailure(); diff --git a/tests/LibHac.Tests/FsSrv/AccessControlTests.cs b/tests/LibHac.Tests/FsSrv/AccessControlTests.cs index 571d0df1..fd9df95d 100644 --- a/tests/LibHac.Tests/FsSrv/AccessControlTests.cs +++ b/tests/LibHac.Tests/FsSrv/AccessControlTests.cs @@ -31,7 +31,7 @@ public class AccessControlTests StorageId.BuiltInUser, SpanHelpers.AsReadOnlyByteSpan(in dataHeader), SpanHelpers.AsReadOnlyByteSpan(in descriptor))); - Result res = client.Fs.MountContent("test".ToU8Span(), "@System:/fake.nca".ToU8Span(), ContentType.Meta); + Result res = client.Fs.MountContent("test"u8, "@System:/fake.nca"u8, ContentType.Meta); Assert.Result(ResultFs.PermissionDenied, res); } @@ -57,7 +57,7 @@ public class AccessControlTests SpanHelpers.AsReadOnlyByteSpan(in descriptor))); // We should get UnexpectedInNcaFileSystemServiceImplA because mounting NCAs from @System isn't allowed - Result res = client.Fs.MountContent("test".ToU8Span(), "@System:/fake.nca".ToU8Span(), ContentType.Meta); + Result res = client.Fs.MountContent("test"u8, "@System:/fake.nca"u8, ContentType.Meta); Assert.Result(ResultFs.UnexpectedInNcaFileSystemServiceImplA, res); } } \ No newline at end of file diff --git a/tests/LibHac.Tests/Kvdb/FlatMapKeyValueStoreTests.cs b/tests/LibHac.Tests/Kvdb/FlatMapKeyValueStoreTests.cs index 91941f0e..63eb9666 100644 --- a/tests/LibHac.Tests/Kvdb/FlatMapKeyValueStoreTests.cs +++ b/tests/LibHac.Tests/Kvdb/FlatMapKeyValueStoreTests.cs @@ -12,9 +12,9 @@ namespace LibHac.Tests.Kvdb; public class FlatMapKeyValueStoreTests { - private static readonly U8String MountName = new U8String("mount"); - private static readonly U8String RootPath = new U8String("mount:/"); - private static readonly U8String ArchiveFilePath = new U8String("mount:/imkvdb.arc"); + private static ReadOnlySpan MountName => "mount"u8; + private static ReadOnlySpan RootPath => "mount:/"u8; + private static ReadOnlySpan ArchiveFilePath => "mount:/imkvdb.arc"u8; private static (FlatMapKeyValueStore kvStore, FileSystemClient fsClient) Create(int capacity) where T : unmanaged, IEquatable, IComparable diff --git a/tests/LibHac.Tests/PathToolsTests.cs b/tests/LibHac.Tests/PathToolsTests.cs index 44bb94a0..156ba259 100644 --- a/tests/LibHac.Tests/PathToolsTests.cs +++ b/tests/LibHac.Tests/PathToolsTests.cs @@ -187,7 +187,7 @@ public class PathToolsTests [MemberData(nameof(GetFileNameTestItems))] public static void GetFileNameTest(string path, string expected) { - var u8Path = path.ToU8String(); + var u8Path = path.ToU8Span(); ReadOnlySpan fileName = PathTools.GetFileName(u8Path); @@ -211,7 +211,7 @@ public class PathToolsTests [MemberData(nameof(GetLastSegmentTestItems))] public static void GetLastSegmentTest(string path, string expected) { - var u8Path = path.ToU8String(); + var u8Path = path.ToU8Span(); ReadOnlySpan fileName = PathTools.GetLastSegment(u8Path);