mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2025-02-09 13:14:46 +01:00
Use SkipParamInit for handling unwritten out values
Use this function in all places out values that set in the original code because of errors. Unmanaged values will stay uninitialized while managed values will be zeroed.
This commit is contained in:
parent
d2c327377d
commit
d8b8e3088e
@ -32,11 +32,12 @@ namespace LibHac.Bcat.Detail.Service.Core
|
||||
|
||||
public Result GetEntry(out DeliveryCacheDirectoryMetaEntry entry, int index)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out entry);
|
||||
|
||||
lock (Locker)
|
||||
{
|
||||
if (index >= Count)
|
||||
{
|
||||
entry = default;
|
||||
return ResultBcat.NotFound.Log();
|
||||
}
|
||||
|
||||
|
@ -34,11 +34,12 @@ namespace LibHac.Bcat.Detail.Service.Core
|
||||
|
||||
public Result GetEntry(out DeliveryCacheFileMetaEntry entry, int index)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out entry);
|
||||
|
||||
lock (Locker)
|
||||
{
|
||||
if (index >= Count)
|
||||
{
|
||||
entry = default;
|
||||
return ResultBcat.NotFound.Log();
|
||||
}
|
||||
|
||||
@ -49,6 +50,8 @@ namespace LibHac.Bcat.Detail.Service.Core
|
||||
|
||||
public Result FindEntry(out DeliveryCacheFileMetaEntry entry, ref FileName fileName)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out entry);
|
||||
|
||||
lock (Locker)
|
||||
{
|
||||
for (int i = 0; i < Count; i++)
|
||||
@ -60,7 +63,6 @@ namespace LibHac.Bcat.Detail.Service.Core
|
||||
}
|
||||
}
|
||||
|
||||
entry = default;
|
||||
return ResultBcat.NotFound.Log();
|
||||
}
|
||||
}
|
||||
|
@ -288,6 +288,8 @@ namespace LibHac.Bcat.Detail.Service.Core
|
||||
|
||||
private Result FindOrGetUnusedEntry(out int entryIndex, ulong applicationId)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out entryIndex);
|
||||
|
||||
// Try to find an existing entry
|
||||
for (int i = 0; i < Entries.Length; i++)
|
||||
{
|
||||
@ -308,7 +310,6 @@ namespace LibHac.Bcat.Detail.Service.Core
|
||||
}
|
||||
}
|
||||
|
||||
entryIndex = default;
|
||||
return ResultBcat.StorageOpenLimitReached.Log();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using LibHac.Bcat.Detail.Ipc;
|
||||
using LibHac.Bcat.Detail.Service.Core;
|
||||
using LibHac.Common;
|
||||
|
||||
namespace LibHac.Bcat.Detail.Service
|
||||
{
|
||||
@ -50,10 +51,10 @@ namespace LibHac.Bcat.Detail.Service
|
||||
|
||||
public Result Read(out int entriesRead, Span<DeliveryCacheDirectoryEntry> entryBuffer)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out entriesRead);
|
||||
|
||||
lock (Locker)
|
||||
{
|
||||
entriesRead = default;
|
||||
|
||||
if (!IsDirectoryOpen)
|
||||
return ResultBcat.NotOpen.Log();
|
||||
|
||||
@ -84,11 +85,12 @@ namespace LibHac.Bcat.Detail.Service
|
||||
|
||||
public Result GetCount(out int count)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out count);
|
||||
|
||||
lock (Locker)
|
||||
{
|
||||
if (!IsDirectoryOpen)
|
||||
{
|
||||
count = default;
|
||||
return ResultBcat.NotOpen.Log();
|
||||
}
|
||||
|
||||
|
@ -81,11 +81,12 @@ namespace LibHac.Bcat.Detail.Service
|
||||
|
||||
public Result GetSize(out long size)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out size);
|
||||
|
||||
lock (Locker)
|
||||
{
|
||||
if (!IsFileOpen)
|
||||
{
|
||||
size = default;
|
||||
return ResultBcat.NotOpen.Log();
|
||||
}
|
||||
|
||||
@ -95,11 +96,12 @@ namespace LibHac.Bcat.Detail.Service
|
||||
|
||||
public Result GetDigest(out Digest digest)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out digest);
|
||||
|
||||
lock (Locker)
|
||||
{
|
||||
if (!IsFileOpen)
|
||||
{
|
||||
digest = default;
|
||||
return ResultBcat.NotOpen.Log();
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.Diagnostics;
|
||||
using LibHac.Bcat.Detail.Ipc;
|
||||
using LibHac.Bcat.Detail.Service.Core;
|
||||
using LibHac.Common;
|
||||
using LibHac.Util;
|
||||
|
||||
namespace LibHac.Bcat.Detail.Service
|
||||
@ -28,7 +29,7 @@ namespace LibHac.Bcat.Detail.Service
|
||||
{
|
||||
lock (Locker)
|
||||
{
|
||||
service = default;
|
||||
UnsafeHelpers.SkipParamInit(out service);
|
||||
|
||||
if (FileServiceOpenCount >= MaxOpenCount)
|
||||
return ResultBcat.ServiceOpenLimitReached.Log();
|
||||
@ -44,7 +45,7 @@ namespace LibHac.Bcat.Detail.Service
|
||||
{
|
||||
lock (Locker)
|
||||
{
|
||||
service = default;
|
||||
UnsafeHelpers.SkipParamInit(out service);
|
||||
|
||||
if (DirectoryServiceOpenCount >= MaxOpenCount)
|
||||
return ResultBcat.ServiceOpenLimitReached.Log();
|
||||
@ -58,10 +59,10 @@ namespace LibHac.Bcat.Detail.Service
|
||||
|
||||
public Result EnumerateDeliveryCacheDirectory(out int namesRead, Span<DirectoryName> nameBuffer)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out namesRead);
|
||||
|
||||
lock (Locker)
|
||||
{
|
||||
namesRead = default;
|
||||
|
||||
var metaReader = new DeliveryCacheDirectoryMetaAccessor(Server);
|
||||
Result rc = metaReader.ReadApplicationDirectoryMeta(ApplicationId, true);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
@ -1,5 +1,6 @@
|
||||
using LibHac.Arp;
|
||||
using LibHac.Bcat.Detail.Ipc;
|
||||
using LibHac.Common;
|
||||
|
||||
namespace LibHac.Bcat.Detail.Service
|
||||
{
|
||||
@ -25,7 +26,7 @@ namespace LibHac.Bcat.Detail.Service
|
||||
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
service = default;
|
||||
UnsafeHelpers.SkipParamInit(out service);
|
||||
return ResultBcat.NotFound.LogConverted(rc);
|
||||
}
|
||||
|
||||
@ -37,7 +38,7 @@ namespace LibHac.Bcat.Detail.Service
|
||||
{
|
||||
if (!AccessControl.HasFlag(AccessControl.MountOthersDeliveryCacheStorage))
|
||||
{
|
||||
service = default;
|
||||
UnsafeHelpers.SkipParamInit(out service);
|
||||
return ResultBcat.PermissionDenied.Log();
|
||||
}
|
||||
|
||||
@ -47,7 +48,7 @@ namespace LibHac.Bcat.Detail.Service
|
||||
private Result CreateDeliveryCacheStorageServiceImpl(out IDeliveryCacheStorageService service,
|
||||
ApplicationId applicationId)
|
||||
{
|
||||
service = default;
|
||||
UnsafeHelpers.SkipParamInit(out service);
|
||||
|
||||
Result rc = Server.GetStorageManager().Open(applicationId.Value);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
@ -53,7 +53,7 @@ namespace LibHac.Boot
|
||||
/// <returns>The <see cref="Result"/> of the operation.</returns>
|
||||
public Result OpenPayload(out IStorage payloadStorage, int index)
|
||||
{
|
||||
payloadStorage = default;
|
||||
UnsafeHelpers.SkipParamInit(out payloadStorage);
|
||||
|
||||
if ((uint)index >= Package2Header.PayloadCount)
|
||||
return ResultLibHac.ArgumentOutOfRange.Log();
|
||||
@ -100,7 +100,7 @@ namespace LibHac.Boot
|
||||
}
|
||||
|
||||
// Ini is embedded in the kernel
|
||||
iniStorage = default;
|
||||
UnsafeHelpers.SkipParamInit(out iniStorage);
|
||||
|
||||
Result rc = OpenKernel(out IStorage kernelStorage);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -242,7 +242,7 @@ namespace LibHac.Boot
|
||||
Result rc = OpenPayload(out IStorage payloadStorage, i);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
packageStorage = default;
|
||||
UnsafeHelpers.SkipParamInit(out packageStorage);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -571,6 +571,8 @@ namespace LibHac.Common.Keys
|
||||
|
||||
private static bool TryGetKeyInfo(out SpecificKeyInfo info, List<KeyInfo> keyList, ReadOnlySpan<char> keyName)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out info);
|
||||
|
||||
for (int i = 0; i < keyList.Count; i++)
|
||||
{
|
||||
if (keyList[i].Matches(keyName, out int keyIndex, out bool isDev))
|
||||
@ -580,7 +582,6 @@ namespace LibHac.Common.Keys
|
||||
}
|
||||
}
|
||||
|
||||
info = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
67
src/LibHac/Common/UnsafeHelpers.cs
Normal file
67
src/LibHac/Common/UnsafeHelpers.cs
Normal file
@ -0,0 +1,67 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace LibHac.Common
|
||||
{
|
||||
public static class UnsafeHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Bypasses definite assignment rules for a given unmanaged value,
|
||||
/// or zeros a managed value to avoid having invalid references.
|
||||
/// <br/>Used in instances where an out value in the original code isn't set due to an error condition.
|
||||
/// <br/>Behaves the same as <see cref="Unsafe.SkipInit{T}"/>, except it zeros managed values.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the object.</typeparam>
|
||||
/// <param name="value">The object.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void SkipParamInit<T>(out T value)
|
||||
{
|
||||
if (!RuntimeHelpers.IsReferenceOrContainsReferences<T>())
|
||||
{
|
||||
Unsafe.SkipInit(out value);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = default;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bypasses definite assignment rules for the given unmanaged values,
|
||||
/// zeroing any managed values to avoid having invalid references.
|
||||
/// <br/>Used in instances where out values in the original code aren't set due to an error condition.
|
||||
/// <br/>Behaves the same as calling <see cref="Unsafe.SkipInit{T}"/>
|
||||
/// on each value, except managed values will be zeroed.
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">The type of the first object.</typeparam>
|
||||
/// <typeparam name="T2">The type of the second object.</typeparam>
|
||||
/// <param name="value1">The first object.</param>
|
||||
/// <param name="value2">The second object.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void SkipParamInit<T1, T2>(out T1 value1, out T2 value2)
|
||||
{
|
||||
SkipParamInit(out value1);
|
||||
SkipParamInit(out value2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bypasses definite assignment rules for the given unmanaged values,
|
||||
/// zeroing any managed values to avoid having invalid references.
|
||||
/// <br/>Used in instances where out values in the original code aren't set due to an error condition.
|
||||
/// <br/>Behaves the same as calling <see cref="Unsafe.SkipInit{T}"/>
|
||||
/// on each value, except managed values will be zeroed.
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">The type of the first object.</typeparam>
|
||||
/// <typeparam name="T2">The type of the second object.</typeparam>
|
||||
/// <typeparam name="T3">The type of the third object.</typeparam>
|
||||
/// <param name="value1">The first object.</param>
|
||||
/// <param name="value2">The second object.</param>
|
||||
/// <param name="value3">The third object.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void SkipParamInit<T1, T2, T3>(out T1 value1, out T2 value2, out T3 value3)
|
||||
{
|
||||
SkipParamInit(out value1);
|
||||
SkipParamInit(out value2);
|
||||
SkipParamInit(out value3);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using LibHac.Account;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs.Shim;
|
||||
using LibHac.Ncm;
|
||||
using LibHac.Ns;
|
||||
@ -13,7 +14,7 @@ namespace LibHac.Fs
|
||||
public static Result EnsureApplicationSaveData(FileSystemClient fs, out long requiredSize, Ncm.ApplicationId applicationId,
|
||||
ref ApplicationControlProperty nacp, ref Uid uid)
|
||||
{
|
||||
requiredSize = default;
|
||||
UnsafeHelpers.SkipParamInit(out requiredSize);
|
||||
long requiredSizeSum = 0;
|
||||
|
||||
// Create local variable for use in closures
|
||||
@ -214,7 +215,7 @@ namespace LibHac.Fs
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
requiredSize = default;
|
||||
UnsafeHelpers.SkipParamInit(out requiredSize);
|
||||
long requiredSizeBcat = 0;
|
||||
|
||||
var filter = new SaveDataFilter();
|
||||
@ -236,7 +237,7 @@ namespace LibHac.Fs
|
||||
out CacheStorageTargetMedia target, Ncm.ApplicationId applicationId, ulong saveDataOwnerId, ushort index,
|
||||
long dataSize, long journalSize, bool allowExisting)
|
||||
{
|
||||
requiredSize = default;
|
||||
UnsafeHelpers.SkipParamInit(out requiredSize);
|
||||
target = CacheStorageTargetMedia.SdCard;
|
||||
|
||||
Result rc = fs.GetCacheStorageTargetMediaImpl(out CacheStorageTargetMedia targetMedia, applicationId);
|
||||
@ -317,12 +318,10 @@ namespace LibHac.Fs
|
||||
public static Result EnsureApplicationCacheStorage(this FileSystemClient fs, out long requiredSize,
|
||||
out CacheStorageTargetMedia target, Ncm.ApplicationId applicationId, ref ApplicationControlProperty nacp)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out requiredSize, out target);
|
||||
|
||||
if (nacp.CacheStorageSize <= 0)
|
||||
{
|
||||
requiredSize = default;
|
||||
target = default;
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
return EnsureApplicationCacheStorageImpl(fs, out requiredSize, out target, applicationId,
|
||||
nacp.SaveDataOwnerId.Value, 0, nacp.CacheStorageSize, nacp.CacheStorageJournalSize, true);
|
||||
@ -338,7 +337,7 @@ namespace LibHac.Fs
|
||||
SaveDataSpaceId spaceId, Ncm.ApplicationId applicationId, ulong saveDataOwnerId, ushort index,
|
||||
long dataSize, long journalSize, bool allowExisting)
|
||||
{
|
||||
requiredSize = default;
|
||||
UnsafeHelpers.SkipParamInit(out requiredSize);
|
||||
long requiredSizeLocal = 0;
|
||||
|
||||
var filter = new SaveDataFilter();
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs.Fsa;
|
||||
|
||||
namespace LibHac.Fs
|
||||
@ -66,7 +67,7 @@ namespace LibHac.Fs
|
||||
|
||||
protected override Result DoGetSize(out long size)
|
||||
{
|
||||
size = default;
|
||||
UnsafeHelpers.SkipParamInit(out size);
|
||||
|
||||
Result rc = UpdateSize();
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs.Fsa;
|
||||
|
||||
namespace LibHac.Fs
|
||||
@ -75,12 +76,10 @@ namespace LibHac.Fs
|
||||
|
||||
protected override Result DoGetSize(out long size)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out size);
|
||||
|
||||
Result rc = UpdateSize();
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
size = default;
|
||||
return rc;
|
||||
}
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
||||
size = FileSize;
|
||||
return Result.Success;
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using LibHac.Common;
|
||||
using LibHac.Diag;
|
||||
using LibHac.Fs.Fsa;
|
||||
@ -84,7 +83,7 @@ namespace LibHac.Fs.Impl
|
||||
|
||||
public Result Read(out long bytesRead, long offset, Span<byte> destination, in ReadOption option)
|
||||
{
|
||||
Unsafe.SkipInit(out bytesRead);
|
||||
UnsafeHelpers.SkipParamInit(out bytesRead);
|
||||
|
||||
Result rc;
|
||||
Span<byte> logBuffer = stackalloc byte[0x50];
|
||||
@ -208,7 +207,7 @@ namespace LibHac.Fs.Impl
|
||||
|
||||
public Result GetSize(out long size)
|
||||
{
|
||||
Unsafe.SkipInit(out size);
|
||||
UnsafeHelpers.SkipParamInit(out size);
|
||||
|
||||
if (_lastResult.IsFailure())
|
||||
return _lastResult;
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using LibHac.Common;
|
||||
using LibHac.Diag;
|
||||
using LibHac.Fs.Fsa;
|
||||
@ -234,7 +233,7 @@ namespace LibHac.Fs.Impl
|
||||
|
||||
public Result GetEntryType(out DirectoryEntryType entryType, U8Span path)
|
||||
{
|
||||
Unsafe.SkipInit(out entryType);
|
||||
UnsafeHelpers.SkipParamInit(out entryType);
|
||||
|
||||
Result rc = CheckPath(new U8Span(_mountName.Name), path);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -244,7 +243,7 @@ namespace LibHac.Fs.Impl
|
||||
|
||||
public Result GetFreeSpaceSize(out long freeSpace, U8Span path)
|
||||
{
|
||||
Unsafe.SkipInit(out freeSpace);
|
||||
UnsafeHelpers.SkipParamInit(out freeSpace);
|
||||
|
||||
Result rc = CheckPath(new U8Span(_mountName.Name), path);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -254,7 +253,7 @@ namespace LibHac.Fs.Impl
|
||||
|
||||
public Result GetTotalSpaceSize(out long totalSpace, U8Span path)
|
||||
{
|
||||
Unsafe.SkipInit(out totalSpace);
|
||||
UnsafeHelpers.SkipParamInit(out totalSpace);
|
||||
|
||||
Result rc = CheckPath(new U8Span(_mountName.Name), path);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -264,7 +263,7 @@ namespace LibHac.Fs.Impl
|
||||
|
||||
public Result OpenFile(out FileAccessor file, U8Span path, OpenMode mode)
|
||||
{
|
||||
file = default;
|
||||
UnsafeHelpers.SkipParamInit(out file);
|
||||
|
||||
Result rc = CheckPath(new U8Span(_mountName.Name), path);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -305,7 +304,7 @@ namespace LibHac.Fs.Impl
|
||||
|
||||
public Result OpenDirectory(out DirectoryAccessor directory, U8Span path, OpenDirectoryMode mode)
|
||||
{
|
||||
directory = default;
|
||||
UnsafeHelpers.SkipParamInit(out directory);
|
||||
|
||||
Result rc = CheckPath(new U8Span(_mountName.Name), path);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -370,7 +369,7 @@ namespace LibHac.Fs.Impl
|
||||
|
||||
public Result GetSaveDataAttribute(out SaveDataAttribute attribute)
|
||||
{
|
||||
Unsafe.SkipInit(out attribute);
|
||||
UnsafeHelpers.SkipParamInit(out attribute);
|
||||
|
||||
if (_saveDataAttributeGetter is null)
|
||||
return ResultFs.PreconditionViolation.Log();
|
||||
|
@ -15,11 +15,10 @@ namespace LibHac.Fs.Fsa
|
||||
|
||||
public Result GetFileAttributes(out NxFileAttributes attributes, U8Span path)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out attributes);
|
||||
|
||||
if (path.IsNull())
|
||||
{
|
||||
attributes = default;
|
||||
return ResultFs.NullptrArgument.Log();
|
||||
}
|
||||
|
||||
return DoGetFileAttributes(out attributes, path);
|
||||
}
|
||||
@ -34,11 +33,10 @@ namespace LibHac.Fs.Fsa
|
||||
|
||||
public Result GetFileSize(out long fileSize, U8Span path)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out fileSize);
|
||||
|
||||
if (path.IsNull())
|
||||
{
|
||||
fileSize = default;
|
||||
return ResultFs.NullptrArgument.Log();
|
||||
}
|
||||
|
||||
return DoGetFileSize(out fileSize, path);
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using LibHac.Common;
|
||||
using LibHac.Diag;
|
||||
|
||||
namespace LibHac.Fs.Fsa
|
||||
@ -32,6 +34,11 @@ namespace LibHac.Fs.Fsa
|
||||
/// <returns>The <see cref="Result"/> of the requested operation.</returns>
|
||||
public Result Read(out long bytesRead, long offset, Span<byte> destination, in ReadOption option)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out bytesRead);
|
||||
|
||||
if (Unsafe.IsNullRef(ref bytesRead))
|
||||
return ResultFs.NullptrArgument.Log();
|
||||
|
||||
if (destination.IsEmpty)
|
||||
{
|
||||
bytesRead = 0;
|
||||
@ -39,16 +46,10 @@ namespace LibHac.Fs.Fsa
|
||||
}
|
||||
|
||||
if (offset < 0)
|
||||
{
|
||||
bytesRead = 0;
|
||||
return ResultFs.OutOfRange.Log();
|
||||
}
|
||||
|
||||
if (long.MaxValue - offset < destination.Length)
|
||||
{
|
||||
bytesRead = 0;
|
||||
return ResultFs.OutOfRange.Log();
|
||||
}
|
||||
|
||||
return DoRead(out bytesRead, offset, destination, in option);
|
||||
}
|
||||
@ -157,26 +158,18 @@ namespace LibHac.Fs.Fsa
|
||||
protected Result DryRead(out long readableBytes, long offset, long size, in ReadOption option,
|
||||
OpenMode openMode)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out readableBytes);
|
||||
|
||||
// Check that we can read.
|
||||
if (!openMode.HasFlag(OpenMode.Read))
|
||||
{
|
||||
readableBytes = default;
|
||||
return ResultFs.ReadUnpermitted.Log();
|
||||
}
|
||||
|
||||
// Get the file size, and validate our offset.
|
||||
Result rc = GetSize(out long fileSize);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
readableBytes = default;
|
||||
return rc;
|
||||
}
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
||||
if (offset > fileSize)
|
||||
{
|
||||
readableBytes = default;
|
||||
return ResultFs.OutOfRange.Log();
|
||||
}
|
||||
|
||||
readableBytes = Math.Min(fileSize - offset, size);
|
||||
return Result.Success;
|
||||
@ -196,28 +189,20 @@ namespace LibHac.Fs.Fsa
|
||||
protected Result DryWrite(out bool needsAppend, long offset, long size, in WriteOption option,
|
||||
OpenMode openMode)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out needsAppend);
|
||||
|
||||
// Check that we can write.
|
||||
if (!openMode.HasFlag(OpenMode.Write))
|
||||
{
|
||||
needsAppend = default;
|
||||
return ResultFs.WriteUnpermitted.Log();
|
||||
}
|
||||
|
||||
// Get the file size.
|
||||
Result rc = GetSize(out long fileSize);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
needsAppend = default;
|
||||
return rc;
|
||||
}
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
||||
if (fileSize < offset + size)
|
||||
{
|
||||
if (!openMode.HasFlag(OpenMode.AllowAppend))
|
||||
{
|
||||
needsAppend = default;
|
||||
return ResultFs.FileExtensionWithoutOpenModeAllowAppend.Log();
|
||||
}
|
||||
|
||||
needsAppend = true;
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using LibHac.Common;
|
||||
using LibHac.FsSystem;
|
||||
|
||||
@ -214,11 +213,10 @@ namespace LibHac.Fs.Fsa
|
||||
/// <returns>The <see cref="Result"/> of the requested operation.</returns>
|
||||
public Result GetEntryType(out DirectoryEntryType entryType, U8Span path)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out entryType);
|
||||
|
||||
if (path.IsNull())
|
||||
{
|
||||
entryType = default;
|
||||
return ResultFs.NullptrArgument.Log();
|
||||
}
|
||||
|
||||
return DoGetEntryType(out entryType, path);
|
||||
}
|
||||
@ -231,11 +229,10 @@ namespace LibHac.Fs.Fsa
|
||||
/// <returns>The <see cref="Result"/> of the requested operation.</returns>
|
||||
public Result GetFreeSpaceSize(out long freeSpace, U8Span path)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out freeSpace);
|
||||
|
||||
if (path.IsNull())
|
||||
{
|
||||
freeSpace = default;
|
||||
return ResultFs.NullptrArgument.Log();
|
||||
}
|
||||
|
||||
return DoGetFreeSpaceSize(out freeSpace, path);
|
||||
}
|
||||
@ -248,11 +245,10 @@ namespace LibHac.Fs.Fsa
|
||||
/// <returns>The <see cref="Result"/> of the requested operation.</returns>
|
||||
public Result GetTotalSpaceSize(out long totalSpace, U8Span path)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out totalSpace);
|
||||
|
||||
if (path.IsNull())
|
||||
{
|
||||
totalSpace = default;
|
||||
return ResultFs.NullptrArgument.Log();
|
||||
}
|
||||
|
||||
return DoGetTotalSpaceSize(out totalSpace, path);
|
||||
}
|
||||
@ -274,19 +270,19 @@ namespace LibHac.Fs.Fsa
|
||||
{
|
||||
if (path.IsNull())
|
||||
{
|
||||
file = default;
|
||||
UnsafeHelpers.SkipParamInit(out file);
|
||||
return ResultFs.NullptrArgument.Log();
|
||||
}
|
||||
|
||||
if ((mode & OpenMode.ReadWrite) == 0)
|
||||
{
|
||||
file = default;
|
||||
UnsafeHelpers.SkipParamInit(out file);
|
||||
return ResultFs.InvalidOpenMode.Log();
|
||||
}
|
||||
|
||||
if ((mode & ~OpenMode.All) != 0)
|
||||
{
|
||||
file = default;
|
||||
UnsafeHelpers.SkipParamInit(out file);
|
||||
return ResultFs.InvalidOpenMode.Log();
|
||||
}
|
||||
|
||||
@ -310,19 +306,19 @@ namespace LibHac.Fs.Fsa
|
||||
{
|
||||
if (path.IsNull())
|
||||
{
|
||||
directory = default;
|
||||
UnsafeHelpers.SkipParamInit(out directory);
|
||||
return ResultFs.NullptrArgument.Log();
|
||||
}
|
||||
|
||||
if ((mode & OpenDirectoryMode.All) == 0)
|
||||
{
|
||||
directory = default;
|
||||
UnsafeHelpers.SkipParamInit(out directory);
|
||||
return ResultFs.InvalidOpenMode.Log();
|
||||
}
|
||||
|
||||
if ((mode & ~(OpenDirectoryMode.All | OpenDirectoryMode.NoFileSize)) != 0)
|
||||
{
|
||||
directory = default;
|
||||
UnsafeHelpers.SkipParamInit(out directory);
|
||||
return ResultFs.InvalidOpenMode.Log();
|
||||
}
|
||||
|
||||
@ -358,7 +354,7 @@ namespace LibHac.Fs.Fsa
|
||||
{
|
||||
if (path.IsNull())
|
||||
{
|
||||
timeStamp = default;
|
||||
UnsafeHelpers.SkipParamInit(out timeStamp);
|
||||
return ResultFs.NullptrArgument.Log();
|
||||
}
|
||||
|
||||
@ -397,13 +393,13 @@ namespace LibHac.Fs.Fsa
|
||||
|
||||
protected virtual Result DoGetFreeSpaceSize(out long freeSpace, U8Span path)
|
||||
{
|
||||
freeSpace = default;
|
||||
UnsafeHelpers.SkipParamInit(out freeSpace);
|
||||
return ResultFs.NotImplemented.Log();
|
||||
}
|
||||
|
||||
protected virtual Result DoGetTotalSpaceSize(out long totalSpace, U8Span path)
|
||||
{
|
||||
totalSpace = default;
|
||||
UnsafeHelpers.SkipParamInit(out totalSpace);
|
||||
return ResultFs.NotImplemented.Log();
|
||||
}
|
||||
|
||||
@ -417,7 +413,7 @@ namespace LibHac.Fs.Fsa
|
||||
|
||||
protected virtual Result DoGetFileTimeStampRaw(out FileTimeStampRaw timeStamp, U8Span path)
|
||||
{
|
||||
Unsafe.SkipInit(out timeStamp);
|
||||
UnsafeHelpers.SkipParamInit(out timeStamp);
|
||||
return ResultFs.NotImplemented.Log();
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ namespace LibHac.Fs.Impl
|
||||
|
||||
public Result Find(out FileSystemAccessor accessor, U8Span name)
|
||||
{
|
||||
accessor = default;
|
||||
UnsafeHelpers.SkipParamInit(out accessor);
|
||||
using ScopedLock<SdkMutexType> lk = ScopedLock.Lock(ref _mutex);
|
||||
|
||||
for (LinkedListNode<FileSystemAccessor> currentNode = _fileSystemList.First;
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using LibHac.Common;
|
||||
using LibHac.Diag;
|
||||
using LibHac.Fs.Impl;
|
||||
@ -14,7 +13,7 @@ namespace LibHac.Fs.Fsa
|
||||
{
|
||||
internal static Result GetMountNameAndSubPath(out MountName mountName, out U8Span subPath, U8Span path)
|
||||
{
|
||||
Unsafe.SkipInit(out mountName);
|
||||
UnsafeHelpers.SkipParamInit(out mountName);
|
||||
subPath = default;
|
||||
|
||||
int mountLen = 0;
|
||||
@ -94,7 +93,7 @@ namespace LibHac.Fs.Fsa
|
||||
internal static Result FindFileSystem(this FileSystemClientImpl fs, out FileSystemAccessor fileSystem,
|
||||
out U8Span subPath, U8Span path)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
subPath = default;
|
||||
|
||||
if (path.IsNull())
|
||||
@ -153,7 +152,7 @@ namespace LibHac.Fs.Fsa
|
||||
|
||||
public static Result IsMounted(this FileSystemClientImpl fs, out bool isMounted, U8Span mountName)
|
||||
{
|
||||
Unsafe.SkipInit(out isMounted);
|
||||
UnsafeHelpers.SkipParamInit(out isMounted);
|
||||
|
||||
Result rc = fs.Find(out _, mountName);
|
||||
if (rc.IsFailure())
|
||||
|
@ -206,7 +206,7 @@ namespace LibHac.Fs.Fsa
|
||||
public static Result QueryRange(this FileSystemClient fs, out QueryRangeInfo rangeInfo, FileHandle handle,
|
||||
long offset, long size)
|
||||
{
|
||||
Unsafe.SkipInit(out rangeInfo);
|
||||
UnsafeHelpers.SkipParamInit(out rangeInfo);
|
||||
|
||||
Result rc = Get(handle).OperateRange(SpanHelpers.AsByteSpan(ref rangeInfo), OperationId.QueryRange, offset,
|
||||
size, ReadOnlySpan<byte>.Empty);
|
||||
|
@ -362,7 +362,7 @@ namespace LibHac.Fs.Fsa
|
||||
|
||||
public static Result GetEntryType(this FileSystemClient fs, out DirectoryEntryType type, U8Span path)
|
||||
{
|
||||
Unsafe.SkipInit(out type);
|
||||
UnsafeHelpers.SkipParamInit(out type);
|
||||
|
||||
Result rc;
|
||||
U8Span subPath;
|
||||
@ -414,7 +414,7 @@ namespace LibHac.Fs.Fsa
|
||||
|
||||
public static Result GetFreeSpaceSize(this FileSystemClient fs, out long freeSpace, U8Span path)
|
||||
{
|
||||
Unsafe.SkipInit(out freeSpace);
|
||||
UnsafeHelpers.SkipParamInit(out freeSpace);
|
||||
|
||||
Result rc;
|
||||
var subPath = U8Span.Empty;
|
||||
@ -482,7 +482,7 @@ namespace LibHac.Fs.Fsa
|
||||
|
||||
public static Result OpenFile(this FileSystemClient fs, out FileHandle handle, U8Span path, OpenMode mode)
|
||||
{
|
||||
handle = default;
|
||||
UnsafeHelpers.SkipParamInit(out handle);
|
||||
|
||||
Result rc;
|
||||
U8Span subPath;
|
||||
@ -539,7 +539,7 @@ namespace LibHac.Fs.Fsa
|
||||
public static Result OpenDirectory(this FileSystemClient fs, out DirectoryHandle handle, U8Span path,
|
||||
OpenDirectoryMode mode)
|
||||
{
|
||||
handle = default;
|
||||
UnsafeHelpers.SkipParamInit(out handle);
|
||||
|
||||
Result rc;
|
||||
U8Span subPath;
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs.Impl;
|
||||
using LibHac.Os;
|
||||
@ -57,7 +56,7 @@ namespace LibHac.Fs.Fsa
|
||||
|
||||
public static Result GetTotalSpaceSize(this FileSystemClient fs, out long totalSpace, U8Span path)
|
||||
{
|
||||
Unsafe.SkipInit(out totalSpace);
|
||||
UnsafeHelpers.SkipParamInit(out totalSpace);
|
||||
|
||||
Result rc = fs.Impl.FindFileSystem(out FileSystemAccessor fileSystem, out U8Span subPath, path);
|
||||
fs.Impl.AbortIfNeeded(rc);
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using LibHac.Common;
|
||||
|
||||
namespace LibHac.Fs
|
||||
{
|
||||
@ -84,11 +85,10 @@ namespace LibHac.Fs
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Result GetSize(out long size)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out size);
|
||||
|
||||
if (IsDisposed)
|
||||
{
|
||||
size = default;
|
||||
return ResultFs.PreconditionViolation.Log();
|
||||
}
|
||||
|
||||
return DoGetSize(out size);
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ namespace LibHac.Fs.Impl
|
||||
|
||||
protected override Result DoGetEntryType(out DirectoryEntryType entryType, U8Span path)
|
||||
{
|
||||
Unsafe.SkipInit(out entryType);
|
||||
UnsafeHelpers.SkipParamInit(out entryType);
|
||||
|
||||
Result rc = GetPathForServiceObject(out Path sfPath, path);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -107,7 +107,7 @@ namespace LibHac.Fs.Impl
|
||||
|
||||
protected override Result DoGetFreeSpaceSize(out long freeSpace, U8Span path)
|
||||
{
|
||||
Unsafe.SkipInit(out freeSpace);
|
||||
UnsafeHelpers.SkipParamInit(out freeSpace);
|
||||
|
||||
Result rc = GetPathForServiceObject(out Path sfPath, path);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -117,7 +117,7 @@ namespace LibHac.Fs.Impl
|
||||
|
||||
protected override Result DoGetTotalSpaceSize(out long totalSpace, U8Span path)
|
||||
{
|
||||
Unsafe.SkipInit(out totalSpace);
|
||||
UnsafeHelpers.SkipParamInit(out totalSpace);
|
||||
|
||||
Result rc = GetPathForServiceObject(out Path sfPath, path);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -127,7 +127,7 @@ namespace LibHac.Fs.Impl
|
||||
|
||||
protected override Result DoOpenFile(out Fsa.IFile file, U8Span path, OpenMode mode)
|
||||
{
|
||||
file = default;
|
||||
UnsafeHelpers.SkipParamInit(out file);
|
||||
|
||||
Result rc = GetPathForServiceObject(out Path sfPath, path);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -149,7 +149,7 @@ namespace LibHac.Fs.Impl
|
||||
|
||||
protected override Result DoOpenDirectory(out Fsa.IDirectory directory, U8Span path, OpenDirectoryMode mode)
|
||||
{
|
||||
directory = default;
|
||||
UnsafeHelpers.SkipParamInit(out directory);
|
||||
|
||||
Result rc = GetPathForServiceObject(out Path sfPath, path);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -176,7 +176,7 @@ namespace LibHac.Fs.Impl
|
||||
|
||||
protected override Result DoGetFileTimeStampRaw(out FileTimeStampRaw timeStamp, U8Span path)
|
||||
{
|
||||
Unsafe.SkipInit(out timeStamp);
|
||||
UnsafeHelpers.SkipParamInit(out timeStamp);
|
||||
|
||||
Result rc = GetPathForServiceObject(out Path sfPath, path);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -211,7 +211,7 @@ namespace LibHac.Fs.Impl
|
||||
private Result GetPathForServiceObject(out Path sfPath, U8Span path)
|
||||
{
|
||||
// This is the function used to create Sf.Path structs. Get an unsafe byte span for init only.
|
||||
Unsafe.SkipInit(out sfPath);
|
||||
UnsafeHelpers.SkipParamInit(out sfPath);
|
||||
Span<byte> outPath = SpanHelpers.AsByteSpan(ref sfPath);
|
||||
|
||||
// Copy and null terminate
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using LibHac.Common;
|
||||
using LibHac.Common.FixedArrays;
|
||||
using LibHac.Diag;
|
||||
using LibHac.Fs.Fsa;
|
||||
@ -19,7 +19,7 @@ namespace LibHac.Fs.Impl
|
||||
public Result Read(IFile file, out long bytesRead, long offset, Span<byte> destination, in ReadOption option,
|
||||
ref FileDataCacheAccessResult cacheAccessResult)
|
||||
{
|
||||
Unsafe.SkipInit(out bytesRead);
|
||||
UnsafeHelpers.SkipParamInit(out bytesRead);
|
||||
|
||||
if (destination.Length == 0)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using LibHac.Common;
|
||||
|
||||
namespace LibHac.Fs.Impl
|
||||
{
|
||||
@ -14,7 +14,7 @@ namespace LibHac.Fs.Impl
|
||||
|
||||
public void GenerateMetaInfo(out SaveDataMetaInfo metaInfo)
|
||||
{
|
||||
Unsafe.SkipInit(out metaInfo);
|
||||
UnsafeHelpers.SkipParamInit(out metaInfo);
|
||||
|
||||
if (_type == SaveDataType.Account || _type == SaveDataType.Device)
|
||||
{
|
||||
|
@ -70,7 +70,7 @@ namespace LibHac.Fs
|
||||
|
||||
protected override Result DoOpenDirectory(out IDirectory directory, U8Span path, OpenDirectoryMode mode)
|
||||
{
|
||||
directory = default;
|
||||
UnsafeHelpers.SkipParamInit(out directory);
|
||||
|
||||
Result rs = FsTable.GetDirectory(new U8Span(path), out DirectoryNode dirNode);
|
||||
if (rs.IsFailure()) return rs;
|
||||
@ -81,7 +81,7 @@ namespace LibHac.Fs
|
||||
|
||||
protected override Result DoOpenFile(out IFile file, U8Span path, OpenMode mode)
|
||||
{
|
||||
file = default;
|
||||
UnsafeHelpers.SkipParamInit(out file);
|
||||
|
||||
Result rc = FsTable.GetFile(path, out FileNode fileNode);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -103,6 +103,8 @@ namespace LibHac.Fs
|
||||
|
||||
protected override Result DoGetEntryType(out DirectoryEntryType entryType, U8Span path)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out entryType);
|
||||
|
||||
if (FsTable.GetFile(path, out _).IsSuccess())
|
||||
{
|
||||
entryType = DirectoryEntryType.File;
|
||||
@ -115,7 +117,6 @@ namespace LibHac.Fs
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
entryType = default;
|
||||
return ResultFs.PathNotFound.Log();
|
||||
}
|
||||
|
||||
@ -126,6 +127,8 @@ namespace LibHac.Fs
|
||||
|
||||
protected override Result DoGetFileAttributes(out NxFileAttributes attributes, U8Span path)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out attributes);
|
||||
|
||||
if (FsTable.GetFile(path, out FileNode file).IsSuccess())
|
||||
{
|
||||
attributes = file.Attributes;
|
||||
@ -138,7 +141,6 @@ namespace LibHac.Fs
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
attributes = default;
|
||||
return ResultFs.PathNotFound.Log();
|
||||
}
|
||||
|
||||
@ -161,12 +163,13 @@ namespace LibHac.Fs
|
||||
|
||||
protected override Result DoGetFileSize(out long fileSize, U8Span path)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out fileSize);
|
||||
|
||||
if (FsTable.GetFile(path, out FileNode file).IsSuccess())
|
||||
{
|
||||
return file.File.GetSize(out fileSize);
|
||||
}
|
||||
|
||||
fileSize = default;
|
||||
return ResultFs.PathNotFound.Log();
|
||||
}
|
||||
|
||||
@ -346,7 +349,7 @@ namespace LibHac.Fs
|
||||
{
|
||||
if (offset > BaseStream.Length)
|
||||
{
|
||||
bytesRead = default;
|
||||
bytesRead = 0;
|
||||
return ResultFs.OutOfRange.Log();
|
||||
}
|
||||
|
||||
@ -626,7 +629,7 @@ namespace LibHac.Fs
|
||||
Result rc = FindDirectory(parentPath, out DirectoryNode parentNode);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
file = default;
|
||||
UnsafeHelpers.SkipParamInit(out file);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -654,7 +657,7 @@ namespace LibHac.Fs
|
||||
|
||||
if (!TryFindChildDirectory(currentDir, current, out DirectoryNode child))
|
||||
{
|
||||
directory = default;
|
||||
UnsafeHelpers.SkipParamInit(out directory);
|
||||
return ResultFs.PathNotFound.Log();
|
||||
}
|
||||
|
||||
@ -680,7 +683,7 @@ namespace LibHac.Fs
|
||||
currentChild = currentChild.Next;
|
||||
}
|
||||
|
||||
child = default;
|
||||
UnsafeHelpers.SkipParamInit(out child);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -699,7 +702,7 @@ namespace LibHac.Fs
|
||||
currentChild = currentChild.Next;
|
||||
}
|
||||
|
||||
child = default;
|
||||
UnsafeHelpers.SkipParamInit(out child);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ namespace LibHac.Fs
|
||||
public static Result Normalize(Span<byte> outputBuffer, out long normalizedLength, U8Span path,
|
||||
bool preserveUnc, bool hasMountName)
|
||||
{
|
||||
normalizedLength = default;
|
||||
UnsafeHelpers.SkipParamInit(out normalizedLength);
|
||||
|
||||
U8Span path2 = path;
|
||||
int prefixLength = 0;
|
||||
@ -318,7 +318,7 @@ namespace LibHac.Fs
|
||||
|
||||
public static Result IsNormalized(out bool isNormalized, U8Span path, bool preserveUnc, bool hasMountName)
|
||||
{
|
||||
isNormalized = default;
|
||||
UnsafeHelpers.SkipParamInit(out isNormalized);
|
||||
U8Span path2 = path;
|
||||
bool isUncPath = false;
|
||||
|
||||
@ -478,7 +478,7 @@ namespace LibHac.Fs
|
||||
out long mountNameLength, U8Span path)
|
||||
{
|
||||
pathAfterMount = default;
|
||||
mountNameLength = default;
|
||||
UnsafeHelpers.SkipParamInit(out mountNameLength);
|
||||
|
||||
int mountStart = IsSeparator(path.GetOrNull(0)) ? 1 : 0;
|
||||
int mountEnd;
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using LibHac.Common;
|
||||
using LibHac.FsSrv.Impl;
|
||||
@ -52,7 +51,7 @@ namespace LibHac.Fs
|
||||
public static Result Make(out SaveDataAttribute attribute, ProgramId programId, SaveDataType type,
|
||||
UserId userId, ulong staticSaveDataId, ushort index, SaveDataRank rank)
|
||||
{
|
||||
Unsafe.SkipInit(out attribute);
|
||||
UnsafeHelpers.SkipParamInit(out attribute);
|
||||
SaveDataAttribute tempAttribute = default;
|
||||
|
||||
tempAttribute.ProgramId = programId;
|
||||
@ -124,7 +123,7 @@ namespace LibHac.Fs
|
||||
public static Result Make(out SaveDataCreationInfo creationInfo, long size, long journalSize, ulong ownerId,
|
||||
SaveDataFlags flags, SaveDataSpaceId spaceId)
|
||||
{
|
||||
Unsafe.SkipInit(out creationInfo);
|
||||
UnsafeHelpers.SkipParamInit(out creationInfo);
|
||||
SaveDataCreationInfo tempCreationInfo = default;
|
||||
|
||||
tempCreationInfo.Size = size;
|
||||
@ -194,7 +193,7 @@ namespace LibHac.Fs
|
||||
public static Result Make(out SaveDataFilter filter, Optional<ulong> programId, Optional<SaveDataType> saveType,
|
||||
Optional<UserId> userId, Optional<ulong> saveDataId, Optional<ushort> index, SaveDataRank rank)
|
||||
{
|
||||
Unsafe.SkipInit(out filter);
|
||||
UnsafeHelpers.SkipParamInit(out filter);
|
||||
|
||||
SaveDataFilter tempFilter = Make(programId, saveType, userId, saveDataId, index, rank);
|
||||
|
||||
|
@ -49,7 +49,8 @@ namespace LibHac.Fs.Shim
|
||||
}
|
||||
}
|
||||
|
||||
private static Result MountBis(this FileSystemClientImpl fs, U8Span mountName, BisPartitionId partitionId, U8Span rootPath)
|
||||
private static Result MountBis(this FileSystemClientImpl fs, U8Span mountName, BisPartitionId partitionId,
|
||||
U8Span rootPath)
|
||||
{
|
||||
Result rc;
|
||||
|
||||
@ -73,6 +74,7 @@ namespace LibHac.Fs.Shim
|
||||
{
|
||||
rc = Mount(fs, mountName, partitionId);
|
||||
}
|
||||
|
||||
fs.AbortIfNeeded(rc);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
||||
@ -192,7 +194,7 @@ namespace LibHac.Fs.Shim
|
||||
public static Result OpenBisPartition(this FileSystemClient fs, out IStorage partitionStorage,
|
||||
BisPartitionId partitionId)
|
||||
{
|
||||
partitionStorage = default;
|
||||
UnsafeHelpers.SkipParamInit(out partitionStorage);
|
||||
|
||||
ReferenceCountedDisposable<IStorageSf> storage = null;
|
||||
try
|
||||
|
@ -48,7 +48,7 @@ namespace LibHac.Fs.Shim
|
||||
static Result Mount(FileSystemClient fs, out CodeVerificationData verificationData,
|
||||
U8Span mountName, U8Span path, ProgramId programId)
|
||||
{
|
||||
Unsafe.SkipInit(out verificationData);
|
||||
UnsafeHelpers.SkipParamInit(out verificationData);
|
||||
|
||||
Result rc = fs.Impl.CheckMountName(mountName);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
@ -70,7 +70,7 @@ namespace LibHac.Fs.Shim
|
||||
|
||||
public static Result GetGameCardHandle(this FileSystemClient fs, out GameCardHandle handle)
|
||||
{
|
||||
Unsafe.SkipInit(out handle);
|
||||
UnsafeHelpers.SkipParamInit(out handle);
|
||||
|
||||
using ReferenceCountedDisposable<IFileSystemProxy> fsProxy = fs.Impl.GetFileSystemProxyServiceObject();
|
||||
|
||||
@ -175,7 +175,7 @@ namespace LibHac.Fs.Shim
|
||||
public static Result OpenGameCardPartition(this FileSystemClient fs, out IStorage storage,
|
||||
GameCardHandle handle, GameCardPartitionRaw partitionType)
|
||||
{
|
||||
storage = default;
|
||||
UnsafeHelpers.SkipParamInit(out storage);
|
||||
|
||||
using ReferenceCountedDisposable<IFileSystemProxy> fsProxy = fs.Impl.GetFileSystemProxyServiceObject();
|
||||
|
||||
|
@ -38,7 +38,7 @@ namespace LibHac.Fs.Shim
|
||||
private static Result OpenHostFileSystemImpl(FileSystemClient fs, out IFileSystem fileSystem, in FspPath path,
|
||||
MountHostOption option)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
using ReferenceCountedDisposable<IFileSystemProxy> fsProxy = fs.Impl.GetFileSystemProxyServiceObject();
|
||||
|
||||
@ -130,7 +130,7 @@ namespace LibHac.Fs.Shim
|
||||
private static Result OpenHostFileSystem(FileSystemClient fs, out IFileSystem fileSystem, U8Span mountName,
|
||||
U8Span path, MountHostOption option)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
if (mountName.IsNull())
|
||||
return ResultFs.NullptrArgument.Log();
|
||||
@ -196,7 +196,7 @@ namespace LibHac.Fs.Shim
|
||||
private static Result PreMountHost(FileSystemClient fs, out HostCommonMountNameGenerator nameGenerator,
|
||||
U8Span mountName, U8Span path)
|
||||
{
|
||||
nameGenerator = default;
|
||||
UnsafeHelpers.SkipParamInit(out nameGenerator);
|
||||
|
||||
Result rc = fs.Impl.CheckMountName(mountName);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
@ -18,7 +18,7 @@ namespace LibHac.Fs.Shim
|
||||
|
||||
public static Result GetRightsId(this FileSystemClient fs, out FsRightsId rightsId, U8Span path)
|
||||
{
|
||||
rightsId = default;
|
||||
UnsafeHelpers.SkipParamInit(out rightsId);
|
||||
|
||||
using ReferenceCountedDisposable<IFileSystemProxy> fsProxy = fs.Impl.GetFileSystemProxyServiceObject();
|
||||
|
||||
@ -30,8 +30,7 @@ namespace LibHac.Fs.Shim
|
||||
|
||||
public static Result GetRightsId(this FileSystemClient fs, out FsRightsId rightsId, out byte keyGeneration, U8Span path)
|
||||
{
|
||||
rightsId = default;
|
||||
keyGeneration = default;
|
||||
UnsafeHelpers.SkipParamInit(out rightsId, out keyGeneration);
|
||||
|
||||
using ReferenceCountedDisposable<IFileSystemProxy> fsProxy = fs.Impl.GetFileSystemProxyServiceObject();
|
||||
|
||||
|
@ -65,7 +65,6 @@ namespace LibHac.Fs.Shim
|
||||
[SkipLocalsInit]
|
||||
public static class SaveDataManagement
|
||||
{
|
||||
|
||||
internal static Result ReadSaveDataFileSystemExtraData(this FileSystemClientImpl fs,
|
||||
out SaveDataExtraData extraData, ulong saveDataId)
|
||||
{
|
||||
@ -112,7 +111,7 @@ namespace LibHac.Fs.Shim
|
||||
internal static Result FindSaveDataWithFilter(this FileSystemClientImpl fs, out SaveDataInfo saveInfo,
|
||||
SaveDataSpaceId spaceId, in SaveDataFilter filter)
|
||||
{
|
||||
saveInfo = default;
|
||||
UnsafeHelpers.SkipParamInit(out saveInfo);
|
||||
|
||||
using ReferenceCountedDisposable<IFileSystemProxy> fsProxy = fs.GetFileSystemProxyServiceObject();
|
||||
|
||||
@ -285,7 +284,7 @@ namespace LibHac.Fs.Shim
|
||||
public static Result OpenSaveDataIterator(this FileSystemClientImpl fs, out SaveDataIterator iterator,
|
||||
SaveDataSpaceId spaceId)
|
||||
{
|
||||
iterator = default;
|
||||
UnsafeHelpers.SkipParamInit(out iterator);
|
||||
|
||||
using ReferenceCountedDisposable<IFileSystemProxy> fsProxy = fs.GetFileSystemProxyServiceObject();
|
||||
|
||||
@ -308,7 +307,7 @@ namespace LibHac.Fs.Shim
|
||||
public static Result OpenSaveDataIterator(this FileSystemClientImpl fs, out SaveDataIterator iterator,
|
||||
SaveDataSpaceId spaceId, in SaveDataFilter filter)
|
||||
{
|
||||
iterator = default;
|
||||
UnsafeHelpers.SkipParamInit(out iterator);
|
||||
|
||||
using ReferenceCountedDisposable<IFileSystemProxy> fsProxy = fs.GetFileSystemProxyServiceObject();
|
||||
|
||||
@ -725,7 +724,7 @@ namespace LibHac.Fs.Shim
|
||||
public static Result QuerySaveDataTotalSize(this FileSystemClientImpl fs, out long totalSize, long size,
|
||||
long journalSize)
|
||||
{
|
||||
Unsafe.SkipInit(out totalSize);
|
||||
UnsafeHelpers.SkipParamInit(out totalSize);
|
||||
|
||||
using ReferenceCountedDisposable<IFileSystemProxy> fsProxy = fs.GetFileSystemProxyServiceObject();
|
||||
|
||||
|
@ -24,7 +24,7 @@ namespace LibHac.Fs.Shim
|
||||
static Result OpenFileSystem(FileSystemClient fs, ReferenceCountedDisposable<IFileSystemProxy> fsProxy,
|
||||
out ReferenceCountedDisposable<IFileSystemSf> fileSystem)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
// Retry a few times if the storage device isn't ready yet
|
||||
const int maxRetries = 10;
|
||||
@ -153,7 +153,7 @@ namespace LibHac.Fs.Shim
|
||||
static Result CheckIfInserted(FileSystemClient fs,
|
||||
ReferenceCountedDisposable<IDeviceOperator> deviceOperator, out bool isInserted)
|
||||
{
|
||||
Unsafe.SkipInit(out isInserted);
|
||||
UnsafeHelpers.SkipParamInit(out isInserted);
|
||||
|
||||
// Retry a few times if the storage device isn't ready yet
|
||||
const int maxRetries = 10;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using LibHac.Common;
|
||||
using LibHac.Diag;
|
||||
|
||||
namespace LibHac.Fs
|
||||
@ -194,7 +195,7 @@ namespace LibHac.Fs
|
||||
|
||||
protected override Result DoGetSize(out long size)
|
||||
{
|
||||
size = default;
|
||||
UnsafeHelpers.SkipParamInit(out size);
|
||||
|
||||
if (!IsValid()) return ResultFs.NotInitialized.Log();
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.FsSrv.Impl;
|
||||
using LibHac.FsSrv.Sf;
|
||||
@ -25,7 +25,7 @@ namespace LibHac.FsSrv
|
||||
public Result OpenAccessFailureDetectionEventNotifier(out ReferenceCountedDisposable<IEventNotifier> notifier,
|
||||
ulong processId, bool notifyOnDeepRetry)
|
||||
{
|
||||
notifier = default;
|
||||
UnsafeHelpers.SkipParamInit(out notifier);
|
||||
|
||||
Result rc = GetProgramInfo(out ProgramInfo programInfo);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -42,7 +42,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result GetAccessFailureDetectionEvent(out NativeHandle eventHandle)
|
||||
{
|
||||
eventHandle = default;
|
||||
UnsafeHelpers.SkipParamInit(out eventHandle);
|
||||
|
||||
Result rc = GetProgramInfo(out ProgramInfo programInfo);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -58,7 +58,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result IsAccessFailureDetected(out bool isDetected, ulong processId)
|
||||
{
|
||||
Unsafe.SkipInit(out isDetected);
|
||||
UnsafeHelpers.SkipParamInit(out isDetected);
|
||||
|
||||
Result rc = GetProgramInfo(out ProgramInfo programInfo);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.FsSrv.Impl;
|
||||
using LibHac.FsSrv.Sf;
|
||||
@ -57,7 +58,7 @@ namespace LibHac.FsSrv
|
||||
public Result OpenBaseFileSystem(out ReferenceCountedDisposable<IFileSystemSf> fileSystem,
|
||||
BaseFileSystemId fileSystemId)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
Result rc = CheckCapabilityById(fileSystemId, _processId);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -84,7 +85,7 @@ namespace LibHac.FsSrv
|
||||
public Result OpenBisFileSystem(out ReferenceCountedDisposable<IFileSystemSf> fileSystem, in FspPath rootPath,
|
||||
BisPartitionId partitionId)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
Result rc = GetProgramInfo(out ProgramInfo programInfo);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -170,7 +171,7 @@ namespace LibHac.FsSrv
|
||||
public Result OpenGameCardFileSystem(out ReferenceCountedDisposable<IFileSystemSf> fileSystem, GameCardHandle handle,
|
||||
GameCardPartition partitionId)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
Result rc = GetProgramInfo(out ProgramInfo programInfo);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -198,7 +199,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result OpenSdCardFileSystem(out ReferenceCountedDisposable<IFileSystemSf> fileSystem)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
Result rc = GetProgramInfo(out ProgramInfo programInfo);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -256,7 +257,7 @@ namespace LibHac.FsSrv
|
||||
public Result OpenImageDirectoryFileSystem(out ReferenceCountedDisposable<IFileSystemSf> fileSystem,
|
||||
ImageDirectoryId directoryId)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
// Caller must have the MountImageAndVideoStorage permission
|
||||
Result rc = GetProgramInfo(out ProgramInfo programInfo);
|
||||
@ -301,7 +302,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result OpenBisWiper(out ReferenceCountedDisposable<IWiper> bisWiper, NativeHandle transferMemoryHandle, ulong transferMemorySize)
|
||||
{
|
||||
bisWiper = default;
|
||||
UnsafeHelpers.SkipParamInit(out bisWiper);
|
||||
|
||||
// Caller must have the OpenBisWiper permission
|
||||
Result rc = GetProgramInfo(out ProgramInfo programInfo);
|
||||
|
@ -50,7 +50,7 @@ namespace LibHac.FsSrv
|
||||
public Result OpenBisFileSystem(out ReferenceCountedDisposable<IFileSystem> fileSystem, U8Span rootPath,
|
||||
BisPartitionId partitionId, bool caseSensitive)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
Result rc = _config.BisFileSystemCreator.Create(out IFileSystem fs, rootPath.ToString(), partitionId);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -95,7 +95,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result OpenSdCardProxyFileSystem(out ReferenceCountedDisposable<IFileSystem> fileSystem, bool openCaseSensitive)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
// Todo: Shared
|
||||
Result rc = _config.SdCardFileSystemCreator.Create(out IFileSystem fs, openCaseSensitive);
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.FsSrv.Creators;
|
||||
using LibHac.FsSrv.Impl;
|
||||
@ -23,7 +23,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result OpenBisStorage(out ReferenceCountedDisposable<IStorageSf> storage, BisPartitionId id)
|
||||
{
|
||||
storage = default;
|
||||
UnsafeHelpers.SkipParamInit(out storage);
|
||||
|
||||
var storageFlag = StorageType.Bis;
|
||||
using var scopedLayoutType = new ScopedStorageLayoutTypeSetter(storageFlag);
|
||||
@ -73,7 +73,7 @@ namespace LibHac.FsSrv
|
||||
public Result OpenGameCardStorage(out ReferenceCountedDisposable<IStorageSf> storage, GameCardHandle handle,
|
||||
GameCardPartitionRaw partitionId)
|
||||
{
|
||||
storage = default;
|
||||
UnsafeHelpers.SkipParamInit(out storage);
|
||||
|
||||
Result rc = GetProgramInfo(out ProgramInfo programInfo);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -111,7 +111,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result OpenSdCardDetectionEventNotifier(out ReferenceCountedDisposable<IEventNotifier> eventNotifier)
|
||||
{
|
||||
eventNotifier = default;
|
||||
UnsafeHelpers.SkipParamInit(out eventNotifier);
|
||||
|
||||
Result rc = GetProgramInfo(out ProgramInfo programInfo);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -124,7 +124,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result OpenGameCardDetectionEventNotifier(out ReferenceCountedDisposable<IEventNotifier> eventNotifier)
|
||||
{
|
||||
eventNotifier = default;
|
||||
UnsafeHelpers.SkipParamInit(out eventNotifier);
|
||||
|
||||
Result rc = GetProgramInfo(out ProgramInfo programInfo);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -155,7 +155,7 @@ namespace LibHac.FsSrv
|
||||
private static Result GetAccessibilityForOpenBisPartition(out Accessibility accessibility, ProgramInfo programInfo,
|
||||
BisPartitionId partitionId)
|
||||
{
|
||||
Unsafe.SkipInit(out accessibility);
|
||||
UnsafeHelpers.SkipParamInit(out accessibility);
|
||||
|
||||
AccessibilityType type = partitionId switch
|
||||
{
|
||||
@ -228,7 +228,7 @@ namespace LibHac.FsSrv
|
||||
case GameCardPartitionRaw.RootWriteOnly:
|
||||
return Config.GameCardStorageCreator.CreateWriteOnly(handle, out storage);
|
||||
default:
|
||||
storage = default;
|
||||
UnsafeHelpers.SkipParamInit(out storage);
|
||||
return ResultFs.InvalidArgument.Log();
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ namespace LibHac.FsSrv.Creators
|
||||
|
||||
public Result Create(out IFileSystem fileSystem, string rootPath, BisPartitionId partitionId)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
if (!IsValidPartitionId(partitionId)) return ResultFs.InvalidArgument.Log();
|
||||
if (rootPath == null) return ResultFs.NullptrArgument.Log();
|
||||
@ -91,7 +91,7 @@ namespace LibHac.FsSrv.Creators
|
||||
public Result Create(out ReferenceCountedDisposable<IFileSystem> fileSystem, U8Span rootPath,
|
||||
BisPartitionId partitionId, bool caseSensitive)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
if (!IsValidPartitionId(partitionId)) return ResultFs.InvalidArgument.Log();
|
||||
if (rootPath.IsNull()) return ResultFs.NullptrArgument.Log();
|
||||
@ -136,7 +136,7 @@ namespace LibHac.FsSrv.Creators
|
||||
|
||||
public Result CreateFatFileSystem(out IFileSystem fileSystem, BisPartitionId partitionId)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
return ResultFs.NotImplemented.Log();
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
|
||||
@ -41,7 +42,7 @@ namespace LibHac.FsSrv.Creators
|
||||
{
|
||||
if (!IsValidPartitionId(partitionId))
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -54,7 +55,7 @@ namespace LibHac.FsSrv.Creators
|
||||
{
|
||||
if (!IsValidPartitionId(partitionId))
|
||||
{
|
||||
path = default;
|
||||
UnsafeHelpers.SkipParamInit(out path);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using LibHac.Fs;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
|
||||
namespace LibHac.FsSrv.Creators
|
||||
@ -19,7 +20,7 @@ namespace LibHac.FsSrv.Creators
|
||||
{
|
||||
// Use the old xci code temporarily
|
||||
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
Result rc = GameCard.GetXci(out Xci xci, handle);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -37,7 +38,7 @@ namespace LibHac.FsSrv.Creators
|
||||
{
|
||||
// Use the old xci code temporarily
|
||||
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
Result rc = GameCard.GetXci(out Xci xci, handle);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
|
||||
namespace LibHac.FsSrv.Creators
|
||||
@ -14,7 +15,7 @@ namespace LibHac.FsSrv.Creators
|
||||
|
||||
public Result CreateReadOnly(GameCardHandle handle, out ReferenceCountedDisposable<IStorage> storage)
|
||||
{
|
||||
storage = default;
|
||||
UnsafeHelpers.SkipParamInit(out storage);
|
||||
|
||||
if (GameCard.IsGameCardHandleInvalid(handle))
|
||||
{
|
||||
@ -33,7 +34,7 @@ namespace LibHac.FsSrv.Creators
|
||||
|
||||
public Result CreateSecureReadOnly(GameCardHandle handle, out ReferenceCountedDisposable<IStorage> storage)
|
||||
{
|
||||
storage = default;
|
||||
UnsafeHelpers.SkipParamInit(out storage);
|
||||
|
||||
if (GameCard.IsGameCardHandleInvalid(handle))
|
||||
{
|
||||
@ -82,7 +83,8 @@ namespace LibHac.FsSrv.Creators
|
||||
Handle = handle;
|
||||
}
|
||||
|
||||
public ReadOnlyGameCardStorage(EmulatedGameCard gameCard, GameCardHandle handle, ReadOnlySpan<byte> deviceId, ReadOnlySpan<byte> imageHash)
|
||||
public ReadOnlyGameCardStorage(EmulatedGameCard gameCard, GameCardHandle handle,
|
||||
ReadOnlySpan<byte> deviceId, ReadOnlySpan<byte> imageHash)
|
||||
{
|
||||
GameCard = gameCard;
|
||||
Handle = handle;
|
||||
@ -116,7 +118,7 @@ namespace LibHac.FsSrv.Creators
|
||||
|
||||
protected override Result DoGetSize(out long size)
|
||||
{
|
||||
size = 0;
|
||||
UnsafeHelpers.SkipParamInit(out size);
|
||||
|
||||
Result rc = GameCard.GetCardInfo(out GameCardInfo info, Handle);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
|
||||
@ -29,7 +30,7 @@ namespace LibHac.FsSrv.Creators
|
||||
|
||||
public Result Create(out IFileSystem fileSystem, bool isCaseSensitive)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
if (!SdCard.IsSdCardInserted())
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using LibHac.Common.Keys;
|
||||
using LibHac.Common;
|
||||
using LibHac.Common.Keys;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
using LibHac.FsSystem;
|
||||
@ -17,7 +18,7 @@ namespace LibHac.FsSrv.Creators
|
||||
public Result Create(out ReferenceCountedDisposable<IFileSystem> encryptedFileSystem, ReferenceCountedDisposable<IFileSystem> baseFileSystem,
|
||||
EncryptedFsKeyId keyId, in EncryptionSeed encryptionSeed)
|
||||
{
|
||||
encryptedFileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out encryptedFileSystem);
|
||||
|
||||
if (keyId < EncryptedFsKeyId.Save || keyId > EncryptedFsKeyId.CustomStorage)
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using LibHac.Fs;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.FsSystem.Detail;
|
||||
@ -14,7 +15,7 @@ namespace LibHac.FsSrv.Creators
|
||||
Result rc = partitionFs.Initialize(pFsStorage);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -29,7 +30,7 @@ namespace LibHac.FsSrv.Creators
|
||||
Result rc = partitionFs.Initialize(pFsStorage);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -27,8 +27,7 @@ namespace LibHac.FsSrv.Creators
|
||||
ulong saveDataId, bool allowDirectorySaveData, bool useDeviceUniqueMac, SaveDataType type,
|
||||
ITimeStampGenerator timeStampGenerator)
|
||||
{
|
||||
fileSystem = default;
|
||||
extraDataAccessor = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem, out extraDataAccessor);
|
||||
|
||||
var saveDataPath = $"/{saveDataId:x16}".ToU8String();
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using LibHac.Common;
|
||||
using LibHac.Common.Keys;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
@ -23,8 +24,7 @@ namespace LibHac.FsSrv.Creators
|
||||
public Result Create(out ReferenceCountedDisposable<IStorage> storage, out NcaFsHeader fsHeader, Nca nca,
|
||||
int fsIndex, bool isCodeFs)
|
||||
{
|
||||
storage = default;
|
||||
fsHeader = default;
|
||||
UnsafeHelpers.SkipParamInit(out storage, out fsHeader);
|
||||
|
||||
Result rc = OpenStorage(out IStorage storageTemp, nca, fsIndex);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -67,7 +67,7 @@ namespace LibHac.FsSrv.Creators
|
||||
|
||||
private Result OpenStorage(out IStorage storage, Nca nca, int fsIndex)
|
||||
{
|
||||
storage = default;
|
||||
UnsafeHelpers.SkipParamInit(out storage);
|
||||
|
||||
if (!nca.SectionExists(fsIndex))
|
||||
return ResultFs.PartitionNotFound.Log();
|
||||
|
@ -15,7 +15,7 @@ namespace LibHac.FsSrv.Creators
|
||||
public Result Create(out ReferenceCountedDisposable<IFileSystem> subDirFileSystem,
|
||||
ref ReferenceCountedDisposable<IFileSystem> baseFileSystem, U8Span path, bool preserveUnc)
|
||||
{
|
||||
subDirFileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out subDirFileSystem);
|
||||
|
||||
// Verify the sub-path exists
|
||||
Result rc = baseFileSystem.Target.OpenDirectory(out IDirectory _, path, OpenDirectoryMode.Directory);
|
||||
|
@ -1,4 +1,5 @@
|
||||
using LibHac.Fs;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.FsSrv.Sf;
|
||||
|
||||
namespace LibHac.FsSrv
|
||||
@ -30,11 +31,10 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result GetGameCardHandle(out GameCardHandle handle)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out handle);
|
||||
|
||||
if (!GameCard.IsGameCardInserted())
|
||||
{
|
||||
handle = default;
|
||||
return ResultFs.GameCardNotInsertedOnGetHandle.Log();
|
||||
}
|
||||
|
||||
handle = GameCard.GetGameCardHandle();
|
||||
return Result.Success;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using LibHac.Common;
|
||||
using LibHac.Common.Keys;
|
||||
using LibHac.Fs;
|
||||
|
||||
@ -51,10 +52,10 @@ namespace LibHac.FsSrv
|
||||
Handle++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal Result GetXci(out Xci xci, GameCardHandle handle)
|
||||
{
|
||||
xci = default;
|
||||
UnsafeHelpers.SkipParamInit(out xci);
|
||||
|
||||
if (IsGameCardHandleInvalid(handle)) return ResultFs.InvalidGameCardHandleOnRead.Log();
|
||||
if (!IsGameCardInserted()) return ResultFs.GameCardNotInserted.Log();
|
||||
@ -93,7 +94,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
internal Result GetCardInfo(out GameCardInfo cardInfo, GameCardHandle handle)
|
||||
{
|
||||
cardInfo = default;
|
||||
UnsafeHelpers.SkipParamInit(out cardInfo);
|
||||
|
||||
if (IsGameCardHandleInvalid(handle)) return ResultFs.InvalidGameCardHandleOnGetCardInfo.Log();
|
||||
if (!IsGameCardInserted()) return ResultFs.GameCardNotInserted.Log();
|
||||
|
@ -29,7 +29,7 @@ namespace LibHac.FsSrv
|
||||
public Result OpenCustomStorageFileSystem(out ReferenceCountedDisposable<IFileSystem> fileSystem,
|
||||
CustomStorageId storageId)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
ReferenceCountedDisposable<IFileSystem> tempFs = null;
|
||||
ReferenceCountedDisposable<IFileSystem> encryptedFs = null;
|
||||
@ -91,7 +91,7 @@ namespace LibHac.FsSrv
|
||||
public Result OpenHostFileSystem(out ReferenceCountedDisposable<IFileSystem> fileSystem, U8Span path,
|
||||
bool openCaseSensitive)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
Result rc;
|
||||
|
||||
if (!path.IsEmpty())
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using LibHac.Common;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.FsSrv.Impl;
|
||||
using LibHac.FsSrv.Sf;
|
||||
@ -85,7 +84,7 @@ namespace LibHac.FsSrv
|
||||
{
|
||||
if (NcaFsService is null)
|
||||
{
|
||||
ncaFsService = null;
|
||||
UnsafeHelpers.SkipParamInit(out ncaFsService);
|
||||
return ResultFs.PreconditionViolation.Log();
|
||||
}
|
||||
|
||||
@ -97,7 +96,7 @@ namespace LibHac.FsSrv
|
||||
{
|
||||
if (SaveFsService is null)
|
||||
{
|
||||
saveFsService = null;
|
||||
UnsafeHelpers.SkipParamInit(out saveFsService);
|
||||
return ResultFs.PreconditionViolation.Log();
|
||||
}
|
||||
|
||||
@ -146,7 +145,7 @@ namespace LibHac.FsSrv
|
||||
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -159,7 +158,7 @@ namespace LibHac.FsSrv
|
||||
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -169,12 +168,12 @@ namespace LibHac.FsSrv
|
||||
public Result OpenCodeFileSystem(out ReferenceCountedDisposable<IFileSystemSf> fileSystem,
|
||||
out CodeVerificationData verificationData, in FspPath path, ProgramId programId)
|
||||
{
|
||||
Unsafe.SkipInit(out verificationData);
|
||||
UnsafeHelpers.SkipParamInit(out verificationData);
|
||||
|
||||
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -194,7 +193,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result GetFreeSpaceSizeForSaveData(out long freeSpaceSize, SaveDataSpaceId spaceId)
|
||||
{
|
||||
Unsafe.SkipInit(out freeSpaceSize);
|
||||
UnsafeHelpers.SkipParamInit(out freeSpaceSize);
|
||||
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -207,7 +206,7 @@ namespace LibHac.FsSrv
|
||||
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -220,7 +219,7 @@ namespace LibHac.FsSrv
|
||||
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -232,7 +231,7 @@ namespace LibHac.FsSrv
|
||||
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
storage = default;
|
||||
UnsafeHelpers.SkipParamInit(out storage);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -245,7 +244,7 @@ namespace LibHac.FsSrv
|
||||
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
storage = default;
|
||||
UnsafeHelpers.SkipParamInit(out storage);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -258,7 +257,7 @@ namespace LibHac.FsSrv
|
||||
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
storage = default;
|
||||
UnsafeHelpers.SkipParamInit(out storage);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -267,7 +266,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result OpenPatchDataStorageByCurrentProcess(out ReferenceCountedDisposable<IStorageSf> storage)
|
||||
{
|
||||
storage = default;
|
||||
UnsafeHelpers.SkipParamInit(out storage);
|
||||
return ResultFs.TargetNotFound.Log();
|
||||
}
|
||||
|
||||
@ -277,7 +276,7 @@ namespace LibHac.FsSrv
|
||||
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -290,7 +289,7 @@ namespace LibHac.FsSrv
|
||||
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
storage = default;
|
||||
UnsafeHelpers.SkipParamInit(out storage);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -381,7 +380,7 @@ namespace LibHac.FsSrv
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -394,7 +393,7 @@ namespace LibHac.FsSrv
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -407,7 +406,7 @@ namespace LibHac.FsSrv
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -516,7 +515,7 @@ namespace LibHac.FsSrv
|
||||
public Result OpenHostFileSystemWithOption(out ReferenceCountedDisposable<IFileSystemSf> fileSystem,
|
||||
in FspPath path, MountHostOption option)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
Result rc = GetProgramInfo(out ProgramInfo programInfo);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -599,7 +598,7 @@ namespace LibHac.FsSrv
|
||||
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
eventNotifier = null;
|
||||
UnsafeHelpers.SkipParamInit(out eventNotifier);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -619,7 +618,7 @@ namespace LibHac.FsSrv
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
infoReader = default;
|
||||
UnsafeHelpers.SkipParamInit(out infoReader);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -632,7 +631,7 @@ namespace LibHac.FsSrv
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
infoReader = default;
|
||||
UnsafeHelpers.SkipParamInit(out infoReader);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -645,7 +644,7 @@ namespace LibHac.FsSrv
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
infoReader = default;
|
||||
UnsafeHelpers.SkipParamInit(out infoReader);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -655,7 +654,7 @@ namespace LibHac.FsSrv
|
||||
public Result FindSaveDataWithFilter(out long count, OutBuffer saveDataInfoBuffer, SaveDataSpaceId spaceId,
|
||||
in SaveDataFilter filter)
|
||||
{
|
||||
Unsafe.SkipInit(out count);
|
||||
UnsafeHelpers.SkipParamInit(out count);
|
||||
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -669,7 +668,7 @@ namespace LibHac.FsSrv
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -678,7 +677,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result QuerySaveDataInternalStorageTotalSize(out long size, SaveDataSpaceId spaceId, ulong saveDataId)
|
||||
{
|
||||
Unsafe.SkipInit(out size);
|
||||
UnsafeHelpers.SkipParamInit(out size);
|
||||
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -688,7 +687,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result GetSaveDataCommitId(out long commitId, SaveDataSpaceId spaceId, ulong saveDataId)
|
||||
{
|
||||
Unsafe.SkipInit(out commitId);
|
||||
UnsafeHelpers.SkipParamInit(out commitId);
|
||||
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -702,7 +701,7 @@ namespace LibHac.FsSrv
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
infoReader = default;
|
||||
UnsafeHelpers.SkipParamInit(out infoReader);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -715,7 +714,7 @@ namespace LibHac.FsSrv
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
file = default;
|
||||
UnsafeHelpers.SkipParamInit(out file);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -732,8 +731,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result GetCacheStorageSize(out long dataSize, out long journalSize, ushort index)
|
||||
{
|
||||
Unsafe.SkipInit(out dataSize);
|
||||
Unsafe.SkipInit(out journalSize);
|
||||
UnsafeHelpers.SkipParamInit(out dataSize, out journalSize);
|
||||
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -743,7 +741,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result OpenSaveDataTransferManager(out ReferenceCountedDisposable<ISaveDataTransferManager> manager)
|
||||
{
|
||||
manager = default;
|
||||
UnsafeHelpers.SkipParamInit(out manager);
|
||||
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -754,7 +752,7 @@ namespace LibHac.FsSrv
|
||||
public Result OpenSaveDataTransferManagerVersion2(
|
||||
out ReferenceCountedDisposable<ISaveDataTransferManagerWithDivision> manager)
|
||||
{
|
||||
manager = default;
|
||||
UnsafeHelpers.SkipParamInit(out manager);
|
||||
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -765,7 +763,7 @@ namespace LibHac.FsSrv
|
||||
public Result OpenSaveDataTransferManagerForSaveDataRepair(
|
||||
out ReferenceCountedDisposable<ISaveDataTransferManagerForSaveDataRepair> manager)
|
||||
{
|
||||
manager = default;
|
||||
UnsafeHelpers.SkipParamInit(out manager);
|
||||
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -776,7 +774,7 @@ namespace LibHac.FsSrv
|
||||
public Result OpenSaveDataTransferManagerForRepair(
|
||||
out ReferenceCountedDisposable<ISaveDataTransferManagerForRepair> manager)
|
||||
{
|
||||
manager = default;
|
||||
UnsafeHelpers.SkipParamInit(out manager);
|
||||
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -787,7 +785,7 @@ namespace LibHac.FsSrv
|
||||
public Result OpenSaveDataTransferProhibiter(
|
||||
out ReferenceCountedDisposable<ISaveDataTransferProhibiter> prohibiter, Ncm.ApplicationId applicationId)
|
||||
{
|
||||
prohibiter = default;
|
||||
UnsafeHelpers.SkipParamInit(out prohibiter);
|
||||
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -798,7 +796,7 @@ namespace LibHac.FsSrv
|
||||
public Result ListAccessibleSaveDataOwnerId(out int readCount, OutBuffer idBuffer, ProgramId programId,
|
||||
int startIndex, int bufferIdCount)
|
||||
{
|
||||
Unsafe.SkipInit(out readCount);
|
||||
UnsafeHelpers.SkipParamInit(out readCount);
|
||||
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -814,7 +812,7 @@ namespace LibHac.FsSrv
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
saveMover = default;
|
||||
UnsafeHelpers.SkipParamInit(out saveMover);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -849,7 +847,7 @@ namespace LibHac.FsSrv
|
||||
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
fileSystem = null;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -859,7 +857,7 @@ namespace LibHac.FsSrv
|
||||
public Result OpenCloudBackupWorkStorageFileSystem(out ReferenceCountedDisposable<IFileSystemSf> fileSystem,
|
||||
CloudBackupWorkStorageId storageId)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
var storageFlag = StorageType.NonGameCard;
|
||||
using var scopedLayoutType = new ScopedStorageLayoutTypeSetter(storageFlag);
|
||||
|
||||
@ -893,7 +891,7 @@ namespace LibHac.FsSrv
|
||||
public Result OpenCustomStorageFileSystem(out ReferenceCountedDisposable<IFileSystemSf> fileSystem,
|
||||
CustomStorageId storageId)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
var storageFlag = StorageType.NonGameCard;
|
||||
using var scopedLayoutType = new ScopedStorageLayoutTypeSetter(storageFlag);
|
||||
|
||||
@ -935,7 +933,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result IsArchivedProgram(out bool isArchived, ulong processId)
|
||||
{
|
||||
Unsafe.SkipInit(out isArchived);
|
||||
UnsafeHelpers.SkipParamInit(out isArchived);
|
||||
|
||||
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -945,7 +943,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result QuerySaveDataTotalSize(out long totalSize, long dataSize, long journalSize)
|
||||
{
|
||||
Unsafe.SkipInit(out totalSize);
|
||||
UnsafeHelpers.SkipParamInit(out totalSize);
|
||||
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -960,7 +958,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result GetRightsId(out RightsId rightsId, ProgramId programId, StorageId storageId)
|
||||
{
|
||||
Unsafe.SkipInit(out rightsId);
|
||||
UnsafeHelpers.SkipParamInit(out rightsId);
|
||||
|
||||
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -975,8 +973,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result GetRightsIdAndKeyGenerationByPath(out RightsId rightsId, out byte keyGeneration, in FspPath path)
|
||||
{
|
||||
Unsafe.SkipInit(out rightsId);
|
||||
Unsafe.SkipInit(out keyGeneration);
|
||||
UnsafeHelpers.SkipParamInit(out rightsId, out keyGeneration);
|
||||
|
||||
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -1146,7 +1143,7 @@ namespace LibHac.FsSrv
|
||||
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -1181,7 +1178,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result IsSdCardAccessible(out bool isAccessible)
|
||||
{
|
||||
Unsafe.SkipInit(out isAccessible);
|
||||
UnsafeHelpers.SkipParamInit(out isAccessible);
|
||||
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -1218,7 +1215,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result OpenMultiCommitManager(out ReferenceCountedDisposable<IMultiCommitManager> commitManager)
|
||||
{
|
||||
commitManager = null;
|
||||
UnsafeHelpers.SkipParamInit(out commitManager);
|
||||
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Sf;
|
||||
using IDirectory = LibHac.Fs.Fsa.IDirectory;
|
||||
@ -23,7 +24,7 @@ namespace LibHac.FsSrv.Impl
|
||||
public Result Read(out long entriesRead, OutBuffer entryBuffer)
|
||||
{
|
||||
const int maxTryCount = 2;
|
||||
entriesRead = default;
|
||||
UnsafeHelpers.SkipParamInit(out entriesRead);
|
||||
|
||||
Span<DirectoryEntry> entries = MemoryMarshal.Cast<byte, DirectoryEntry>(entryBuffer.Buffer);
|
||||
|
||||
@ -47,7 +48,7 @@ namespace LibHac.FsSrv.Impl
|
||||
|
||||
public Result GetEntryCount(out long entryCount)
|
||||
{
|
||||
entryCount = default;
|
||||
UnsafeHelpers.SkipParamInit(out entryCount);
|
||||
|
||||
Result rc = BaseDirectory.GetEntryCount(out long tmpEntryCount);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
@ -23,7 +23,7 @@ namespace LibHac.FsSrv.Impl
|
||||
public Result Read(out long bytesRead, long offset, Span<byte> destination, ReadOption option)
|
||||
{
|
||||
const int maxTryCount = 2;
|
||||
bytesRead = default;
|
||||
UnsafeHelpers.SkipParamInit(out bytesRead);
|
||||
|
||||
if (offset < 0)
|
||||
return ResultFs.InvalidOffset.Log();
|
||||
@ -78,7 +78,7 @@ namespace LibHac.FsSrv.Impl
|
||||
public Result GetSize(out long size)
|
||||
{
|
||||
const int maxTryCount = 2;
|
||||
size = default;
|
||||
UnsafeHelpers.SkipParamInit(out size);
|
||||
|
||||
Result rc = Result.Success;
|
||||
long tmpSize = 0;
|
||||
@ -100,7 +100,8 @@ namespace LibHac.FsSrv.Impl
|
||||
|
||||
public Result OperateRange(out QueryRangeInfo rangeInfo, int operationId, long offset, long size)
|
||||
{
|
||||
rangeInfo = new QueryRangeInfo();
|
||||
UnsafeHelpers.SkipParamInit(out rangeInfo);
|
||||
rangeInfo.Clear();
|
||||
|
||||
if (operationId == (int)OperationId.InvalidateCache)
|
||||
{
|
||||
|
@ -163,7 +163,7 @@ namespace LibHac.FsSrv.Impl
|
||||
|
||||
public Result GetEntryType(out uint entryType, in Path path)
|
||||
{
|
||||
entryType = default;
|
||||
UnsafeHelpers.SkipParamInit(out entryType);
|
||||
|
||||
var normalizer = new PathNormalizer(new U8Span(path.Str), GetPathNormalizerOption());
|
||||
if (normalizer.Result.IsFailure()) return normalizer.Result;
|
||||
@ -176,7 +176,7 @@ namespace LibHac.FsSrv.Impl
|
||||
public Result OpenFile(out ReferenceCountedDisposable<IFileSf> file, in Path path, uint mode)
|
||||
{
|
||||
const int maxTryCount = 2;
|
||||
file = default;
|
||||
UnsafeHelpers.SkipParamInit(out file);
|
||||
|
||||
var normalizer = new PathNormalizer(new U8Span(path.Str), GetPathNormalizerOption());
|
||||
if (normalizer.Result.IsFailure()) return normalizer.Result;
|
||||
@ -205,7 +205,7 @@ namespace LibHac.FsSrv.Impl
|
||||
public Result OpenDirectory(out ReferenceCountedDisposable<IDirectorySf> directory, in Path path, uint mode)
|
||||
{
|
||||
const int maxTryCount = 2;
|
||||
directory = default;
|
||||
UnsafeHelpers.SkipParamInit(out directory);
|
||||
|
||||
var normalizer = new PathNormalizer(new U8Span(path.Str), GetPathNormalizerOption());
|
||||
if (normalizer.Result.IsFailure()) return normalizer.Result;
|
||||
@ -238,7 +238,7 @@ namespace LibHac.FsSrv.Impl
|
||||
|
||||
public Result GetFreeSpaceSize(out long freeSpace, in Path path)
|
||||
{
|
||||
freeSpace = default;
|
||||
UnsafeHelpers.SkipParamInit(out freeSpace);
|
||||
|
||||
var normalizer = new PathNormalizer(new U8Span(path.Str), GetPathNormalizerOption());
|
||||
if (normalizer.Result.IsFailure()) return normalizer.Result;
|
||||
@ -248,7 +248,7 @@ namespace LibHac.FsSrv.Impl
|
||||
|
||||
public Result GetTotalSpaceSize(out long totalSpace, in Path path)
|
||||
{
|
||||
totalSpace = default;
|
||||
UnsafeHelpers.SkipParamInit(out totalSpace);
|
||||
|
||||
var normalizer = new PathNormalizer(new U8Span(path.Str), GetPathNormalizerOption());
|
||||
if (normalizer.Result.IsFailure()) return normalizer.Result;
|
||||
@ -266,7 +266,7 @@ namespace LibHac.FsSrv.Impl
|
||||
|
||||
public Result GetFileTimeStampRaw(out FileTimeStampRaw timeStamp, in Path path)
|
||||
{
|
||||
timeStamp = default;
|
||||
UnsafeHelpers.SkipParamInit(out timeStamp);
|
||||
|
||||
var normalizer = new PathNormalizer(new U8Span(path.Str), GetPathNormalizerOption());
|
||||
if (normalizer.Result.IsFailure()) return normalizer.Result;
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.FsSrv.Sf;
|
||||
using LibHac.Ncm;
|
||||
@ -44,7 +44,7 @@ namespace LibHac.FsSrv.Impl
|
||||
|
||||
public Result IsArchivedProgram(out bool isArchived, ulong processId)
|
||||
{
|
||||
Unsafe.SkipInit(out isArchived);
|
||||
UnsafeHelpers.SkipParamInit(out isArchived);
|
||||
|
||||
return ResultFs.PortAcceptableCountLimited.Log();
|
||||
}
|
||||
@ -52,8 +52,7 @@ namespace LibHac.FsSrv.Impl
|
||||
public Result OpenCodeFileSystem(out ReferenceCountedDisposable<IFileSystem> fileSystem,
|
||||
out CodeVerificationData verificationData, in FspPath path, ProgramId programId)
|
||||
{
|
||||
fileSystem = default;
|
||||
Unsafe.SkipInit(out verificationData);
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem, out verificationData);
|
||||
|
||||
return ResultFs.PortAcceptableCountLimited.Log();
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using LibHac.Common;
|
||||
using LibHac.Diag;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Lr;
|
||||
@ -27,7 +28,7 @@ namespace LibHac.FsSrv.Impl
|
||||
|
||||
private Result GetLocationResolver(out LocationResolver resolver, StorageId storageId)
|
||||
{
|
||||
resolver = default;
|
||||
UnsafeHelpers.SkipParamInit(out resolver);
|
||||
|
||||
if (!IsValidStorageId(storageId))
|
||||
return ResultLr.LocationResolverNotFound.Log();
|
||||
@ -52,7 +53,7 @@ namespace LibHac.FsSrv.Impl
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
lr?.Dispose();
|
||||
resolver = default;
|
||||
UnsafeHelpers.SkipParamInit(out resolver);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -69,7 +70,7 @@ namespace LibHac.FsSrv.Impl
|
||||
Result rc = Hos.Lr.OpenAddOnContentLocationResolver(out AddOnContentLocationResolver lr);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
resolver = default;
|
||||
UnsafeHelpers.SkipParamInit(out resolver);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Ncm;
|
||||
|
||||
@ -119,7 +120,7 @@ namespace LibHac.FsSrv.Impl
|
||||
}
|
||||
}
|
||||
|
||||
programInfo = default;
|
||||
UnsafeHelpers.SkipParamInit(out programInfo);
|
||||
return ResultFs.TargetProgramNotFound.Log();
|
||||
}
|
||||
}
|
||||
@ -145,7 +146,7 @@ namespace LibHac.FsSrv.Impl
|
||||
}
|
||||
}
|
||||
|
||||
programInfo = default;
|
||||
UnsafeHelpers.SkipParamInit(out programInfo);
|
||||
return ResultFs.TargetProgramNotFound.Log();
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,8 @@ namespace LibHac.FsSrv.Impl
|
||||
|
||||
public Result OperateRange(out QueryRangeInfo rangeInfo, int operationId, long offset, long size)
|
||||
{
|
||||
rangeInfo = new QueryRangeInfo();
|
||||
UnsafeHelpers.SkipParamInit(out rangeInfo);
|
||||
rangeInfo.Clear();
|
||||
|
||||
if (operationId == (int)OperationId.InvalidateCache)
|
||||
{
|
||||
|
@ -124,7 +124,7 @@ namespace LibHac.FsSrv.Impl
|
||||
public static Result CreateSubDirectoryFileSystem(out ReferenceCountedDisposable<IFileSystem> subDirFileSystem,
|
||||
ref ReferenceCountedDisposable<IFileSystem> baseFileSystem, U8Span subPath, bool preserveUnc = false)
|
||||
{
|
||||
subDirFileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out subDirFileSystem);
|
||||
|
||||
// Check if the directory exists
|
||||
Result rc = baseFileSystem.Target.OpenDirectory(out IDirectory dir, subPath, OpenDirectoryMode.Directory);
|
||||
@ -146,7 +146,7 @@ namespace LibHac.FsSrv.Impl
|
||||
public static Result WrapSubDirectory(out ReferenceCountedDisposable<IFileSystem> fileSystem,
|
||||
ref ReferenceCountedDisposable<IFileSystem> baseFileSystem, U8Span path, bool createIfMissing)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
// The path must already exist if we're not automatically creating it
|
||||
if (!createIfMissing)
|
||||
|
@ -60,7 +60,7 @@ namespace LibHac.FsSrv
|
||||
public Result OpenFileSystemWithPatch(out ReferenceCountedDisposable<IFileSystemSf> fileSystem,
|
||||
ProgramId programId, FileSystemProxyType fsType)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
const StorageType storageFlag = StorageType.All;
|
||||
using var scopedLayoutType = new ScopedStorageLayoutTypeSetter(storageFlag);
|
||||
@ -202,7 +202,7 @@ namespace LibHac.FsSrv
|
||||
public Result OpenFileSystemWithId(out ReferenceCountedDisposable<IFileSystemSf> fileSystem, in FspPath path,
|
||||
ulong id, FileSystemProxyType fsType)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
Result rc = GetProgramInfo(out ProgramInfo programInfo);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -287,7 +287,7 @@ namespace LibHac.FsSrv
|
||||
public Result OpenDataFileSystemWithProgramIndex(out ReferenceCountedDisposable<IFileSystemSf> fileSystem,
|
||||
byte programIndex)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
Result rc = GetProgramInfo(out ProgramInfo programInfo);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -335,7 +335,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result GetRightsId(out RightsId rightsId, ProgramId programId, StorageId storageId)
|
||||
{
|
||||
Unsafe.SkipInit(out rightsId);
|
||||
UnsafeHelpers.SkipParamInit(out rightsId);
|
||||
|
||||
using var scopedLayoutType = new ScopedStorageLayoutTypeSetter(StorageType.All);
|
||||
|
||||
@ -360,8 +360,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result GetRightsIdAndKeyGenerationByPath(out RightsId rightsId, out byte keyGeneration, in FspPath path)
|
||||
{
|
||||
Unsafe.SkipInit(out rightsId);
|
||||
Unsafe.SkipInit(out keyGeneration);
|
||||
UnsafeHelpers.SkipParamInit(out rightsId, out keyGeneration);
|
||||
|
||||
using var scopedLayoutType = new ScopedStorageLayoutTypeSetter(StorageType.All);
|
||||
|
||||
@ -386,8 +385,7 @@ namespace LibHac.FsSrv
|
||||
private Result OpenDataFileSystemCore(out ReferenceCountedDisposable<IFileSystem> fileSystem, out bool isHostFs,
|
||||
ulong programId, StorageId storageId)
|
||||
{
|
||||
fileSystem = default;
|
||||
Unsafe.SkipInit(out isHostFs);
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem, out isHostFs);
|
||||
|
||||
if (Unsafe.IsNullRef(ref isHostFs))
|
||||
return ResultFs.NullptrArgument.Log();
|
||||
@ -424,7 +422,7 @@ namespace LibHac.FsSrv
|
||||
public Result OpenContentStorageFileSystem(out ReferenceCountedDisposable<IFileSystemSf> fileSystem,
|
||||
ContentStorageId contentStorageId)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
StorageType storageFlag = contentStorageId == ContentStorageId.System ? StorageType.Bis : StorageType.All;
|
||||
using var scopedLayoutType = new ScopedStorageLayoutTypeSetter(storageFlag);
|
||||
@ -511,7 +509,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result OpenRegisteredUpdatePartition(out ReferenceCountedDisposable<IFileSystemSf> fileSystem)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
var storageFlag = StorageType.All;
|
||||
using var scopedLayoutType = new ScopedStorageLayoutTypeSetter(storageFlag);
|
||||
|
@ -75,9 +75,8 @@ namespace LibHac.FsSrv
|
||||
out CodeVerificationData verificationData, U8Span path, FileSystemProxyType type,
|
||||
bool canMountSystemDataPrivate, ulong id)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem, out verificationData);
|
||||
|
||||
Unsafe.SkipInit(out verificationData);
|
||||
if (!Unsafe.IsNullRef(ref verificationData))
|
||||
verificationData.IsValid = false;
|
||||
|
||||
@ -201,7 +200,7 @@ namespace LibHac.FsSrv
|
||||
public Result OpenFileSystemWithPatch(out ReferenceCountedDisposable<IFileSystem> fileSystem,
|
||||
U8Span originalNcaPath, U8Span currentNcaPath, FileSystemProxyType fsType, ulong id)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
ReferenceCountedDisposable<IStorage> romFsStorage = null;
|
||||
try
|
||||
@ -223,12 +222,11 @@ namespace LibHac.FsSrv
|
||||
{
|
||||
const int storagePathMaxLen = 0x40;
|
||||
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
ReferenceCountedDisposable<IFileSystem> baseFileSystem = null;
|
||||
ReferenceCountedDisposable<IFileSystem> subDirFileSystem = null;
|
||||
ReferenceCountedDisposable<IFileSystem> encryptedFileSystem = null;
|
||||
|
||||
try
|
||||
{
|
||||
Result rc;
|
||||
@ -341,7 +339,7 @@ namespace LibHac.FsSrv
|
||||
private Result ParseMountName(ref U8Span path,
|
||||
out ReferenceCountedDisposable<IFileSystem> fileSystem, out bool shouldContinue, out MountInfo info)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
info = new MountInfo();
|
||||
shouldContinue = true;
|
||||
@ -505,7 +503,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
private Result CheckDirOrNcaOrNsp(ref U8Span path, out bool isDirectory)
|
||||
{
|
||||
isDirectory = default;
|
||||
UnsafeHelpers.SkipParamInit(out isDirectory);
|
||||
|
||||
ReadOnlySpan<byte> mountSeparator = new[] { (byte)':', (byte)'/' };
|
||||
|
||||
@ -546,7 +544,7 @@ namespace LibHac.FsSrv
|
||||
out ReferenceCountedDisposable<IFileSystem> contentFileSystem,
|
||||
ref ReferenceCountedDisposable<IFileSystem> baseFileSystem, FileSystemProxyType fsType, bool preserveUnc)
|
||||
{
|
||||
contentFileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out contentFileSystem);
|
||||
|
||||
ReferenceCountedDisposable<IFileSystem> subDirFs = null;
|
||||
try
|
||||
@ -566,7 +564,7 @@ namespace LibHac.FsSrv
|
||||
out ReferenceCountedDisposable<IFileSystem> contentFileSystem,
|
||||
ref ReferenceCountedDisposable<IFileSystem> baseFileSystem, U8Span path)
|
||||
{
|
||||
contentFileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out contentFileSystem);
|
||||
Unsafe.SkipInit(out FsPath fullPath);
|
||||
|
||||
var sb = new U8StringBuilder(fullPath.Str);
|
||||
@ -594,7 +592,7 @@ namespace LibHac.FsSrv
|
||||
private Result ParseNsp(ref U8Span path, out ReferenceCountedDisposable<IFileSystem> fileSystem,
|
||||
ReferenceCountedDisposable<IFileSystem> baseFileSystem)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
ReadOnlySpan<byte> nspExtension = new[] { (byte)'.', (byte)'n', (byte)'s', (byte)'p' };
|
||||
|
||||
@ -653,7 +651,7 @@ namespace LibHac.FsSrv
|
||||
private Result ParseNca(ref U8Span path, out Nca nca, ReferenceCountedDisposable<IFileSystem> baseFileSystem,
|
||||
ulong ncaId)
|
||||
{
|
||||
nca = default;
|
||||
UnsafeHelpers.SkipParamInit(out nca);
|
||||
|
||||
// Todo: Create ref-counted storage
|
||||
var ncaFileStorage = new FileStorageBasedFileSystem();
|
||||
@ -681,7 +679,7 @@ namespace LibHac.FsSrv
|
||||
private Result ParseContentTypeForDirectory(out ReferenceCountedDisposable<IFileSystem> fileSystem,
|
||||
ref ReferenceCountedDisposable<IFileSystem> baseFileSystem, FileSystemProxyType fsType)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
ReadOnlySpan<byte> dirName;
|
||||
|
||||
// Get the name of the subdirectory for the filesystem type
|
||||
@ -751,8 +749,7 @@ namespace LibHac.FsSrv
|
||||
private Result OpenStorageByContentType(out ReferenceCountedDisposable<IStorage> ncaStorage, Nca nca,
|
||||
out NcaFormatType fsType, FileSystemProxyType fsProxyType, bool isGameCard, bool canMountSystemDataPrivate)
|
||||
{
|
||||
ncaStorage = default;
|
||||
fsType = default;
|
||||
UnsafeHelpers.SkipParamInit(out ncaStorage, out fsType);
|
||||
|
||||
NcaContentType contentType = nca.Header.ContentType;
|
||||
|
||||
@ -821,7 +818,7 @@ namespace LibHac.FsSrv
|
||||
public Result ResolveRomReferenceProgramId(out ProgramId targetProgramId, ProgramId programId,
|
||||
byte programIndex)
|
||||
{
|
||||
Unsafe.SkipInit(out targetProgramId);
|
||||
UnsafeHelpers.SkipParamInit(out targetProgramId);
|
||||
|
||||
ProgramId mainProgramId = _config.ProgramRegistryService.GetProgramIdByIndex(programId, programIndex);
|
||||
if (mainProgramId == ProgramId.InvalidId)
|
||||
@ -914,7 +911,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result OpenHostFileSystem(out ReferenceCountedDisposable<IFileSystem> fileSystem, U8Span path, bool openCaseSensitive)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
Result rc;
|
||||
|
||||
if (!path.IsEmpty())
|
||||
@ -987,7 +984,7 @@ namespace LibHac.FsSrv
|
||||
index = 2;
|
||||
return Result.Success;
|
||||
default:
|
||||
index = default;
|
||||
UnsafeHelpers.SkipParamInit(out index);
|
||||
return ResultFs.InvalidArgument.Log();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.FsSrv.Impl;
|
||||
using LibHac.Sf;
|
||||
@ -73,8 +73,7 @@ namespace LibHac.FsSrv
|
||||
/// in the program registry. Something's wrong with Loader if this happens.</returns>
|
||||
public Result GetProgramIndex(out int programIndex, out int programCount)
|
||||
{
|
||||
Unsafe.SkipInit(out programIndex);
|
||||
Unsafe.SkipInit(out programCount);
|
||||
UnsafeHelpers.SkipParamInit(out programIndex, out programCount);
|
||||
|
||||
// No permissions are needed to call this method
|
||||
Result rc = GetProgramInfo(out ProgramInfo programInfo, ProcessId);
|
||||
|
@ -321,7 +321,7 @@ namespace LibHac.FsSrv
|
||||
private static Result GetAccessibilityForSaveData(out Accessibility accessibility, ProgramInfo programInfo,
|
||||
ExtraDataGetter extraDataGetter)
|
||||
{
|
||||
Unsafe.SkipInit(out accessibility);
|
||||
UnsafeHelpers.SkipParamInit(out accessibility);
|
||||
|
||||
Result rc = extraDataGetter(out SaveDataExtraData extraData);
|
||||
if (rc.IsFailure())
|
||||
@ -797,7 +797,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result GetSaveDataInfo(out SaveDataInfo info, SaveDataSpaceId spaceId, in SaveDataAttribute attribute)
|
||||
{
|
||||
Unsafe.SkipInit(out info);
|
||||
UnsafeHelpers.SkipParamInit(out info);
|
||||
|
||||
using var scopedLayoutType = new ScopedStorageLayoutTypeSetter(StorageType.NonGameCard);
|
||||
|
||||
@ -816,7 +816,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result QuerySaveDataTotalSize(out long totalSize, long dataSize, long journalSize)
|
||||
{
|
||||
Unsafe.SkipInit(out totalSize);
|
||||
UnsafeHelpers.SkipParamInit(out totalSize);
|
||||
|
||||
if (dataSize < 0 || journalSize < 0)
|
||||
return ResultFs.InvalidSize.Log();
|
||||
@ -827,7 +827,7 @@ namespace LibHac.FsSrv
|
||||
public Result CreateSaveDataFileSystem(in SaveDataAttribute attribute, in SaveDataCreationInfo creationInfo,
|
||||
in SaveDataMetaInfo metaInfo)
|
||||
{
|
||||
Optional<HashSalt> hashSalt = default;
|
||||
var hashSalt = new Optional<HashSalt>();
|
||||
|
||||
return CreateSaveDataFileSystemWithHashSaltImpl(in attribute, in creationInfo, in metaInfo, in hashSalt);
|
||||
}
|
||||
@ -930,8 +930,7 @@ namespace LibHac.FsSrv
|
||||
out ulong saveDataId, SaveDataSpaceId spaceId, in SaveDataAttribute attribute, bool openReadOnly,
|
||||
bool cacheExtraData)
|
||||
{
|
||||
Unsafe.SkipInit(out saveDataId);
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem, out saveDataId);
|
||||
|
||||
SaveDataIndexerAccessor accessor = null;
|
||||
|
||||
@ -1028,7 +1027,7 @@ namespace LibHac.FsSrv
|
||||
private Result OpenUserSaveDataFileSystemCore(out ReferenceCountedDisposable<IFileSystemSf> fileSystem,
|
||||
SaveDataSpaceId spaceId, in SaveDataAttribute attribute, ProgramInfo programInfo, bool openReadOnly)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
IUniqueLock mountCountSemaphore = null;
|
||||
ReferenceCountedDisposable<IFileSystem> tempFileSystem = null;
|
||||
ReferenceCountedDisposable<SaveDataFileSystemService> saveService = null;
|
||||
@ -1089,7 +1088,7 @@ namespace LibHac.FsSrv
|
||||
private Result OpenUserSaveDataFileSystem(out ReferenceCountedDisposable<IFileSystemSf> fileSystem,
|
||||
SaveDataSpaceId spaceId, in SaveDataAttribute attribute, bool openReadOnly)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
Result rc = GetProgramInfo(out ProgramInfo programInfo);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -1132,7 +1131,7 @@ namespace LibHac.FsSrv
|
||||
public Result OpenSaveDataFileSystemBySystemSaveDataId(out ReferenceCountedDisposable<IFileSystemSf> fileSystem,
|
||||
SaveDataSpaceId spaceId, in SaveDataAttribute attribute)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
if (!IsStaticSaveDataIdValueRange(attribute.StaticSaveDataId))
|
||||
return ResultFs.InvalidArgument.Log();
|
||||
@ -1262,7 +1261,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result OpenSaveDataInfoReader(out ReferenceCountedDisposable<ISaveDataInfoReader> infoReader)
|
||||
{
|
||||
infoReader = default;
|
||||
UnsafeHelpers.SkipParamInit(out infoReader);
|
||||
|
||||
using var scopedLayoutType = new ScopedStorageLayoutTypeSetter(StorageType.Bis);
|
||||
|
||||
@ -1299,7 +1298,7 @@ namespace LibHac.FsSrv
|
||||
public Result OpenSaveDataInfoReaderBySaveDataSpaceId(
|
||||
out ReferenceCountedDisposable<ISaveDataInfoReader> infoReader, SaveDataSpaceId spaceId)
|
||||
{
|
||||
infoReader = default;
|
||||
UnsafeHelpers.SkipParamInit(out infoReader);
|
||||
|
||||
using var scopedLayoutType = new ScopedStorageLayoutTypeSetter(StorageType.NonGameCard);
|
||||
|
||||
@ -1338,7 +1337,7 @@ namespace LibHac.FsSrv
|
||||
public Result OpenSaveDataInfoReaderWithFilter(out ReferenceCountedDisposable<ISaveDataInfoReader> infoReader,
|
||||
SaveDataSpaceId spaceId, in SaveDataFilter filter)
|
||||
{
|
||||
infoReader = default;
|
||||
UnsafeHelpers.SkipParamInit(out infoReader);
|
||||
|
||||
using var scopedLayoutType = new ScopedStorageLayoutTypeSetter(StorageType.NonGameCard);
|
||||
|
||||
@ -1379,8 +1378,7 @@ namespace LibHac.FsSrv
|
||||
private Result FindSaveDataWithFilterImpl(out long count, out SaveDataInfo info, SaveDataSpaceId spaceId,
|
||||
in SaveDataInfoFilter infoFilter)
|
||||
{
|
||||
Unsafe.SkipInit(out count);
|
||||
Unsafe.SkipInit(out info);
|
||||
UnsafeHelpers.SkipParamInit(out count, out info);
|
||||
|
||||
SaveDataIndexerAccessor accessor = null;
|
||||
ReferenceCountedDisposable<SaveDataInfoReaderImpl> reader = null;
|
||||
@ -1409,7 +1407,7 @@ namespace LibHac.FsSrv
|
||||
public Result FindSaveDataWithFilter(out long count, OutBuffer saveDataInfoBuffer, SaveDataSpaceId spaceId,
|
||||
in SaveDataFilter filter)
|
||||
{
|
||||
Unsafe.SkipInit(out count);
|
||||
UnsafeHelpers.SkipParamInit(out count);
|
||||
|
||||
if (saveDataInfoBuffer.Size != Unsafe.SizeOf<SaveDataInfo>())
|
||||
return ResultFs.InvalidArgument.Log();
|
||||
@ -1467,7 +1465,7 @@ namespace LibHac.FsSrv
|
||||
public Result OpenSaveDataInfoReaderOnlyCacheStorage(
|
||||
out ReferenceCountedDisposable<ISaveDataInfoReader> infoReader)
|
||||
{
|
||||
infoReader = null;
|
||||
UnsafeHelpers.SkipParamInit(out infoReader);
|
||||
|
||||
using var scopedLayoutType = new ScopedStorageLayoutTypeSetter(StorageType.NonGameCard);
|
||||
|
||||
@ -1505,7 +1503,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
private Result GetCacheStorageSpaceId(out SaveDataSpaceId spaceId)
|
||||
{
|
||||
Unsafe.SkipInit(out spaceId);
|
||||
UnsafeHelpers.SkipParamInit(out spaceId);
|
||||
|
||||
Result rc = GetProgramInfo(out ProgramInfo programInfo);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -1516,7 +1514,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
private Result GetCacheStorageSpaceId(out SaveDataSpaceId spaceId, ulong programId)
|
||||
{
|
||||
Unsafe.SkipInit(out spaceId);
|
||||
UnsafeHelpers.SkipParamInit(out spaceId);
|
||||
Result rc;
|
||||
|
||||
// Cache storage on the SD card will always take priority over case storage in NAND
|
||||
@ -1545,7 +1543,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
Result SaveExists(out bool exists, SaveDataSpaceId saveSpaceId)
|
||||
{
|
||||
Unsafe.SkipInit(out exists);
|
||||
UnsafeHelpers.SkipParamInit(out exists);
|
||||
|
||||
var infoFilter = new SaveDataInfoFilter(saveSpaceId, new ProgramId(programId), SaveDataType.Cache,
|
||||
default, default, default, 0);
|
||||
@ -1716,7 +1714,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result OpenMultiCommitManager(out ReferenceCountedDisposable<IMultiCommitManager> commitManager)
|
||||
{
|
||||
commitManager = default;
|
||||
UnsafeHelpers.SkipParamInit(out commitManager);
|
||||
|
||||
ReferenceCountedDisposable<SaveDataFileSystemService> saveService = null;
|
||||
ReferenceCountedDisposable<ISaveDataMultiCommitCoreInterface> commitInterface = null;
|
||||
@ -1797,7 +1795,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
private Result TryAcquireSaveDataEntryOpenCountSemaphore(out IUniqueLock semaphoreLock)
|
||||
{
|
||||
semaphoreLock = null;
|
||||
UnsafeHelpers.SkipParamInit(out semaphoreLock);
|
||||
|
||||
ReferenceCountedDisposable<SaveDataFileSystemService> saveService = null;
|
||||
IUniqueLock uniqueLock = null;
|
||||
@ -1821,7 +1819,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
private Result TryAcquireSaveDataMountCountSemaphore(out IUniqueLock semaphoreLock)
|
||||
{
|
||||
semaphoreLock = null;
|
||||
UnsafeHelpers.SkipParamInit(out semaphoreLock);
|
||||
|
||||
ReferenceCountedDisposable<SaveDataFileSystemService> saveService = null;
|
||||
IUniqueLock uniqueLock = null;
|
||||
@ -1868,9 +1866,9 @@ namespace LibHac.FsSrv
|
||||
|
||||
private Result OpenSaveDataIndexerAccessor(out SaveDataIndexerAccessor accessor, SaveDataSpaceId spaceId)
|
||||
{
|
||||
accessor = default;
|
||||
SaveDataIndexerAccessor accessorTemp = null;
|
||||
UnsafeHelpers.SkipParamInit(out accessor);
|
||||
|
||||
SaveDataIndexerAccessor accessorTemp = null;
|
||||
try
|
||||
{
|
||||
Result rc = ServiceImpl.OpenSaveDataIndexerAccessor(out accessorTemp, out bool neededInit, spaceId);
|
||||
|
@ -59,7 +59,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result DoesSaveDataEntityExist(out bool exists, SaveDataSpaceId spaceId, ulong saveDataId)
|
||||
{
|
||||
Unsafe.SkipInit(out exists);
|
||||
UnsafeHelpers.SkipParamInit(out exists);
|
||||
|
||||
ReferenceCountedDisposable<IFileSystem> fileSystem = null;
|
||||
try
|
||||
@ -99,7 +99,7 @@ namespace LibHac.FsSrv
|
||||
SaveDataSpaceId spaceId, ulong saveDataId, U8Span saveDataRootPath, bool openReadOnly, SaveDataType type,
|
||||
bool cacheExtraData)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
ReferenceCountedDisposable<IFileSystem> saveDirectoryFs = null;
|
||||
ReferenceCountedDisposable<SaveDataFileSystem> cachedSaveDataFs = null;
|
||||
@ -279,7 +279,7 @@ namespace LibHac.FsSrv
|
||||
public Result OpenSaveDataMeta(out IFile metaFile, ulong saveDataId, SaveDataSpaceId spaceId,
|
||||
SaveDataMetaType metaType)
|
||||
{
|
||||
metaFile = default;
|
||||
UnsafeHelpers.SkipParamInit(out metaFile);
|
||||
|
||||
ReferenceCountedDisposable<IFileSystem> metaDirFs = null;
|
||||
try
|
||||
@ -386,7 +386,7 @@ namespace LibHac.FsSrv
|
||||
ulong saveDataId, SaveDataType type, U8Span saveDataRootPath)
|
||||
{
|
||||
// Todo: Find a way to store extra data for directory save data
|
||||
extraData = default;
|
||||
extraData = new SaveDataExtraData();
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@ -412,7 +412,7 @@ namespace LibHac.FsSrv
|
||||
{
|
||||
if (allowEmulatedSave && IsAllowedDirectorySaveData(spaceId, saveDataRootPath))
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
ReferenceCountedDisposable<IFileSystem> tmFs = null;
|
||||
|
||||
try
|
||||
@ -469,7 +469,7 @@ namespace LibHac.FsSrv
|
||||
public Result OpenSaveDataDirectoryFileSystemImpl(out ReferenceCountedDisposable<IFileSystem> fileSystem,
|
||||
SaveDataSpaceId spaceId, U8Span basePath, bool createIfMissing)
|
||||
{
|
||||
fileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSystem);
|
||||
|
||||
ReferenceCountedDisposable<IFileSystem> tempFs = null;
|
||||
ReferenceCountedDisposable<IFileSystem> tempSubFs = null;
|
||||
@ -614,7 +614,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result GetSaveDataIndexCount(out int count)
|
||||
{
|
||||
Unsafe.SkipInit(out count);
|
||||
UnsafeHelpers.SkipParamInit(out count);
|
||||
|
||||
SaveDataIndexerAccessor accessor = null;
|
||||
try
|
||||
|
@ -218,7 +218,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result Publish(out ulong saveDataId, in SaveDataAttribute key)
|
||||
{
|
||||
saveDataId = default;
|
||||
UnsafeHelpers.SkipParamInit(out saveDataId);
|
||||
|
||||
lock (Locker)
|
||||
{
|
||||
@ -261,7 +261,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result Get(out SaveDataIndexerValue value, in SaveDataAttribute key)
|
||||
{
|
||||
Unsafe.SkipInit(out value);
|
||||
UnsafeHelpers.SkipParamInit(out value);
|
||||
|
||||
lock (Locker)
|
||||
{
|
||||
@ -429,7 +429,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result GetKey(out SaveDataAttribute key, ulong saveDataId)
|
||||
{
|
||||
Unsafe.SkipInit(out key);
|
||||
UnsafeHelpers.SkipParamInit(out key);
|
||||
|
||||
Result rc = TryInitializeDatabase();
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -455,7 +455,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result GetValue(out SaveDataIndexerValue value, ulong saveDataId)
|
||||
{
|
||||
Unsafe.SkipInit(out value);
|
||||
UnsafeHelpers.SkipParamInit(out value);
|
||||
|
||||
Result rc = TryInitializeDatabase();
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -509,7 +509,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result OpenSaveDataInfoReader(out ReferenceCountedDisposable<SaveDataInfoReaderImpl> infoReader)
|
||||
{
|
||||
infoReader = default;
|
||||
UnsafeHelpers.SkipParamInit(out infoReader);
|
||||
|
||||
lock (Locker)
|
||||
{
|
||||
@ -821,7 +821,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result Read(out long readCount, OutBuffer saveDataInfoBuffer)
|
||||
{
|
||||
Unsafe.SkipInit(out readCount);
|
||||
UnsafeHelpers.SkipParamInit(out readCount);
|
||||
|
||||
lock (_indexer.Locker)
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.FsSrv.Sf;
|
||||
using LibHac.Sf;
|
||||
@ -19,6 +20,8 @@ namespace LibHac.FsSrv
|
||||
{
|
||||
private object Locker { get; } = new object();
|
||||
private ulong CurrentSaveDataId { get; set; } = 0x4000000000000000;
|
||||
|
||||
// Todo: Use Optional<T>
|
||||
private bool IsKeyValueSet { get; set; }
|
||||
|
||||
private SaveDataAttribute _key;
|
||||
@ -45,13 +48,12 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result Publish(out ulong saveDataId, in SaveDataAttribute key)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out saveDataId);
|
||||
|
||||
lock (Locker)
|
||||
{
|
||||
if (IsKeyValueSet && _key == key)
|
||||
{
|
||||
saveDataId = default;
|
||||
return ResultFs.SaveDataPathAlreadyExists.Log();
|
||||
}
|
||||
|
||||
_key = key;
|
||||
IsKeyValueSet = true;
|
||||
@ -66,6 +68,8 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result Get(out SaveDataIndexerValue value, in SaveDataAttribute key)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out value);
|
||||
|
||||
lock (Locker)
|
||||
{
|
||||
if (IsKeyValueSet && _key == key)
|
||||
@ -74,7 +78,6 @@ namespace LibHac.FsSrv
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
value = default;
|
||||
return ResultFs.TargetNotFound.Log();
|
||||
}
|
||||
}
|
||||
@ -84,15 +87,12 @@ namespace LibHac.FsSrv
|
||||
lock (Locker)
|
||||
{
|
||||
if (IsKeyValueSet && _key == key)
|
||||
{
|
||||
return ResultFs.SaveDataPathAlreadyExists.Log();
|
||||
}
|
||||
|
||||
_key = key;
|
||||
IsKeyValueSet = true;
|
||||
|
||||
_value = new SaveDataIndexerValue();
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
}
|
||||
@ -162,6 +162,8 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result GetKey(out SaveDataAttribute key, ulong saveDataId)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out key);
|
||||
|
||||
lock (Locker)
|
||||
{
|
||||
if (IsKeyValueSet && _value.SaveDataId == saveDataId)
|
||||
@ -170,13 +172,14 @@ namespace LibHac.FsSrv
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
key = default;
|
||||
return ResultFs.TargetNotFound.Log();
|
||||
}
|
||||
}
|
||||
|
||||
public Result GetValue(out SaveDataIndexerValue value, ulong saveDataId)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out value);
|
||||
|
||||
lock (Locker)
|
||||
{
|
||||
if (IsKeyValueSet && _value.SaveDataId == saveDataId)
|
||||
@ -185,7 +188,6 @@ namespace LibHac.FsSrv
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
value = default;
|
||||
return ResultFs.TargetNotFound.Log();
|
||||
}
|
||||
}
|
||||
@ -215,7 +217,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
if (IsKeyValueSet)
|
||||
{
|
||||
reader = new SaveDataIndexerLiteInfoReader(ref _key, ref _value);
|
||||
reader = new SaveDataIndexerLiteInfoReader(in _key, in _value);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -237,7 +239,7 @@ namespace LibHac.FsSrv
|
||||
_finishedIterating = true;
|
||||
}
|
||||
|
||||
public SaveDataIndexerLiteInfoReader(ref SaveDataAttribute key, ref SaveDataIndexerValue value)
|
||||
public SaveDataIndexerLiteInfoReader(in SaveDataAttribute key, in SaveDataIndexerValue value)
|
||||
{
|
||||
SaveDataIndexer.GenerateSaveDataInfo(out _info, in key, in value);
|
||||
}
|
||||
|
@ -57,14 +57,14 @@ namespace LibHac.FsSrv
|
||||
public Result OpenSaveDataIndexerAccessor(out SaveDataIndexerAccessor accessor, out bool neededInit,
|
||||
SaveDataSpaceId spaceId)
|
||||
{
|
||||
neededInit = false;
|
||||
UniqueLock indexerLock = default;
|
||||
UnsafeHelpers.SkipParamInit(out neededInit);
|
||||
|
||||
if (IsBisUserRedirectionEnabled && spaceId == SaveDataSpaceId.User)
|
||||
{
|
||||
spaceId = SaveDataSpaceId.ProperSystem;
|
||||
}
|
||||
|
||||
UniqueLock indexerLock = default;
|
||||
try
|
||||
{
|
||||
ISaveDataIndexer indexer;
|
||||
|
@ -23,7 +23,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result Read(out long readCount, OutBuffer saveDataInfoBuffer)
|
||||
{
|
||||
readCount = default;
|
||||
UnsafeHelpers.SkipParamInit(out readCount);
|
||||
|
||||
Span<SaveDataInfo> outInfo = MemoryMarshal.Cast<byte, SaveDataInfo>(saveDataInfoBuffer.Buffer);
|
||||
|
||||
|
@ -25,7 +25,7 @@ namespace LibHac.FsSrv.Sf
|
||||
|
||||
public static Result FromSpan(out FspPath fspPath, ReadOnlySpan<byte> path)
|
||||
{
|
||||
Unsafe.SkipInit(out fspPath);
|
||||
UnsafeHelpers.SkipParamInit(out fspPath);
|
||||
|
||||
Span<byte> str = SpanHelpers.AsByteSpan(ref fspPath);
|
||||
|
||||
@ -40,7 +40,7 @@ namespace LibHac.FsSrv.Sf
|
||||
|
||||
public static void CreateEmpty(out FspPath fspPath)
|
||||
{
|
||||
Unsafe.SkipInit(out fspPath);
|
||||
UnsafeHelpers.SkipParamInit(out fspPath);
|
||||
SpanHelpers.AsByteSpan(ref fspPath)[0] = 0;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ namespace LibHac.FsSrv.Storage
|
||||
private static Result GetMmcManagerOperator(this StorageService service,
|
||||
out ReferenceCountedDisposable<IStorageDeviceOperator> deviceOperator)
|
||||
{
|
||||
deviceOperator = null;
|
||||
UnsafeHelpers.SkipParamInit(out deviceOperator);
|
||||
|
||||
ReferenceCountedDisposable<IStorageDeviceManager> deviceManager = null;
|
||||
try
|
||||
@ -40,7 +40,7 @@ namespace LibHac.FsSrv.Storage
|
||||
|
||||
private static Result GetAttribute(out ulong attribute, MmcPartition partition)
|
||||
{
|
||||
Unsafe.SkipInit(out attribute);
|
||||
UnsafeHelpers.SkipParamInit(out attribute);
|
||||
|
||||
switch (partition)
|
||||
{
|
||||
@ -66,7 +66,7 @@ namespace LibHac.FsSrv.Storage
|
||||
private static Result GetMmcOperator(this StorageService service,
|
||||
out ReferenceCountedDisposable<IStorageDeviceOperator> mmcOperator, MmcPartition partition)
|
||||
{
|
||||
mmcOperator = null;
|
||||
UnsafeHelpers.SkipParamInit(out mmcOperator);
|
||||
|
||||
ReferenceCountedDisposable<IStorageDeviceManager> deviceManager = null;
|
||||
try
|
||||
@ -109,7 +109,7 @@ namespace LibHac.FsSrv.Storage
|
||||
public static Result OpenMmcStorage(this StorageService service,
|
||||
out ReferenceCountedDisposable<IStorage> storage, MmcPartition partition)
|
||||
{
|
||||
storage = default;
|
||||
UnsafeHelpers.SkipParamInit(out storage);
|
||||
|
||||
ReferenceCountedDisposable<IStorageDeviceManager> deviceManager = null;
|
||||
try
|
||||
@ -153,7 +153,7 @@ namespace LibHac.FsSrv.Storage
|
||||
|
||||
public static Result GetMmcSpeedMode(this StorageService service, out MmcSpeedMode speedMode)
|
||||
{
|
||||
Unsafe.SkipInit(out speedMode);
|
||||
UnsafeHelpers.SkipParamInit(out speedMode);
|
||||
|
||||
ReferenceCountedDisposable<IStorageDeviceOperator> mmcOperator = null;
|
||||
try
|
||||
@ -224,7 +224,7 @@ namespace LibHac.FsSrv.Storage
|
||||
|
||||
public static Result GetMmcPartitionSize(this StorageService service, out long size, MmcPartition partition)
|
||||
{
|
||||
Unsafe.SkipInit(out size);
|
||||
UnsafeHelpers.SkipParamInit(out size);
|
||||
|
||||
ReferenceCountedDisposable<IStorageDeviceOperator> mmcOperator = null;
|
||||
try
|
||||
@ -245,7 +245,7 @@ namespace LibHac.FsSrv.Storage
|
||||
|
||||
public static Result GetMmcPatrolCount(this StorageService service, out uint count)
|
||||
{
|
||||
Unsafe.SkipInit(out count);
|
||||
UnsafeHelpers.SkipParamInit(out count);
|
||||
|
||||
ReferenceCountedDisposable<IStorageDeviceOperator> mmcOperator = null;
|
||||
try
|
||||
@ -267,8 +267,7 @@ namespace LibHac.FsSrv.Storage
|
||||
public static Result GetAndClearMmcErrorInfo(this StorageService service, out StorageErrorInfo errorInfo,
|
||||
out long logSize, Span<byte> logBuffer)
|
||||
{
|
||||
Unsafe.SkipInit(out errorInfo);
|
||||
Unsafe.SkipInit(out logSize);
|
||||
UnsafeHelpers.SkipParamInit(out errorInfo, out logSize);
|
||||
|
||||
ReferenceCountedDisposable<IStorageDeviceOperator> mmcOperator = null;
|
||||
try
|
||||
@ -347,8 +346,7 @@ namespace LibHac.FsSrv.Storage
|
||||
public static Result GetAndClearPatrolReadAllocateBufferCount(this StorageService service,
|
||||
out long successCount, out long failureCount)
|
||||
{
|
||||
Unsafe.SkipInit(out successCount);
|
||||
Unsafe.SkipInit(out failureCount);
|
||||
UnsafeHelpers.SkipParamInit(out successCount, out failureCount);
|
||||
|
||||
ReferenceCountedDisposable<IStorageDeviceOperator> mmcOperator = null;
|
||||
try
|
||||
|
@ -25,7 +25,7 @@ namespace LibHac.FsSrv.Storage
|
||||
private static Result GetSdCardManagerOperator(this StorageService service,
|
||||
out ReferenceCountedDisposable<IStorageDeviceOperator> deviceOperator)
|
||||
{
|
||||
deviceOperator = null;
|
||||
UnsafeHelpers.SkipParamInit(out deviceOperator);
|
||||
|
||||
ReferenceCountedDisposable<IStorageDeviceManager> deviceManager = null;
|
||||
try
|
||||
@ -44,7 +44,7 @@ namespace LibHac.FsSrv.Storage
|
||||
private static Result GetSdCardOperator(this StorageService service,
|
||||
out ReferenceCountedDisposable<IStorageDeviceOperator> sdCardOperator)
|
||||
{
|
||||
sdCardOperator = null;
|
||||
UnsafeHelpers.SkipParamInit(out sdCardOperator);
|
||||
|
||||
ReferenceCountedDisposable<IStorageDeviceManager> deviceManager = null;
|
||||
try
|
||||
@ -84,7 +84,7 @@ namespace LibHac.FsSrv.Storage
|
||||
public static Result OpenSdStorage(this StorageService service,
|
||||
out ReferenceCountedDisposable<IStorage> storage)
|
||||
{
|
||||
storage = default;
|
||||
UnsafeHelpers.SkipParamInit(out storage);
|
||||
|
||||
ReferenceCountedDisposable<IStorageDeviceManager> deviceManager = null;
|
||||
try
|
||||
@ -123,7 +123,7 @@ namespace LibHac.FsSrv.Storage
|
||||
|
||||
public static Result GetCurrentSdCardHandle(this StorageService service, out StorageDeviceHandle handle)
|
||||
{
|
||||
Unsafe.SkipInit(out handle);
|
||||
UnsafeHelpers.SkipParamInit(out handle);
|
||||
|
||||
ReferenceCountedDisposable<IStorageDeviceManager> deviceManager = null;
|
||||
try
|
||||
@ -157,7 +157,7 @@ namespace LibHac.FsSrv.Storage
|
||||
public static Result IsSdCardHandleValid(this StorageService service, out bool isValid,
|
||||
in StorageDeviceHandle handle)
|
||||
{
|
||||
Unsafe.SkipInit(out isValid);
|
||||
UnsafeHelpers.SkipParamInit(out isValid);
|
||||
|
||||
ReferenceCountedDisposable<IStorageDeviceManager> deviceManager = null;
|
||||
try
|
||||
@ -192,7 +192,7 @@ namespace LibHac.FsSrv.Storage
|
||||
|
||||
public static Result IsSdCardInserted(this StorageService service, out bool isInserted)
|
||||
{
|
||||
Unsafe.SkipInit(out isInserted);
|
||||
UnsafeHelpers.SkipParamInit(out isInserted);
|
||||
|
||||
ReferenceCountedDisposable<IStorageDeviceManager> deviceManager = null;
|
||||
try
|
||||
@ -210,7 +210,7 @@ namespace LibHac.FsSrv.Storage
|
||||
|
||||
public static Result GetSdCardSpeedMode(this StorageService service, out SdCardSpeedMode speedMode)
|
||||
{
|
||||
Unsafe.SkipInit(out speedMode);
|
||||
UnsafeHelpers.SkipParamInit(out speedMode);
|
||||
|
||||
ReferenceCountedDisposable<IStorageDeviceOperator> sdCardOperator = null;
|
||||
try
|
||||
@ -270,7 +270,7 @@ namespace LibHac.FsSrv.Storage
|
||||
|
||||
public static Result GetSdCardUserAreaNumSectors(this StorageService service, out uint count)
|
||||
{
|
||||
Unsafe.SkipInit(out count);
|
||||
UnsafeHelpers.SkipParamInit(out count);
|
||||
|
||||
ReferenceCountedDisposable<IStorageDeviceOperator> sdCardOperator = null;
|
||||
try
|
||||
@ -294,7 +294,7 @@ namespace LibHac.FsSrv.Storage
|
||||
|
||||
public static Result GetSdCardUserAreaSize(this StorageService service, out long size)
|
||||
{
|
||||
Unsafe.SkipInit(out size);
|
||||
UnsafeHelpers.SkipParamInit(out size);
|
||||
|
||||
ReferenceCountedDisposable<IStorageDeviceOperator> sdCardOperator = null;
|
||||
try
|
||||
@ -318,7 +318,7 @@ namespace LibHac.FsSrv.Storage
|
||||
|
||||
public static Result GetSdCardProtectedAreaNumSectors(this StorageService service, out uint count)
|
||||
{
|
||||
Unsafe.SkipInit(out count);
|
||||
UnsafeHelpers.SkipParamInit(out count);
|
||||
|
||||
ReferenceCountedDisposable<IStorageDeviceOperator> sdCardOperator = null;
|
||||
try
|
||||
@ -342,7 +342,7 @@ namespace LibHac.FsSrv.Storage
|
||||
|
||||
public static Result GetSdCardProtectedAreaSize(this StorageService service, out long size)
|
||||
{
|
||||
Unsafe.SkipInit(out size);
|
||||
UnsafeHelpers.SkipParamInit(out size);
|
||||
|
||||
ReferenceCountedDisposable<IStorageDeviceOperator> sdCardOperator = null;
|
||||
try
|
||||
@ -367,8 +367,7 @@ namespace LibHac.FsSrv.Storage
|
||||
public static Result GetAndClearSdCardErrorInfo(this StorageService service, out StorageErrorInfo errorInfo,
|
||||
out long logSize, Span<byte> logBuffer)
|
||||
{
|
||||
Unsafe.SkipInit(out errorInfo);
|
||||
Unsafe.SkipInit(out logSize);
|
||||
UnsafeHelpers.SkipParamInit(out errorInfo, out logSize);
|
||||
|
||||
ReferenceCountedDisposable<IStorageDeviceOperator> sdCardOperator = null;
|
||||
try
|
||||
@ -395,7 +394,7 @@ namespace LibHac.FsSrv.Storage
|
||||
public static Result OpenSdCardDetectionEvent(this StorageService service,
|
||||
out ReferenceCountedDisposable<IEventNotifier> eventNotifier)
|
||||
{
|
||||
eventNotifier = default;
|
||||
UnsafeHelpers.SkipParamInit(out eventNotifier);
|
||||
|
||||
ReferenceCountedDisposable<IStorageDeviceManager> deviceManager = null;
|
||||
try
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.FsSrv.Impl;
|
||||
using LibHac.Os;
|
||||
@ -66,8 +67,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public Result GetCurrentPosixTimeWithTimeDifference(out long currentTime, out int timeDifference)
|
||||
{
|
||||
Unsafe.SkipInit(out currentTime);
|
||||
Unsafe.SkipInit(out timeDifference);
|
||||
UnsafeHelpers.SkipParamInit(out currentTime, out timeDifference);
|
||||
|
||||
using ScopedLock<SdkMutexType> lk = ScopedLock.Lock(ref _mutex);
|
||||
|
||||
|
@ -10,7 +10,7 @@ namespace LibHac.FsSrv
|
||||
public static Result CreateSubFileSystem(out IFileSystem subFileSystem, IFileSystem baseFileSystem, string path,
|
||||
bool createPathIfMissing)
|
||||
{
|
||||
subFileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out subFileSystem);
|
||||
Result rc;
|
||||
|
||||
if (!createPathIfMissing)
|
||||
@ -33,7 +33,7 @@ namespace LibHac.FsSrv
|
||||
|
||||
public static Result CreateSubFileSystemImpl(out IFileSystem subFileSystem, IFileSystem baseFileSystem, string path)
|
||||
{
|
||||
subFileSystem = default;
|
||||
UnsafeHelpers.SkipParamInit(out subFileSystem);
|
||||
|
||||
if (path == null) return ResultFs.NullptrArgument.Log();
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
using LibHac.Crypto;
|
||||
using LibHac.Fs;
|
||||
using System;
|
||||
using LibHac.Common;
|
||||
|
||||
namespace LibHac.FsSystem
|
||||
{
|
||||
@ -64,8 +65,8 @@ namespace LibHac.FsSystem
|
||||
decryptor = Aes.CreateCbcDecryptor(_key, _iv);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
decryptor = default;
|
||||
|
||||
UnsafeHelpers.SkipParamInit(out decryptor);
|
||||
|
||||
// Need to get the output of the previous block
|
||||
Span<byte> prevBlock = stackalloc byte[BlockSize];
|
||||
|
@ -61,7 +61,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
protected override Result DoRead(out long bytesRead, long offset, Span<byte> destination, in ReadOption option)
|
||||
{
|
||||
bytesRead = default;
|
||||
UnsafeHelpers.SkipParamInit(out bytesRead);
|
||||
|
||||
Result rc = DryRead(out long toRead, offset, destination.Length, in option, Mode);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
@ -104,7 +104,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
protected override Result DoOpenDirectory(out IDirectory directory, U8Span path, OpenDirectoryMode mode)
|
||||
{
|
||||
directory = default;
|
||||
UnsafeHelpers.SkipParamInit(out directory);
|
||||
|
||||
Result rc = BaseFileSystem.OpenDirectory(out IDirectory baseDir, path, mode);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -115,7 +115,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
protected override Result DoOpenFile(out IFile file, U8Span path, OpenMode mode)
|
||||
{
|
||||
file = default;
|
||||
UnsafeHelpers.SkipParamInit(out file);
|
||||
|
||||
Result rc = BaseFileSystem.OpenFile(out IFile baseFile, path, mode | OpenMode.Read);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
@ -594,7 +594,7 @@ namespace LibHac.FsSystem
|
||||
private Result FindEntrySetWithBuffer(out int outIndex, long virtualAddress, int nodeIndex,
|
||||
Span<byte> buffer)
|
||||
{
|
||||
outIndex = default;
|
||||
UnsafeHelpers.SkipParamInit(out outIndex);
|
||||
|
||||
// Calculate node extents.
|
||||
long nodeSize = Tree.NodeSize;
|
||||
|
@ -98,8 +98,8 @@ namespace LibHac.FsSystem.Buffers
|
||||
Assert.NotNull(callerName);
|
||||
|
||||
// Clear the output.
|
||||
outBuffer = default;
|
||||
Buffer tempBuffer = default;
|
||||
outBuffer = new Buffer();
|
||||
var tempBuffer = new Buffer();
|
||||
|
||||
// Get the context.
|
||||
ref BufferManagerContext context = ref GetBufferManagerContext();
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using LibHac.Common;
|
||||
using LibHac.Diag;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Util;
|
||||
@ -127,7 +128,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
public bool Register(out CacheHandle handle, Buffer buffer, BufferAttribute attr)
|
||||
{
|
||||
Unsafe.SkipInit(out handle);
|
||||
UnsafeHelpers.SkipParamInit(out handle);
|
||||
|
||||
// Validate pre-conditions.
|
||||
Assert.True(Entries != null);
|
||||
@ -162,12 +163,13 @@ namespace LibHac.FsSystem
|
||||
|
||||
public bool Unregister(out Buffer buffer, CacheHandle handle)
|
||||
{
|
||||
Unsafe.SkipInit(out buffer);
|
||||
|
||||
// Validate pre-conditions.
|
||||
Unsafe.SkipInit(out buffer);
|
||||
Assert.True(Entries != null);
|
||||
Assert.True(!Unsafe.IsNullRef(ref buffer));
|
||||
|
||||
UnsafeHelpers.SkipParamInit(out buffer);
|
||||
|
||||
// Find the lower bound for the entry.
|
||||
for (int i = 0; i < EntryCount; i++)
|
||||
{
|
||||
@ -185,12 +187,13 @@ namespace LibHac.FsSystem
|
||||
public bool UnregisterOldest(out Buffer buffer, BufferAttribute attr, int requiredSize = 0)
|
||||
// ReSharper restore UnusedParameter.Local
|
||||
{
|
||||
Unsafe.SkipInit(out buffer);
|
||||
|
||||
// Validate pre-conditions.
|
||||
Unsafe.SkipInit(out buffer);
|
||||
Assert.True(Entries != null);
|
||||
Assert.True(!Unsafe.IsNullRef(ref buffer));
|
||||
|
||||
UnsafeHelpers.SkipParamInit(out buffer);
|
||||
|
||||
// If we have no entries, we can't unregister any.
|
||||
if (EntryCount == 0)
|
||||
{
|
||||
@ -231,9 +234,9 @@ namespace LibHac.FsSystem
|
||||
|
||||
private void UnregisterCore(out Buffer buffer, ref Entry entry)
|
||||
{
|
||||
Unsafe.SkipInit(out buffer);
|
||||
|
||||
// Validate pre-conditions.
|
||||
Unsafe.SkipInit(out buffer);
|
||||
Assert.True(Entries != null);
|
||||
Assert.True(!Unsafe.IsNullRef(ref buffer));
|
||||
Assert.True(!Unsafe.IsNullRef(ref entry));
|
||||
|
@ -40,7 +40,7 @@ namespace LibHac.FsSystem
|
||||
protected override Result DoRead(out long bytesRead, long offset, Span<byte> destination,
|
||||
in ReadOption option)
|
||||
{
|
||||
bytesRead = default;
|
||||
UnsafeHelpers.SkipParamInit(out bytesRead);
|
||||
|
||||
long inPos = offset;
|
||||
int outPos = 0;
|
||||
@ -124,7 +124,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
protected override Result DoGetSize(out long size)
|
||||
{
|
||||
size = default;
|
||||
UnsafeHelpers.SkipParamInit(out size);
|
||||
|
||||
foreach (IFile file in Sources)
|
||||
{
|
||||
|
@ -208,7 +208,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
protected override Result DoOpenDirectory(out IDirectory directory, U8Span path, OpenDirectoryMode mode)
|
||||
{
|
||||
directory = default;
|
||||
UnsafeHelpers.SkipParamInit(out directory);
|
||||
|
||||
if (IsConcatenationFile(path))
|
||||
{
|
||||
@ -224,7 +224,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
protected override Result DoOpenFile(out IFile file, U8Span path, OpenMode mode)
|
||||
{
|
||||
file = default;
|
||||
UnsafeHelpers.SkipParamInit(out file);
|
||||
|
||||
if (!IsConcatenationFile(path))
|
||||
{
|
||||
@ -326,7 +326,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
private Result GetSubFileCount(out int fileCount, U8Span dirPath)
|
||||
{
|
||||
fileCount = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileCount);
|
||||
|
||||
Unsafe.SkipInit(out FsPath buffer);
|
||||
|
||||
@ -376,8 +376,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
internal Result GetConcatenationFileSize(out long size, ReadOnlySpan<byte> path)
|
||||
{
|
||||
size = default;
|
||||
|
||||
UnsafeHelpers.SkipParamInit(out size);
|
||||
Unsafe.SkipInit(out FsPath buffer);
|
||||
|
||||
int pathLen = StringUtils.Copy(buffer.Str, path);
|
||||
|
@ -46,7 +46,7 @@ namespace LibHac.FsSystem
|
||||
}
|
||||
|
||||
obj.Dispose();
|
||||
created = default;
|
||||
UnsafeHelpers.SkipParamInit(out created);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -185,7 +185,7 @@ namespace LibHac.FsSystem
|
||||
Result rc = ResolveFullPath(fullPath.Str, path);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
directory = default;
|
||||
UnsafeHelpers.SkipParamInit(out directory);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -197,7 +197,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
protected override Result DoOpenFile(out IFile file, U8Span path, OpenMode mode)
|
||||
{
|
||||
file = default;
|
||||
UnsafeHelpers.SkipParamInit(out file);
|
||||
|
||||
Unsafe.SkipInit(out FsPath fullPath);
|
||||
|
||||
@ -261,7 +261,7 @@ namespace LibHac.FsSystem
|
||||
Result rc = ResolveFullPath(fullPath.Str, path);
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
entryType = default;
|
||||
UnsafeHelpers.SkipParamInit(out entryType);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -324,7 +324,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
protected override Result DoGetFreeSpaceSize(out long freeSpace, U8Span path)
|
||||
{
|
||||
freeSpace = default;
|
||||
UnsafeHelpers.SkipParamInit(out freeSpace);
|
||||
|
||||
Unsafe.SkipInit(out FsPath fullPath);
|
||||
|
||||
@ -339,7 +339,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
protected override Result DoGetTotalSpaceSize(out long totalSpace, U8Span path)
|
||||
{
|
||||
totalSpace = default;
|
||||
UnsafeHelpers.SkipParamInit(out totalSpace);
|
||||
|
||||
Unsafe.SkipInit(out FsPath fullPath);
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
@ -43,7 +44,8 @@ namespace LibHac.FsSystem
|
||||
Result rc = sourceFs.OpenFile(out srcFile, new U8Span(sourcePath), OpenMode.Read);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
||||
FsPath dstPath = default;
|
||||
Unsafe.SkipInit(out FsPath dstPath);
|
||||
dstPath.Str[0] = 0;
|
||||
int dstPathLen = StringUtils.Concat(dstPath.Str, destParentPath);
|
||||
dstPathLen = StringUtils.Concat(dstPath.Str, dirEntry.Name, dstPathLen);
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
@ -86,7 +87,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
while (true)
|
||||
{
|
||||
DirectoryEntry dirEntry = default;
|
||||
Unsafe.SkipInit(out DirectoryEntry dirEntry);
|
||||
|
||||
directory.Read(out long entriesRead, SpanHelpers.AsSpan(ref dirEntry)).ThrowIfFailure();
|
||||
if (entriesRead == 0) break;
|
||||
|
@ -39,7 +39,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
protected override Result DoOpenDirectory(out IDirectory directory, U8Span path, OpenDirectoryMode mode)
|
||||
{
|
||||
directory = default;
|
||||
UnsafeHelpers.SkipParamInit(out directory);
|
||||
|
||||
// Open directories from all layers so they can be merged
|
||||
// Only allocate the list for multiple sources if needed
|
||||
@ -110,7 +110,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
protected override Result DoOpenFile(out IFile file, U8Span path, OpenMode mode)
|
||||
{
|
||||
file = default;
|
||||
UnsafeHelpers.SkipParamInit(out file);
|
||||
|
||||
foreach (IFileSystem fs in Sources)
|
||||
{
|
||||
@ -139,6 +139,8 @@ namespace LibHac.FsSystem
|
||||
|
||||
protected override Result DoGetEntryType(out DirectoryEntryType entryType, U8Span path)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out entryType);
|
||||
|
||||
foreach (IFileSystem fs in Sources)
|
||||
{
|
||||
Result getEntryResult = fs.GetEntryType(out DirectoryEntryType type, path);
|
||||
@ -150,12 +152,13 @@ namespace LibHac.FsSystem
|
||||
}
|
||||
}
|
||||
|
||||
entryType = default;
|
||||
return ResultFs.PathNotFound.Log();
|
||||
}
|
||||
|
||||
protected override Result DoGetFileTimeStampRaw(out FileTimeStampRaw timeStamp, U8Span path)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out timeStamp);
|
||||
|
||||
foreach (IFileSystem fs in Sources)
|
||||
{
|
||||
Result getEntryResult = fs.GetEntryType(out _, path);
|
||||
@ -166,7 +169,6 @@ namespace LibHac.FsSystem
|
||||
}
|
||||
}
|
||||
|
||||
timeStamp = default;
|
||||
return ResultFs.PathNotFound.Log();
|
||||
}
|
||||
|
||||
|
@ -61,13 +61,14 @@ namespace LibHac.FsSystem
|
||||
|
||||
protected override Result DoGetSize(out long size)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out size);
|
||||
|
||||
try
|
||||
{
|
||||
return File.GetSize(out size);
|
||||
}
|
||||
catch (Exception ex) when (ex.HResult < 0)
|
||||
{
|
||||
size = default;
|
||||
return ResultFs.UnexpectedErrorInHostFileGetSize.Log();
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
private Result ResolveFullPath(out string fullPath, U8Span path)
|
||||
{
|
||||
fullPath = default;
|
||||
UnsafeHelpers.SkipParamInit(out fullPath);
|
||||
|
||||
Unsafe.SkipInit(out FsPath normalizedPath);
|
||||
|
||||
@ -67,7 +67,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
protected override Result DoGetFileAttributes(out NxFileAttributes attributes, U8Span path)
|
||||
{
|
||||
attributes = default;
|
||||
UnsafeHelpers.SkipParamInit(out attributes);
|
||||
|
||||
Result rc = ResolveFullPath(out string fullPath, path);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -77,7 +77,6 @@ namespace LibHac.FsSystem
|
||||
|
||||
if (info.Attributes == (FileAttributes)(-1))
|
||||
{
|
||||
attributes = default;
|
||||
return ResultFs.PathNotFound.Log();
|
||||
}
|
||||
|
||||
@ -115,7 +114,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
protected override Result DoGetFileSize(out long fileSize, U8Span path)
|
||||
{
|
||||
fileSize = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileSize);
|
||||
|
||||
Result rc = ResolveFullPath(out string fullPath, path);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -241,7 +240,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
protected override Result DoOpenDirectory(out IDirectory directory, U8Span path, OpenDirectoryMode mode)
|
||||
{
|
||||
directory = default;
|
||||
UnsafeHelpers.SkipParamInit(out directory);
|
||||
Result rc = ResolveFullPath(out string fullPath, path);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
||||
@ -268,7 +267,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
protected override Result DoOpenFile(out IFile file, U8Span path, OpenMode mode)
|
||||
{
|
||||
file = default;
|
||||
UnsafeHelpers.SkipParamInit(out file);
|
||||
|
||||
Result rc = ResolveFullPath(out string fullPath, path);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -333,7 +332,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
protected override Result DoGetEntryType(out DirectoryEntryType entryType, U8Span path)
|
||||
{
|
||||
entryType = default;
|
||||
UnsafeHelpers.SkipParamInit(out entryType);
|
||||
|
||||
Result rc = ResolveFullPath(out string fullPath, path);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -356,13 +355,12 @@ namespace LibHac.FsSystem
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
entryType = default;
|
||||
return ResultFs.PathNotFound.Log();
|
||||
}
|
||||
|
||||
protected override Result DoGetFileTimeStampRaw(out FileTimeStampRaw timeStamp, U8Span path)
|
||||
{
|
||||
timeStamp = default;
|
||||
UnsafeHelpers.SkipParamInit(out timeStamp);
|
||||
|
||||
Result rc = ResolveFullPath(out string fullPath, path);
|
||||
if (rc.IsFailure()) return rc;
|
||||
@ -422,13 +420,15 @@ namespace LibHac.FsSystem
|
||||
}
|
||||
catch (Exception ex) when (ex.HResult < 0)
|
||||
{
|
||||
stream = default;
|
||||
UnsafeHelpers.SkipParamInit(out stream);
|
||||
return HResult.HResultToHorizonResult(ex.HResult).Log();
|
||||
}
|
||||
}
|
||||
|
||||
private static Result GetSizeInternal(out long fileSize, FileInfo file)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out fileSize);
|
||||
|
||||
try
|
||||
{
|
||||
fileSize = file.Length;
|
||||
@ -436,14 +436,13 @@ namespace LibHac.FsSystem
|
||||
}
|
||||
catch (Exception ex) when (ex.HResult < 0)
|
||||
{
|
||||
fileSize = default;
|
||||
return HResult.HResultToHorizonResult(ex.HResult).Log();
|
||||
}
|
||||
}
|
||||
|
||||
private static Result CreateFileInternal(out FileStream file, FileInfo fileInfo)
|
||||
{
|
||||
file = default;
|
||||
UnsafeHelpers.SkipParamInit(out file);
|
||||
|
||||
try
|
||||
{
|
||||
@ -564,6 +563,8 @@ namespace LibHac.FsSystem
|
||||
// GetFileInfo and GetDirInfo detect invalid paths
|
||||
private static Result GetFileInfo(out FileInfo fileInfo, string path)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out fileInfo);
|
||||
|
||||
try
|
||||
{
|
||||
fileInfo = new FileInfo(path);
|
||||
@ -571,13 +572,14 @@ namespace LibHac.FsSystem
|
||||
}
|
||||
catch (Exception ex) when (ex.HResult < 0)
|
||||
{
|
||||
fileInfo = default;
|
||||
return HResult.HResultToHorizonResult(ex.HResult).Log();
|
||||
}
|
||||
}
|
||||
|
||||
private static Result GetDirInfo(out DirectoryInfo directoryInfo, string path)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out directoryInfo);
|
||||
|
||||
try
|
||||
{
|
||||
directoryInfo = new DirectoryInfo(path);
|
||||
@ -585,7 +587,6 @@ namespace LibHac.FsSystem
|
||||
}
|
||||
catch (Exception ex) when (ex.HResult < 0)
|
||||
{
|
||||
directoryInfo = default;
|
||||
return HResult.HResultToHorizonResult(ex.HResult).Log();
|
||||
}
|
||||
}
|
||||
|
@ -500,7 +500,7 @@ namespace LibHac.FsSystem.NcaUtils
|
||||
type = NcaSectionType.Data;
|
||||
return true;
|
||||
default:
|
||||
type = default;
|
||||
UnsafeHelpers.SkipParamInit(out type);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ namespace LibHac.FsSystem.NcaUtils
|
||||
|
||||
// Key areas using fixed, unencrypted keys always use the same keys.
|
||||
// Check for these keys by comparing the key area with the known hash of the fixed body keys.
|
||||
Buffer32 hash = default;
|
||||
Unsafe.SkipInit(out Buffer32 hash);
|
||||
Sha256.GenerateSha256Hash(keyArea.Slice(0, 0x20), hash);
|
||||
|
||||
if (Nca0FixedBodyKeySha256Hash.SequenceEqual(hash))
|
||||
|
@ -59,7 +59,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
protected override Result DoGetEntryType(out DirectoryEntryType entryType, U8Span path)
|
||||
{
|
||||
entryType = default;
|
||||
UnsafeHelpers.SkipParamInit(out entryType);
|
||||
|
||||
if (path.ToString() == "/")
|
||||
{
|
||||
|
@ -55,7 +55,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
protected override Result DoOpenDirectory(out IDirectory directory, U8Span path, OpenDirectoryMode mode)
|
||||
{
|
||||
directory = default;
|
||||
UnsafeHelpers.SkipParamInit(out directory);
|
||||
|
||||
if (!IsInitialized)
|
||||
return ResultFs.PreconditionViolation.Log();
|
||||
@ -72,7 +72,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
protected override Result DoOpenFile(out IFile file, U8Span path, OpenMode mode)
|
||||
{
|
||||
file = default;
|
||||
UnsafeHelpers.SkipParamInit(out file);
|
||||
|
||||
if (!IsInitialized)
|
||||
return ResultFs.PreconditionViolation.Log();
|
||||
@ -92,7 +92,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
protected override Result DoGetEntryType(out DirectoryEntryType entryType, U8Span path)
|
||||
{
|
||||
entryType = default;
|
||||
UnsafeHelpers.SkipParamInit(out entryType);
|
||||
|
||||
if (!IsInitialized)
|
||||
return ResultFs.PreconditionViolation.Log();
|
||||
@ -148,7 +148,7 @@ namespace LibHac.FsSystem
|
||||
protected override Result DoRead(out long bytesRead, long offset, Span<byte> destination,
|
||||
in ReadOption option)
|
||||
{
|
||||
bytesRead = default;
|
||||
UnsafeHelpers.SkipParamInit(out bytesRead);
|
||||
|
||||
Result rc = DryRead(out long bytesToRead, offset, destination.Length, in option, Mode);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
@ -461,7 +461,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
if (rc.IsFailure())
|
||||
{
|
||||
mountName = default;
|
||||
UnsafeHelpers.SkipParamInit(out mountName);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -471,6 +471,8 @@ namespace LibHac.FsSystem
|
||||
|
||||
public static Result GetMountNameLength(string path, out int length)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out length);
|
||||
|
||||
int maxLen = Math.Min(path.Length, MountNameLengthMax);
|
||||
|
||||
for (int i = 0; i < maxLen; i++)
|
||||
@ -482,7 +484,6 @@ namespace LibHac.FsSystem
|
||||
}
|
||||
}
|
||||
|
||||
length = default;
|
||||
return ResultFs.InvalidMountName.Log();
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
protected override Result DoOpenFile(out IFile file, U8Span path, OpenMode mode)
|
||||
{
|
||||
file = default;
|
||||
UnsafeHelpers.SkipParamInit(out file);
|
||||
|
||||
Result rc = BaseFs.OpenFile(out IFile baseFile, path, mode);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Util;
|
||||
|
||||
@ -92,7 +93,7 @@ namespace LibHac.FsSystem.RomFs
|
||||
return true;
|
||||
}
|
||||
|
||||
fileInfo = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileInfo);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -104,7 +105,7 @@ namespace LibHac.FsSystem.RomFs
|
||||
return true;
|
||||
}
|
||||
|
||||
fileInfo = default;
|
||||
UnsafeHelpers.SkipParamInit(out fileInfo);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -125,7 +126,7 @@ namespace LibHac.FsSystem.RomFs
|
||||
return true;
|
||||
}
|
||||
|
||||
position = default;
|
||||
UnsafeHelpers.SkipParamInit(out position);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -144,7 +145,7 @@ namespace LibHac.FsSystem.RomFs
|
||||
return true;
|
||||
}
|
||||
|
||||
position = default;
|
||||
UnsafeHelpers.SkipParamInit(out position);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -161,8 +162,7 @@ namespace LibHac.FsSystem.RomFs
|
||||
{
|
||||
if (position.NextFile == -1)
|
||||
{
|
||||
info = default;
|
||||
name = default;
|
||||
UnsafeHelpers.SkipParamInit(out info, out name);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -187,7 +187,7 @@ namespace LibHac.FsSystem.RomFs
|
||||
{
|
||||
if (position.NextDirectory == -1)
|
||||
{
|
||||
name = default;
|
||||
UnsafeHelpers.SkipParamInit(out name);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
|
||||
@ -20,7 +21,7 @@ namespace LibHac.FsSystem.RomFs
|
||||
protected override Result DoRead(out long bytesRead, long offset, Span<byte> destination,
|
||||
in ReadOption option)
|
||||
{
|
||||
bytesRead = default;
|
||||
UnsafeHelpers.SkipParamInit(out bytesRead);
|
||||
|
||||
Result rc = DryRead(out long toRead, offset, destination.Length, in option, OpenMode.Read);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user