mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Remove a workaround for CS8350 by using fixed arrays
This commit is contained in:
parent
7f1035374d
commit
f315cee9af
6 changed files with 70 additions and 86 deletions
33
src/LibHac/Common/FixedArrays/Array27.cs
Normal file
33
src/LibHac/Common/FixedArrays/Array27.cs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members
|
||||||
|
using System;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace LibHac.Common.FixedArrays;
|
||||||
|
|
||||||
|
public struct Array27<T>
|
||||||
|
{
|
||||||
|
public const int Length = 27;
|
||||||
|
|
||||||
|
private Array16<T> _0;
|
||||||
|
private Array8<T> _16;
|
||||||
|
private Array2<T> _24;
|
||||||
|
private T _26;
|
||||||
|
|
||||||
|
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 Array27<T> value) => value.ItemsRo;
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.CompilerServices;
|
||||||
using LibHac.Common;
|
using LibHac.Common;
|
||||||
|
using LibHac.Common.FixedArrays;
|
||||||
using LibHac.Fs;
|
using LibHac.Fs;
|
||||||
using LibHac.Fs.Fsa;
|
using LibHac.Fs.Fsa;
|
||||||
using LibHac.Fs.Shim;
|
using LibHac.Fs.Shim;
|
||||||
|
@ -29,11 +30,7 @@ public class FileSystemProxyCoreImpl
|
||||||
|
|
||||||
public Result OpenCustomStorageFileSystem(ref SharedRef<IFileSystem> outFileSystem, CustomStorageId storageId)
|
public Result OpenCustomStorageFileSystem(ref SharedRef<IFileSystem> outFileSystem, CustomStorageId storageId)
|
||||||
{
|
{
|
||||||
// Hack around error CS8350.
|
Unsafe.SkipInit(out Array64<byte> pathBuffer);
|
||||||
const int pathBufferLength = 0x40;
|
|
||||||
Span<byte> buffer = stackalloc byte[pathBufferLength];
|
|
||||||
ref byte bufferRef = ref MemoryMarshal.GetReference(buffer);
|
|
||||||
Span<byte> pathBuffer = MemoryMarshal.CreateSpan(ref bufferRef, pathBufferLength);
|
|
||||||
|
|
||||||
using var fileSystem = new SharedRef<IFileSystem>();
|
using var fileSystem = new SharedRef<IFileSystem>();
|
||||||
|
|
||||||
|
@ -43,7 +40,7 @@ public class FileSystemProxyCoreImpl
|
||||||
if (rc.IsFailure()) return rc;
|
if (rc.IsFailure()) return rc;
|
||||||
|
|
||||||
using var path = new Path();
|
using var path = new Path();
|
||||||
rc = PathFunctions.SetUpFixedPathSingleEntry(ref path.Ref(), pathBuffer,
|
rc = PathFunctions.SetUpFixedPathSingleEntry(ref path.Ref(), pathBuffer.Items,
|
||||||
CustomStorage.GetCustomStorageDirectoryName(CustomStorageId.System));
|
CustomStorage.GetCustomStorageDirectoryName(CustomStorageId.System));
|
||||||
if (rc.IsFailure()) return rc;
|
if (rc.IsFailure()) return rc;
|
||||||
|
|
||||||
|
@ -57,7 +54,7 @@ public class FileSystemProxyCoreImpl
|
||||||
if (rc.IsFailure()) return rc;
|
if (rc.IsFailure()) return rc;
|
||||||
|
|
||||||
using var path = new Path();
|
using var path = new Path();
|
||||||
rc = PathFunctions.SetUpFixedPathDoubleEntry(ref path.Ref(), pathBuffer,
|
rc = PathFunctions.SetUpFixedPathDoubleEntry(ref path.Ref(), pathBuffer.Items,
|
||||||
CommonPaths.SdCardNintendoRootDirectoryName,
|
CommonPaths.SdCardNintendoRootDirectoryName,
|
||||||
CustomStorage.GetCustomStorageDirectoryName(CustomStorageId.System));
|
CustomStorage.GetCustomStorageDirectoryName(CustomStorageId.System));
|
||||||
if (rc.IsFailure()) return rc;
|
if (rc.IsFailure()) return rc;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.CompilerServices;
|
||||||
using LibHac.Common;
|
using LibHac.Common;
|
||||||
|
using LibHac.Common.FixedArrays;
|
||||||
using LibHac.Common.Keys;
|
using LibHac.Common.Keys;
|
||||||
using LibHac.Diag;
|
using LibHac.Diag;
|
||||||
using LibHac.Fs;
|
using LibHac.Fs;
|
||||||
|
@ -44,15 +45,12 @@ public class SaveDataFileSystemCreator : ISaveDataFileSystemCreator
|
||||||
bool isJournalingSupported, bool isMultiCommitSupported, bool openReadOnly, bool openShared,
|
bool isJournalingSupported, bool isMultiCommitSupported, bool openReadOnly, bool openShared,
|
||||||
ISaveDataCommitTimeStampGetter timeStampGetter)
|
ISaveDataCommitTimeStampGetter timeStampGetter)
|
||||||
{
|
{
|
||||||
// Hack around error CS8350.
|
Unsafe.SkipInit(out Array18<byte> saveImageNameBuffer);
|
||||||
Span<byte> buffer = stackalloc byte[0x12];
|
|
||||||
ref byte bufferRef = ref MemoryMarshal.GetReference(buffer);
|
|
||||||
Span<byte> saveImageNameBuffer = MemoryMarshal.CreateSpan(ref bufferRef, 0x12);
|
|
||||||
|
|
||||||
Assert.SdkRequiresNotNull(cacheManager);
|
Assert.SdkRequiresNotNull(cacheManager);
|
||||||
|
|
||||||
using var saveImageName = new Path();
|
using var saveImageName = new Path();
|
||||||
Result rc = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer, saveDataId);
|
Result rc = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer.Items, saveDataId);
|
||||||
if (rc.IsFailure()) return rc;
|
if (rc.IsFailure()) return rc;
|
||||||
|
|
||||||
rc = baseFileSystem.Get.GetEntryType(out DirectoryEntryType type, in saveImageName);
|
rc = baseFileSystem.Get.GetEntryType(out DirectoryEntryType type, in saveImageName);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Buffers.Text;
|
using System.Buffers.Text;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using LibHac.Common;
|
using LibHac.Common;
|
||||||
|
using LibHac.Common.FixedArrays;
|
||||||
using LibHac.Fs;
|
using LibHac.Fs;
|
||||||
using LibHac.Fs.Fsa;
|
using LibHac.Fs.Fsa;
|
||||||
using LibHac.FsSrv.FsCreator;
|
using LibHac.FsSrv.FsCreator;
|
||||||
|
@ -217,8 +217,6 @@ public class NcaFileSystemServiceImpl
|
||||||
public Result OpenContentStorageFileSystem(ref SharedRef<IFileSystem> outFileSystem,
|
public Result OpenContentStorageFileSystem(ref SharedRef<IFileSystem> outFileSystem,
|
||||||
ContentStorageId contentStorageId)
|
ContentStorageId contentStorageId)
|
||||||
{
|
{
|
||||||
const int pathBufferLength = 0x40;
|
|
||||||
|
|
||||||
using var fileSystem = new SharedRef<IFileSystem>();
|
using var fileSystem = new SharedRef<IFileSystem>();
|
||||||
Result rc;
|
Result rc;
|
||||||
|
|
||||||
|
@ -241,21 +239,18 @@ public class NcaFileSystemServiceImpl
|
||||||
return ResultFs.InvalidArgument.Log();
|
return ResultFs.InvalidArgument.Log();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hack around error CS8350.
|
Unsafe.SkipInit(out Array64<byte> contentStoragePathBuffer);
|
||||||
Span<byte> buffer = stackalloc byte[pathBufferLength];
|
|
||||||
ref byte bufferRef = ref MemoryMarshal.GetReference(buffer);
|
|
||||||
Span<byte> contentStoragePathBuffer = MemoryMarshal.CreateSpan(ref bufferRef, pathBufferLength);
|
|
||||||
|
|
||||||
// Build the appropriate path for the content storage ID
|
// Build the appropriate path for the content storage ID
|
||||||
if (contentStorageId == ContentStorageId.SdCard)
|
if (contentStorageId == ContentStorageId.SdCard)
|
||||||
{
|
{
|
||||||
var sb = new U8StringBuilder(contentStoragePathBuffer);
|
var sb = new U8StringBuilder(contentStoragePathBuffer.Items);
|
||||||
sb.Append(StringTraits.DirectorySeparator).Append(SdCardNintendoRootDirectoryName);
|
sb.Append(StringTraits.DirectorySeparator).Append(SdCardNintendoRootDirectoryName);
|
||||||
sb.Append(StringTraits.DirectorySeparator).Append(ContentStorageDirectoryName);
|
sb.Append(StringTraits.DirectorySeparator).Append(ContentStorageDirectoryName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var sb = new U8StringBuilder(contentStoragePathBuffer);
|
var sb = new U8StringBuilder(contentStoragePathBuffer.Items);
|
||||||
sb.Append(StringTraits.DirectorySeparator).Append(ContentStorageDirectoryName);
|
sb.Append(StringTraits.DirectorySeparator).Append(ContentStorageDirectoryName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.CompilerServices;
|
||||||
using LibHac.Common;
|
using LibHac.Common;
|
||||||
|
using LibHac.Common.FixedArrays;
|
||||||
using LibHac.Diag;
|
using LibHac.Diag;
|
||||||
using LibHac.Fs;
|
using LibHac.Fs;
|
||||||
using LibHac.Fs.Fsa;
|
using LibHac.Fs.Fsa;
|
||||||
|
@ -91,14 +92,10 @@ public class SaveDataFileSystemServiceImpl
|
||||||
if (rc.IsFailure()) return rc.Miss();
|
if (rc.IsFailure()) return rc.Miss();
|
||||||
|
|
||||||
// Get the path of the save data
|
// Get the path of the save data
|
||||||
// Hack around error CS8350.
|
Unsafe.SkipInit(out Array18<byte> saveImageNameBuffer);
|
||||||
const int bufferLength = 0x12;
|
|
||||||
Span<byte> buffer = stackalloc byte[bufferLength];
|
|
||||||
ref byte bufferRef = ref MemoryMarshal.GetReference(buffer);
|
|
||||||
Span<byte> saveImageNameBuffer = MemoryMarshal.CreateSpan(ref bufferRef, bufferLength);
|
|
||||||
|
|
||||||
using var saveImageName = new Path();
|
using var saveImageName = new Path();
|
||||||
rc = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer, saveDataId);
|
rc = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer.Items, saveDataId);
|
||||||
if (rc.IsFailure()) return rc.Miss();
|
if (rc.IsFailure()) return rc.Miss();
|
||||||
|
|
||||||
rc = fileSystem.Get.GetEntryType(out _, in saveImageName);
|
rc = fileSystem.Get.GetEntryType(out _, in saveImageName);
|
||||||
|
@ -195,15 +192,11 @@ public class SaveDataFileSystemServiceImpl
|
||||||
public Result OpenSaveDataMetaDirectoryFileSystem(ref SharedRef<IFileSystem> outFileSystem,
|
public Result OpenSaveDataMetaDirectoryFileSystem(ref SharedRef<IFileSystem> outFileSystem,
|
||||||
SaveDataSpaceId spaceId, ulong saveDataId)
|
SaveDataSpaceId spaceId, ulong saveDataId)
|
||||||
{
|
{
|
||||||
// Hack around error CS8350.
|
Unsafe.SkipInit(out Array27<byte> saveDataMetaIdDirectoryNameBuffer);
|
||||||
const int bufferLength = 0x1B;
|
|
||||||
Span<byte> buffer = stackalloc byte[bufferLength];
|
|
||||||
ref byte bufferRef = ref MemoryMarshal.GetReference(buffer);
|
|
||||||
Span<byte> saveDataMetaIdDirectoryNameBuffer = MemoryMarshal.CreateSpan(ref bufferRef, bufferLength);
|
|
||||||
|
|
||||||
using var saveDataMetaIdDirectoryName = new Path();
|
using var saveDataMetaIdDirectoryName = new Path();
|
||||||
Result rc = PathFunctions.SetUpFixedPathSaveMetaDir(ref saveDataMetaIdDirectoryName.Ref(),
|
Result rc = PathFunctions.SetUpFixedPathSaveMetaDir(ref saveDataMetaIdDirectoryName.Ref(),
|
||||||
saveDataMetaIdDirectoryNameBuffer, saveDataId);
|
saveDataMetaIdDirectoryNameBuffer.Items, saveDataId);
|
||||||
if (rc.IsFailure()) return rc.Miss();
|
if (rc.IsFailure()) return rc.Miss();
|
||||||
|
|
||||||
return OpenSaveDataDirectoryFileSystemImpl(ref outFileSystem, spaceId, in saveDataMetaIdDirectoryName);
|
return OpenSaveDataDirectoryFileSystemImpl(ref outFileSystem, spaceId, in saveDataMetaIdDirectoryName);
|
||||||
|
@ -230,14 +223,10 @@ public class SaveDataFileSystemServiceImpl
|
||||||
Result rc = OpenSaveDataMetaDirectoryFileSystem(ref fileSystem.Ref(), spaceId, saveDataId);
|
Result rc = OpenSaveDataMetaDirectoryFileSystem(ref fileSystem.Ref(), spaceId, saveDataId);
|
||||||
if (rc.IsFailure()) return rc.Miss();
|
if (rc.IsFailure()) return rc.Miss();
|
||||||
|
|
||||||
// Hack around error CS8350.
|
Unsafe.SkipInit(out Array15<byte> saveDataMetaNameBuffer);
|
||||||
const int bufferLength = 0xF;
|
|
||||||
Span<byte> buffer = stackalloc byte[bufferLength];
|
|
||||||
ref byte bufferRef = ref MemoryMarshal.GetReference(buffer);
|
|
||||||
Span<byte> saveDataMetaNameBuffer = MemoryMarshal.CreateSpan(ref bufferRef, bufferLength);
|
|
||||||
|
|
||||||
using var saveDataMetaName = new Path();
|
using var saveDataMetaName = new Path();
|
||||||
rc = PathFunctions.SetUpFixedPathSaveMetaName(ref saveDataMetaName.Ref(), saveDataMetaNameBuffer,
|
rc = PathFunctions.SetUpFixedPathSaveMetaName(ref saveDataMetaName.Ref(), saveDataMetaNameBuffer.Items,
|
||||||
(uint)metaType);
|
(uint)metaType);
|
||||||
if (rc.IsFailure()) return rc.Miss();
|
if (rc.IsFailure()) return rc.Miss();
|
||||||
|
|
||||||
|
@ -254,14 +243,10 @@ public class SaveDataFileSystemServiceImpl
|
||||||
Result rc = OpenSaveDataMetaDirectoryFileSystem(ref fileSystem.Ref(), spaceId, saveDataId);
|
Result rc = OpenSaveDataMetaDirectoryFileSystem(ref fileSystem.Ref(), spaceId, saveDataId);
|
||||||
if (rc.IsFailure()) return rc.Miss();
|
if (rc.IsFailure()) return rc.Miss();
|
||||||
|
|
||||||
// Hack around error CS8350.
|
Unsafe.SkipInit(out Array15<byte> saveDataMetaNameBuffer);
|
||||||
const int bufferLength = 0xF;
|
|
||||||
Span<byte> buffer = stackalloc byte[bufferLength];
|
|
||||||
ref byte bufferRef = ref MemoryMarshal.GetReference(buffer);
|
|
||||||
Span<byte> saveDataMetaNameBuffer = MemoryMarshal.CreateSpan(ref bufferRef, bufferLength);
|
|
||||||
|
|
||||||
using var saveDataMetaName = new Path();
|
using var saveDataMetaName = new Path();
|
||||||
rc = PathFunctions.SetUpFixedPathSaveMetaName(ref saveDataMetaName.Ref(), saveDataMetaNameBuffer,
|
rc = PathFunctions.SetUpFixedPathSaveMetaName(ref saveDataMetaName.Ref(), saveDataMetaNameBuffer.Items,
|
||||||
(uint)metaType);
|
(uint)metaType);
|
||||||
if (rc.IsFailure()) return rc.Miss();
|
if (rc.IsFailure()) return rc.Miss();
|
||||||
|
|
||||||
|
@ -280,11 +265,7 @@ public class SaveDataFileSystemServiceImpl
|
||||||
(byte)'a'
|
(byte)'a'
|
||||||
};
|
};
|
||||||
|
|
||||||
// Hack around error CS8350.
|
Unsafe.SkipInit(out Array18<byte> saveDataIdDirectoryNameBuffer);
|
||||||
const int bufferLength = 0x12;
|
|
||||||
Span<byte> buffer = stackalloc byte[bufferLength];
|
|
||||||
ref byte bufferRef = ref MemoryMarshal.GetReference(buffer);
|
|
||||||
Span<byte> saveDataIdDirectoryNameBuffer = MemoryMarshal.CreateSpan(ref bufferRef, bufferLength);
|
|
||||||
|
|
||||||
using var fileSystem = new SharedRef<IFileSystem>();
|
using var fileSystem = new SharedRef<IFileSystem>();
|
||||||
|
|
||||||
|
@ -296,7 +277,7 @@ public class SaveDataFileSystemServiceImpl
|
||||||
if (rc.IsFailure()) return rc.Miss();
|
if (rc.IsFailure()) return rc.Miss();
|
||||||
|
|
||||||
using var saveDataIdDirectoryName = new Path();
|
using var saveDataIdDirectoryName = new Path();
|
||||||
PathFunctions.SetUpFixedPathSaveId(ref saveDataIdDirectoryName.Ref(), saveDataIdDirectoryNameBuffer,
|
PathFunctions.SetUpFixedPathSaveId(ref saveDataIdDirectoryName.Ref(), saveDataIdDirectoryNameBuffer.Items,
|
||||||
saveDataId);
|
saveDataId);
|
||||||
if (rc.IsFailure()) return rc.Miss();
|
if (rc.IsFailure()) return rc.Miss();
|
||||||
|
|
||||||
|
@ -322,14 +303,10 @@ public class SaveDataFileSystemServiceImpl
|
||||||
Result rc = OpenSaveDataMetaDirectoryFileSystem(ref fileSystem.Ref(), spaceId, saveDataId);
|
Result rc = OpenSaveDataMetaDirectoryFileSystem(ref fileSystem.Ref(), spaceId, saveDataId);
|
||||||
if (rc.IsFailure()) return rc.Miss();
|
if (rc.IsFailure()) return rc.Miss();
|
||||||
|
|
||||||
// Hack around error CS8350.
|
Unsafe.SkipInit(out Array15<byte> saveDataMetaNameBuffer);
|
||||||
const int bufferLength = 0xF;
|
|
||||||
Span<byte> buffer = stackalloc byte[bufferLength];
|
|
||||||
ref byte bufferRef = ref MemoryMarshal.GetReference(buffer);
|
|
||||||
Span<byte> saveDataMetaNameBuffer = MemoryMarshal.CreateSpan(ref bufferRef, bufferLength);
|
|
||||||
|
|
||||||
using var saveDataMetaName = new Path();
|
using var saveDataMetaName = new Path();
|
||||||
rc = PathFunctions.SetUpFixedPathSaveMetaName(ref saveDataMetaName.Ref(), saveDataMetaNameBuffer,
|
rc = PathFunctions.SetUpFixedPathSaveMetaName(ref saveDataMetaName.Ref(), saveDataMetaNameBuffer.Items,
|
||||||
(uint)metaType);
|
(uint)metaType);
|
||||||
if (rc.IsFailure()) return rc.Miss();
|
if (rc.IsFailure()) return rc.Miss();
|
||||||
|
|
||||||
|
@ -345,11 +322,7 @@ public class SaveDataFileSystemServiceImpl
|
||||||
{
|
{
|
||||||
// Use directory save data for now
|
// Use directory save data for now
|
||||||
|
|
||||||
// Hack around error CS8350.
|
Unsafe.SkipInit(out Array18<byte> saveImageNameBuffer);
|
||||||
const int bufferLength = 0x12;
|
|
||||||
Span<byte> buffer = stackalloc byte[bufferLength];
|
|
||||||
ref byte bufferRef = ref MemoryMarshal.GetReference(buffer);
|
|
||||||
Span<byte> saveImageNameBuffer = MemoryMarshal.CreateSpan(ref bufferRef, bufferLength);
|
|
||||||
|
|
||||||
using var fileSystem = new SharedRef<IFileSystem>();
|
using var fileSystem = new SharedRef<IFileSystem>();
|
||||||
|
|
||||||
|
@ -358,7 +331,7 @@ public class SaveDataFileSystemServiceImpl
|
||||||
if (rc.IsFailure()) return rc.Miss();
|
if (rc.IsFailure()) return rc.Miss();
|
||||||
|
|
||||||
using var saveImageName = new Path();
|
using var saveImageName = new Path();
|
||||||
rc = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer, saveDataId);
|
rc = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer.Items, saveDataId);
|
||||||
if (rc.IsFailure()) return rc.Miss();
|
if (rc.IsFailure()) return rc.Miss();
|
||||||
|
|
||||||
if (_config.IsPseudoSaveData())
|
if (_config.IsPseudoSaveData())
|
||||||
|
@ -414,11 +387,7 @@ public class SaveDataFileSystemServiceImpl
|
||||||
public Result DeleteSaveDataFileSystem(SaveDataSpaceId spaceId, ulong saveDataId, bool wipeSaveFile,
|
public Result DeleteSaveDataFileSystem(SaveDataSpaceId spaceId, ulong saveDataId, bool wipeSaveFile,
|
||||||
in Path saveDataRootPath)
|
in Path saveDataRootPath)
|
||||||
{
|
{
|
||||||
// Hack around error CS8350.
|
Unsafe.SkipInit(out Array18<byte> saveImageNameBuffer);
|
||||||
const int bufferLength = 0x12;
|
|
||||||
Span<byte> buffer = stackalloc byte[bufferLength];
|
|
||||||
ref byte bufferRef = ref MemoryMarshal.GetReference(buffer);
|
|
||||||
Span<byte> saveImageNameBuffer = MemoryMarshal.CreateSpan(ref bufferRef, bufferLength);
|
|
||||||
|
|
||||||
using var fileSystem = new SharedRef<IFileSystem>();
|
using var fileSystem = new SharedRef<IFileSystem>();
|
||||||
|
|
||||||
|
@ -429,7 +398,7 @@ public class SaveDataFileSystemServiceImpl
|
||||||
if (rc.IsFailure()) return rc.Miss();
|
if (rc.IsFailure()) return rc.Miss();
|
||||||
|
|
||||||
using var saveImageName = new Path();
|
using var saveImageName = new Path();
|
||||||
rc = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer, saveDataId);
|
rc = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer.Items, saveDataId);
|
||||||
if (rc.IsFailure()) return rc.Miss();
|
if (rc.IsFailure()) return rc.Miss();
|
||||||
|
|
||||||
// Check if the save data is a file or a directory
|
// Check if the save data is a file or a directory
|
||||||
|
@ -664,14 +633,10 @@ public class SaveDataFileSystemServiceImpl
|
||||||
rc = _config.BaseFsService.OpenSdCardProxyFileSystem(ref baseFileSystem.Ref(), true);
|
rc = _config.BaseFsService.OpenSdCardProxyFileSystem(ref baseFileSystem.Ref(), true);
|
||||||
if (rc.IsFailure()) return rc.Miss();
|
if (rc.IsFailure()) return rc.Miss();
|
||||||
|
|
||||||
// Hack around error CS8350.
|
Unsafe.SkipInit(out Array64<byte> pathParentBuffer);
|
||||||
const int bufferLength = 0x40;
|
|
||||||
Span<byte> buffer = stackalloc byte[bufferLength];
|
|
||||||
ref byte bufferRef = ref MemoryMarshal.GetReference(buffer);
|
|
||||||
Span<byte> pathParentBuffer = MemoryMarshal.CreateSpan(ref bufferRef, bufferLength);
|
|
||||||
|
|
||||||
using var pathParent = new Path();
|
using var pathParent = new Path();
|
||||||
rc = PathFunctions.SetUpFixedPathSingleEntry(ref pathParent.Ref(), pathParentBuffer,
|
rc = PathFunctions.SetUpFixedPathSingleEntry(ref pathParent.Ref(), pathParentBuffer.Items,
|
||||||
CommonPaths.SdCardNintendoRootDirectoryName);
|
CommonPaths.SdCardNintendoRootDirectoryName);
|
||||||
if (rc.IsFailure()) return rc.Miss();
|
if (rc.IsFailure()) return rc.Miss();
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using LibHac.Common;
|
using LibHac.Common;
|
||||||
|
using LibHac.Common.FixedArrays;
|
||||||
using LibHac.Diag;
|
using LibHac.Diag;
|
||||||
using LibHac.Fs;
|
using LibHac.Fs;
|
||||||
using LibHac.Fs.Fsa;
|
using LibHac.Fs.Fsa;
|
||||||
|
@ -334,14 +334,10 @@ public class SaveDataFileStorageHolder
|
||||||
ref SharedRef<IFileSystem> baseFileSystem, SaveDataSpaceId spaceId, ulong saveDataId, OpenMode mode,
|
ref SharedRef<IFileSystem> baseFileSystem, SaveDataSpaceId spaceId, ulong saveDataId, OpenMode mode,
|
||||||
Optional<SaveDataOpenTypeSetFileStorage.OpenType> type)
|
Optional<SaveDataOpenTypeSetFileStorage.OpenType> type)
|
||||||
{
|
{
|
||||||
// Hack around error CS8350.
|
Unsafe.SkipInit(out Array18<byte> saveImageNameBuffer);
|
||||||
const int bufferLength = 0x12;
|
|
||||||
Span<byte> buffer = stackalloc byte[bufferLength];
|
|
||||||
ref byte bufferRef = ref MemoryMarshal.GetReference(buffer);
|
|
||||||
Span<byte> saveImageNameBuffer = MemoryMarshal.CreateSpan(ref bufferRef, bufferLength);
|
|
||||||
|
|
||||||
using var saveImageName = new Path();
|
using var saveImageName = new Path();
|
||||||
Result rc = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer, saveDataId);
|
Result rc = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer.Items, saveDataId);
|
||||||
if (rc.IsFailure()) return rc;
|
if (rc.IsFailure()) return rc;
|
||||||
|
|
||||||
// If an open type isn't specified, open the save without the shared file storage layer
|
// If an open type isn't specified, open the save without the shared file storage layer
|
||||||
|
|
Loading…
Reference in a new issue