mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2025-02-09 13:14:46 +01:00
Ensure UserFileSystemForDebug/Private are updated to 13.1.0
This commit is contained in:
parent
ac378020dc
commit
3940ca9d76
31
src/LibHac/Common/FixedArrays/Array512.cs
Normal file
31
src/LibHac/Common/FixedArrays/Array512.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.Common.FixedArrays;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Array512<T>
|
||||
{
|
||||
public const int Length = 512;
|
||||
|
||||
private Array256<T> _0;
|
||||
private Array256<T> _256;
|
||||
|
||||
public ref T this[int i] => ref Items[i];
|
||||
|
||||
public Span<T> Items
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length);
|
||||
}
|
||||
|
||||
public readonly ReadOnlySpan<T> ItemsRo
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static implicit operator ReadOnlySpan<T>(in Array512<T> value) => value.ItemsRo;
|
||||
}
|
32
src/LibHac/Common/FixedArrays/Array769.cs
Normal file
32
src/LibHac/Common/FixedArrays/Array769.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.Common.FixedArrays;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Array769<T>
|
||||
{
|
||||
public const int Length = 769;
|
||||
|
||||
private Array512<T> _0;
|
||||
private Array256<T> _512;
|
||||
private Array1<T> _768;
|
||||
|
||||
public ref T this[int i] => ref Items[i];
|
||||
|
||||
public Span<T> Items
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length);
|
||||
}
|
||||
|
||||
public readonly ReadOnlySpan<T> ItemsRo
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static implicit operator ReadOnlySpan<T>(in Array769<T> value) => value.ItemsRo;
|
||||
}
|
30
src/LibHac/Fs/Fsa/UserFileSystemForDebug.cs
Normal file
30
src/LibHac/Fs/Fsa/UserFileSystemForDebug.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs.Impl;
|
||||
|
||||
namespace LibHac.Fs.Fsa;
|
||||
|
||||
/// <summary>
|
||||
/// Contains functions meant for debug use for interacting with mounted file systems.
|
||||
/// </summary>
|
||||
/// <remarks>Based on FS 13.1.0 (nnSdk 13.4.0)</remarks>
|
||||
public static class UserFileSystemForDebug
|
||||
{
|
||||
internal static Result GetFileTimeStampRawForDebug(this FileSystemClientImpl fs, out FileTimeStampRaw timeStamp,
|
||||
U8Span path)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out timeStamp);
|
||||
|
||||
Result rc = fs.FindFileSystem(out FileSystemAccessor fileSystem, out U8Span subPath, path);
|
||||
if (rc.IsFailure()) return rc.Miss();
|
||||
|
||||
return fileSystem.GetFileTimeStampRaw(out timeStamp, subPath);
|
||||
}
|
||||
|
||||
public static Result GetFileTimeStampRawForDebug(this FileSystemClient fs, out FileTimeStampRaw timeStamp,
|
||||
U8Span path)
|
||||
{
|
||||
Result rc = fs.Impl.GetFileTimeStampRawForDebug(out timeStamp, path);
|
||||
fs.Impl.AbortIfNeeded(rc);
|
||||
return rc;
|
||||
}
|
||||
}
|
@ -6,9 +6,13 @@ using static LibHac.Fs.Impl.AccessLogStrings;
|
||||
|
||||
namespace LibHac.Fs.Fsa;
|
||||
|
||||
/// <summary>
|
||||
/// Contains functions meant for internal use for interacting with mounted file systems.
|
||||
/// </summary>
|
||||
/// <remarks>Based on FS 13.1.0 (nnSdk 13.4.0)</remarks>
|
||||
public static class UserFileSystemPrivate
|
||||
{
|
||||
public static Result CreateFile(this FileSystemClient fs, U8Span path, long size, CreateFileOptions options)
|
||||
public static Result CreateFile(this FileSystemClient fs, U8Span path, long size, CreateFileOptions option)
|
||||
{
|
||||
Result rc;
|
||||
U8Span subPath;
|
||||
@ -37,7 +41,7 @@ public static class UserFileSystemPrivate
|
||||
if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog())
|
||||
{
|
||||
Tick start = fs.Hos.Os.GetSystemTick();
|
||||
rc = fileSystem.CreateFile(subPath, size, options);
|
||||
rc = fileSystem.CreateFile(subPath, size, option);
|
||||
Tick end = fs.Hos.Os.GetSystemTick();
|
||||
|
||||
var sb = new U8StringBuilder(logBuffer, true);
|
||||
@ -48,7 +52,7 @@ public static class UserFileSystemPrivate
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = fileSystem.CreateFile(subPath, size, options);
|
||||
rc = fileSystem.CreateFile(subPath, size, option);
|
||||
}
|
||||
fs.Impl.AbortIfNeeded(rc);
|
||||
return rc;
|
||||
@ -62,7 +66,7 @@ public static class UserFileSystemPrivate
|
||||
fs.Impl.AbortIfNeeded(rc);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
||||
rc = fileSystem.GetFreeSpaceSize(out totalSpace, subPath);
|
||||
rc = fileSystem.GetTotalSpaceSize(out totalSpace, subPath);
|
||||
fs.Impl.AbortIfNeeded(rc);
|
||||
return rc;
|
||||
}
|
||||
@ -73,7 +77,23 @@ public static class UserFileSystemPrivate
|
||||
fs.Impl.AbortIfNeeded(rc);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
||||
rc = fileSystem.QueryEntry(Span<byte>.Empty, ReadOnlySpan<byte>.Empty, QueryId.SetConcatenationFileAttribute, subPath);
|
||||
rc = fileSystem.QueryEntry(Span<byte>.Empty, ReadOnlySpan<byte>.Empty, QueryId.SetConcatenationFileAttribute,
|
||||
subPath);
|
||||
fs.Impl.AbortIfNeeded(rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
public static Result QueryUnpreparedFileInformation(this FileSystemClient fs, out UnpreparedFileInformation info,
|
||||
U8Span path)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out info);
|
||||
|
||||
Result rc = fs.Impl.FindFileSystem(out FileSystemAccessor fileSystem, out _, path);
|
||||
fs.Impl.AbortIfNeeded(rc);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
||||
rc = fileSystem.QueryEntry(SpanHelpers.AsByteSpan(ref info), ReadOnlySpan<byte>.Empty,
|
||||
QueryId.QueryUnpreparedFileInformation, new U8Span(new[] { (byte)'/' }));
|
||||
fs.Impl.AbortIfNeeded(rc);
|
||||
return rc;
|
||||
}
|
||||
|
@ -12,6 +12,11 @@ public struct UnpreparedRangeInfo
|
||||
public Array20<byte> Reserved;
|
||||
}
|
||||
|
||||
public struct UnpreparedFileInformation
|
||||
{
|
||||
public Array769<byte> Path;
|
||||
}
|
||||
|
||||
public struct LazyLoadArguments
|
||||
{
|
||||
public int GuideIndex;
|
||||
|
@ -14,6 +14,12 @@ public class LazyLoadTypeTests
|
||||
Assert.Equal(0x40, Unsafe.SizeOf<UnpreparedRangeInfo>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void UnpreparedFileInformationSizeIs0x301()
|
||||
{
|
||||
Assert.Equal(0x301, Unsafe.SizeOf<UnpreparedFileInformation>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void LazyLoadArgumentsSizeIs0x40()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user