mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Add implicit ROS<byte> to U8Span cast and use more UTF-8 literals
This commit is contained in:
parent
3b246535cc
commit
f8766b3cc5
27 changed files with 191 additions and 222 deletions
|
@ -64,6 +64,7 @@ public readonly ref struct U8Span
|
|||
}
|
||||
|
||||
public static implicit operator ReadOnlySpan<byte>(in U8Span value) => value.Value;
|
||||
public static implicit operator U8Span(ReadOnlySpan<byte> value) => new U8Span(value);
|
||||
|
||||
public static explicit operator string(in U8Span value) => value.ToString();
|
||||
public static explicit operator U8Span(string value) => new U8Span(value);
|
||||
|
|
|
@ -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;
|
||||
|
|
12
src/LibHac/Fs/CommonDirNames.cs
Normal file
12
src/LibHac/Fs/CommonDirNames.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
|
||||
namespace LibHac.Fs;
|
||||
|
||||
internal static class CommonDirNames
|
||||
{
|
||||
/// <summary>"<c>Nintendo</c>"</summary>
|
||||
public static ReadOnlySpan<byte> SdCardNintendoRootDirectoryName => "Nintendo"u8;
|
||||
|
||||
/// <summary>"<c>Contents</c>"</summary>
|
||||
public static ReadOnlySpan<byte> ContentStorageDirectoryName => "Contents"u8;
|
||||
}
|
|
@ -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<byte> SdCardNintendoRootDirectoryName => "Nintendo"u8;
|
||||
}
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -17,13 +17,13 @@ public static class CommonMountNames
|
|||
public static ReadOnlySpan<byte> GameCardFileSystemMountName => "@Gc"u8;
|
||||
|
||||
/// <summary>"<c>U</c>"</summary>
|
||||
public static ReadOnlySpan<byte> GameCardFileSystemMountNameUpdateSuffix => "U"u8;
|
||||
public static ReadOnlySpan<byte> GameCardFileSystemMountNameSuffixUpdate => "U"u8;
|
||||
|
||||
/// <summary>"<c>N</c>"</summary>
|
||||
public static ReadOnlySpan<byte> GameCardFileSystemMountNameNormalSuffix => "N"u8;
|
||||
public static ReadOnlySpan<byte> GameCardFileSystemMountNameSuffixNormal => "N"u8;
|
||||
|
||||
/// <summary>"<c>S</c>"</summary>
|
||||
public static ReadOnlySpan<byte> GameCardFileSystemMountNameSecureSuffix => "S"u8;
|
||||
public static ReadOnlySpan<byte> GameCardFileSystemMountNameSuffixSecure => "S"u8;
|
||||
|
||||
// Built-in storage names.
|
||||
/// <summary>"<c>@CalibFile</c>"</summary>
|
||||
|
@ -51,7 +51,4 @@ public static class CommonMountNames
|
|||
// Registered update partition
|
||||
/// <summary>"<c>@RegUpdate</c>"</summary>
|
||||
public static ReadOnlySpan<byte> RegisteredUpdatePartitionMountName => "@RegUpdate"u8;
|
||||
|
||||
/// <summary>"<c>Nintendo</c>"</summary>
|
||||
public static ReadOnlySpan<byte> SdCardNintendoRootDirectoryName => "Nintendo"u8;
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<byte> SdCardNintendoRootDirectoryName => "Nintendo"u8;
|
||||
|
||||
private static ReadOnlySpan<byte> ContentStorageDirectoryName => "Contents"u8;
|
||||
}
|
||||
|
||||
public readonly struct InternalProgramIdRangeForSpeedEmulation
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -22,7 +22,7 @@ internal static class Utility
|
|||
/// It contains various fields that can used if needed to pass references to <see cref="FsIterationTask"/> 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 <see cref="Utility.IterateDirectoryRecursively"/> 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.
|
||||
/// </remarks>
|
||||
[NonCopyable]
|
||||
public ref struct FsIterationTaskClosure
|
||||
|
|
|
@ -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<IFile>())
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ internal static class ProcessDelta
|
|||
}
|
||||
|
||||
using var deltaFragmentFile = new UniqueRef<IFile>();
|
||||
fs.OpenFile(ref deltaFragmentFile.Ref(), FragmentFileName.ToU8String(), OpenMode.Read).ThrowIfFailure();
|
||||
fs.OpenFile(ref deltaFragmentFile.Ref(), FragmentFileName.ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
|
||||
deltaStorage = deltaFragmentFile.Release().AsStorage();
|
||||
}
|
||||
|
|
|
@ -77,15 +77,15 @@ internal static class ProcessNca
|
|||
using var outputFs = new UniqueRef<IFileSystem>(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<IFileSystem>(OpenFileSystemByType(NcaSectionType.Data));
|
||||
using var outputFs = new UniqueRef<IFileSystem>(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<IFileSystem>(OpenFileSystemByType(NcaSectionType.Code));
|
||||
using var outputFs = new UniqueRef<IFileSystem>(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<IFile>();
|
||||
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<IFile>();
|
||||
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);
|
||||
|
|
|
@ -37,8 +37,8 @@ internal static class ProcessSave
|
|||
FileSystemClient fs = ctx.Horizon.Fs;
|
||||
|
||||
using var saveUnique = new UniqueRef<IFileSystem>(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<IFileSystem>(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<IFile>(new LocalFile(ctx.Options.ReplaceFileSource, OpenMode.Read));
|
||||
|
||||
using var outFile = new UniqueRef<IFile>();
|
||||
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<IFileSystem>(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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
}
|
|
@ -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]
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
|
@ -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]
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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<byte> MountName => "mount"u8;
|
||||
private static ReadOnlySpan<byte> RootPath => "mount:/"u8;
|
||||
private static ReadOnlySpan<byte> ArchiveFilePath => "mount:/imkvdb.arc"u8;
|
||||
|
||||
private static (FlatMapKeyValueStore<T> kvStore, FileSystemClient fsClient) Create<T>(int capacity)
|
||||
where T : unmanaged, IEquatable<T>, IComparable<T>
|
||||
|
|
|
@ -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<byte> 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<byte> fileName = PathTools.GetLastSegment(u8Path);
|
||||
|
||||
|
|
Loading…
Reference in a new issue