Rename Result rc variables to Result res

This commit is contained in:
Alex Barney 2022-11-09 21:33:27 -07:00
parent 70aac7ca7b
commit ef71eedc05
204 changed files with 6148 additions and 6148 deletions

View File

@ -61,11 +61,11 @@ public class ArpClient : IDisposable
return; return;
using var reader = new SharedRef<IReader>(); using var reader = new SharedRef<IReader>();
Result rc = _hosClient.Sm.GetService(ref reader.Ref(), "arp:r"); Result res = _hosClient.Sm.GetService(ref reader.Ref(), "arp:r");
if (rc.IsFailure()) if (res.IsFailure())
{ {
throw new HorizonResultException(rc, "Failed to initialize arp reader."); throw new HorizonResultException(res, "Failed to initialize arp reader.");
} }
_reader.SetByMove(ref reader.Ref()); _reader.SetByMove(ref reader.Ref());

View File

@ -36,10 +36,10 @@ public class BcatServer
using SharedRef<IServiceCreator> service = GetServiceCreator(type); using SharedRef<IServiceCreator> service = GetServiceCreator(type);
Result rc = Hos.Sm.RegisterService(new BcatServiceObject(ref service.Ref()), name); Result res = Hos.Sm.RegisterService(new BcatServiceObject(ref service.Ref()), name);
if (rc.IsFailure()) if (res.IsFailure())
{ {
throw new HorizonResultException(rc, "Abort"); throw new HorizonResultException(res, "Abort");
} }
} }

View File

@ -52,11 +52,11 @@ internal class DeliveryCacheDirectoryMetaAccessor
{ {
FileSystemClient fs = Server.GetFsClient(); FileSystemClient fs = Server.GetFsClient();
Result rc = fs.OpenFile(out FileHandle handle, path, OpenMode.Read); Result res = fs.OpenFile(out FileHandle handle, path, OpenMode.Read);
if (rc.IsFailure()) if (res.IsFailure())
{ {
if (ResultFs.PathNotFound.Includes(rc)) if (ResultFs.PathNotFound.Includes(res))
{ {
if (allowMissingMetaFile) if (allowMissingMetaFile)
{ {
@ -64,10 +64,10 @@ internal class DeliveryCacheDirectoryMetaAccessor
return Result.Success; return Result.Success;
} }
return ResultBcat.NotFound.LogConverted(rc); return ResultBcat.NotFound.LogConverted(res);
} }
return rc; return res;
} }
try try
@ -76,16 +76,16 @@ internal class DeliveryCacheDirectoryMetaAccessor
int header = 0; int header = 0;
// Verify the header value // Verify the header value
rc = fs.ReadFile(out long bytesRead, handle, 0, SpanHelpers.AsByteSpan(ref header)); res = fs.ReadFile(out long bytesRead, handle, 0, SpanHelpers.AsByteSpan(ref header));
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (bytesRead != sizeof(int) || header != MetaFileHeaderValue) if (bytesRead != sizeof(int) || header != MetaFileHeaderValue)
return ResultBcat.InvalidDeliveryCacheStorageFile.Log(); return ResultBcat.InvalidDeliveryCacheStorageFile.Log();
// Read all the directory entries // Read all the directory entries
Span<byte> buffer = MemoryMarshal.Cast<DeliveryCacheDirectoryMetaEntry, byte>(Entries); Span<byte> buffer = MemoryMarshal.Cast<DeliveryCacheDirectoryMetaEntry, byte>(Entries);
rc = fs.ReadFile(out bytesRead, handle, 4, buffer); res = fs.ReadFile(out bytesRead, handle, 4, buffer);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
Count = (int)((uint)bytesRead / Unsafe.SizeOf<DeliveryCacheDirectoryMetaEntry>()); Count = (int)((uint)bytesRead / Unsafe.SizeOf<DeliveryCacheDirectoryMetaEntry>());

View File

@ -73,11 +73,11 @@ internal class DeliveryCacheFileMetaAccessor
{ {
FileSystemClient fs = Server.GetFsClient(); FileSystemClient fs = Server.GetFsClient();
Result rc = fs.OpenFile(out FileHandle handle, path, OpenMode.Read); Result res = fs.OpenFile(out FileHandle handle, path, OpenMode.Read);
if (rc.IsFailure()) if (res.IsFailure())
{ {
if (ResultFs.PathNotFound.Includes(rc)) if (ResultFs.PathNotFound.Includes(res))
{ {
if (allowMissingMetaFile) if (allowMissingMetaFile)
{ {
@ -85,10 +85,10 @@ internal class DeliveryCacheFileMetaAccessor
return Result.Success; return Result.Success;
} }
return ResultBcat.NotFound.LogConverted(rc); return ResultBcat.NotFound.LogConverted(res);
} }
return rc; return res;
} }
try try
@ -97,16 +97,16 @@ internal class DeliveryCacheFileMetaAccessor
int header = 0; int header = 0;
// Verify the header value // Verify the header value
rc = fs.ReadFile(out long bytesRead, handle, 0, SpanHelpers.AsByteSpan(ref header)); res = fs.ReadFile(out long bytesRead, handle, 0, SpanHelpers.AsByteSpan(ref header));
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (bytesRead != sizeof(int) || header != MetaFileHeaderValue) if (bytesRead != sizeof(int) || header != MetaFileHeaderValue)
return ResultBcat.InvalidDeliveryCacheStorageFile.Log(); return ResultBcat.InvalidDeliveryCacheStorageFile.Log();
// Read all the file entries // Read all the file entries
Span<byte> buffer = MemoryMarshal.Cast<DeliveryCacheFileMetaEntry, byte>(Entries); Span<byte> buffer = MemoryMarshal.Cast<DeliveryCacheFileMetaEntry, byte>(Entries);
rc = fs.ReadFile(out bytesRead, handle, 4, buffer); res = fs.ReadFile(out bytesRead, handle, 4, buffer);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
Count = (int)((uint)bytesRead / Unsafe.SizeOf<DeliveryCacheFileMetaEntry>()); Count = (int)((uint)bytesRead / Unsafe.SizeOf<DeliveryCacheFileMetaEntry>());

View File

@ -35,8 +35,8 @@ internal class DeliveryCacheStorageManager
lock (_locker) lock (_locker)
{ {
// Find an existing storage entry for this application ID or get an empty one // Find an existing storage entry for this application ID or get an empty one
Result rc = FindOrGetUnusedEntry(out int index, applicationId); Result res = FindOrGetUnusedEntry(out int index, applicationId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
ref Entry entry = ref Entries[index]; ref Entry entry = ref Entries[index];
@ -55,15 +55,15 @@ internal class DeliveryCacheStorageManager
// Mount the save if enabled // Mount the save if enabled
if (!DisableStorage) if (!DisableStorage)
{ {
rc = Server.GetFsClient() res = Server.GetFsClient()
.MountBcatSaveData(new U8Span(mountName.Name), new Ncm.ApplicationId(applicationId)); .MountBcatSaveData(new U8Span(mountName.Name), new Ncm.ApplicationId(applicationId));
if (rc.IsFailure()) if (res.IsFailure())
{ {
if (ResultFs.TargetNotFound.Includes(rc)) if (ResultFs.TargetNotFound.Includes(res))
return ResultBcat.SaveDataNotFound.LogConverted(rc); return ResultBcat.SaveDataNotFound.LogConverted(res);
return rc; return res;
} }
} }
@ -121,11 +121,11 @@ internal class DeliveryCacheStorageManager
if (!DisableStorage) if (!DisableStorage)
{ {
Result rc = Server.GetFsClient().Commit(new U8Span(mountName.Name)); Result res = Server.GetFsClient().Commit(new U8Span(mountName.Name));
if (rc.IsFailure()) if (res.IsFailure())
{ {
throw new HorizonResultException(rc, "Abort"); throw new HorizonResultException(res, "Abort");
} }
} }
} }
@ -141,19 +141,19 @@ internal class DeliveryCacheStorageManager
AppendMountName(ref sb, applicationId); AppendMountName(ref sb, applicationId);
sb.Append(RootPath); sb.Append(RootPath);
Result rc; Result res;
if (DisableStorage) if (DisableStorage)
{ {
size = 0x4400000; size = 0x4400000;
rc = Result.Success; res = Result.Success;
} }
else else
{ {
rc = Server.GetFsClient().GetFreeSpaceSize(out size, new U8Span(path)); res = Server.GetFsClient().GetFreeSpaceSize(out size, new U8Span(path));
} }
return rc; return res;
} }
} }

View File

@ -38,8 +38,8 @@ internal class DeliveryCacheDirectoryService : IDeliveryCacheDirectoryService
return ResultBcat.AlreadyOpen.Log(); return ResultBcat.AlreadyOpen.Log();
var metaReader = new DeliveryCacheFileMetaAccessor(Server); var metaReader = new DeliveryCacheFileMetaAccessor(Server);
Result rc = metaReader.ReadApplicationFileMeta(ApplicationId, ref name, false); Result res = metaReader.ReadApplicationFileMeta(ApplicationId, ref name, false);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
Count = metaReader.Count; Count = metaReader.Count;
_name = name; _name = name;
@ -59,18 +59,18 @@ internal class DeliveryCacheDirectoryService : IDeliveryCacheDirectoryService
return ResultBcat.NotOpen.Log(); return ResultBcat.NotOpen.Log();
var metaReader = new DeliveryCacheFileMetaAccessor(Server); var metaReader = new DeliveryCacheFileMetaAccessor(Server);
Result rc = metaReader.ReadApplicationFileMeta(ApplicationId, ref _name, true); Result res = metaReader.ReadApplicationFileMeta(ApplicationId, ref _name, true);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
int i; int i;
for (i = 0; i < entryBuffer.Length; i++) for (i = 0; i < entryBuffer.Length; i++)
{ {
rc = metaReader.GetEntry(out DeliveryCacheFileMetaEntry entry, i); res = metaReader.GetEntry(out DeliveryCacheFileMetaEntry entry, i);
if (rc.IsFailure()) if (res.IsFailure())
{ {
if (!ResultBcat.NotFound.Includes(rc)) if (!ResultBcat.NotFound.Includes(res))
return rc; return res;
break; break;
} }

View File

@ -43,17 +43,17 @@ internal class DeliveryCacheFileService : IDeliveryCacheFileService
return ResultBcat.AlreadyOpen.Log(); return ResultBcat.AlreadyOpen.Log();
var metaReader = new DeliveryCacheFileMetaAccessor(Server); var metaReader = new DeliveryCacheFileMetaAccessor(Server);
Result rc = metaReader.ReadApplicationFileMeta(ApplicationId, ref directoryName, true); Result res = metaReader.ReadApplicationFileMeta(ApplicationId, ref directoryName, true);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = metaReader.FindEntry(out DeliveryCacheFileMetaEntry entry, ref fileName); res = metaReader.FindEntry(out DeliveryCacheFileMetaEntry entry, ref fileName);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
Span<byte> filePath = stackalloc byte[0x80]; Span<byte> filePath = stackalloc byte[0x80];
Server.GetStorageManager().GetFilePath(filePath, ApplicationId, ref directoryName, ref fileName); Server.GetStorageManager().GetFilePath(filePath, ApplicationId, ref directoryName, ref fileName);
rc = Server.GetFsClient().OpenFile(out _handle, new U8Span(filePath), OpenMode.Read); res = Server.GetFsClient().OpenFile(out _handle, new U8Span(filePath), OpenMode.Read);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
_metaEntry = entry; _metaEntry = entry;
IsFileOpen = true; IsFileOpen = true;
@ -71,8 +71,8 @@ internal class DeliveryCacheFileService : IDeliveryCacheFileService
if (!IsFileOpen) if (!IsFileOpen)
return ResultBcat.NotOpen.Log(); return ResultBcat.NotOpen.Log();
Result rc = Server.GetFsClient().ReadFile(out long read, _handle, offset, destination); Result res = Server.GetFsClient().ReadFile(out long read, _handle, offset, destination);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
bytesRead = read; bytesRead = read;
return Result.Success; return Result.Success;

View File

@ -60,18 +60,18 @@ internal class DeliveryCacheStorageService : IDeliveryCacheStorageService
lock (Locker) lock (Locker)
{ {
var metaReader = new DeliveryCacheDirectoryMetaAccessor(Server); var metaReader = new DeliveryCacheDirectoryMetaAccessor(Server);
Result rc = metaReader.ReadApplicationDirectoryMeta(ApplicationId, true); Result res = metaReader.ReadApplicationDirectoryMeta(ApplicationId, true);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
int i; int i;
for (i = 0; i < nameBuffer.Length; i++) for (i = 0; i < nameBuffer.Length; i++)
{ {
rc = metaReader.GetEntry(out DeliveryCacheDirectoryMetaEntry entry, i); res = metaReader.GetEntry(out DeliveryCacheDirectoryMetaEntry entry, i);
if (rc.IsFailure()) if (res.IsFailure())
{ {
if (!ResultBcat.NotFound.Includes(rc)) if (!ResultBcat.NotFound.Includes(res))
return rc; return res;
break; break;
} }

View File

@ -25,11 +25,11 @@ internal class ServiceCreator : IServiceCreator
public Result CreateDeliveryCacheStorageService(ref SharedRef<IDeliveryCacheStorageService> outService, public Result CreateDeliveryCacheStorageService(ref SharedRef<IDeliveryCacheStorageService> outService,
ulong processId) ulong processId)
{ {
Result rc = Server.Hos.Arp.GetApplicationLaunchProperty(out ApplicationLaunchProperty launchProperty, Result res = Server.Hos.Arp.GetApplicationLaunchProperty(out ApplicationLaunchProperty launchProperty,
processId); processId);
if (rc.IsFailure()) if (res.IsFailure())
return ResultBcat.NotFound.LogConverted(rc); return ResultBcat.NotFound.LogConverted(res);
return CreateDeliveryCacheStorageServiceImpl(ref outService, launchProperty.ApplicationId); return CreateDeliveryCacheStorageServiceImpl(ref outService, launchProperty.ApplicationId);
} }
@ -46,8 +46,8 @@ internal class ServiceCreator : IServiceCreator
private Result CreateDeliveryCacheStorageServiceImpl(ref SharedRef<IDeliveryCacheStorageService> outService, private Result CreateDeliveryCacheStorageServiceImpl(ref SharedRef<IDeliveryCacheStorageService> outService,
ApplicationId applicationId) ApplicationId applicationId)
{ {
Result rc = Server.GetStorageManager().Open(applicationId.Value); Result res = Server.GetStorageManager().Open(applicationId.Value);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// todo: Check if network account required // todo: Check if network account required

View File

@ -108,40 +108,40 @@ public class Package1
_baseStorage.SetByCopy(in storage); _baseStorage.SetByCopy(in storage);
// Read what might be a mariko header and check if it actually is a mariko header // Read what might be a mariko header and check if it actually is a mariko header
Result rc = _baseStorage.Get.Read(0, SpanHelpers.AsByteSpan(ref _marikoOemHeader)); Result res = _baseStorage.Get.Read(0, SpanHelpers.AsByteSpan(ref _marikoOemHeader));
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
IsMariko = IsMarikoImpl(); IsMariko = IsMarikoImpl();
if (IsMariko) if (IsMariko)
{ {
rc = InitMarikoBodyStorage(); res = InitMarikoBodyStorage();
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
else else
{ {
rc = _baseStorage.Get.GetSize(out long baseStorageSize); res = _baseStorage.Get.GetSize(out long baseStorageSize);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
_bodyStorage = new SubStorage(in _baseStorage, 0, baseStorageSize); _bodyStorage = new SubStorage(in _baseStorage, 0, baseStorageSize);
rc = _bodyStorage.Read(0, SpanHelpers.AsByteSpan(ref _metaData)); res = _bodyStorage.Read(0, SpanHelpers.AsByteSpan(ref _metaData));
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
rc = ParseStage1(); res = ParseStage1();
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = ReadPk11Header(); res = ReadPk11Header();
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!IsMariko && IsModern) if (!IsMariko && IsModern)
{ {
rc = ReadModernEristaMac(); res = ReadModernEristaMac();
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
rc = SetPk11Storage(); res = SetPk11Storage();
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Make sure the PK11 section sizes add up to the expected size // Make sure the PK11 section sizes add up to the expected size
if (IsDecrypted && !VerifyPk11Sizes()) if (IsDecrypted && !VerifyPk11Sizes())
@ -165,8 +165,8 @@ public class Package1
return ResultLibHac.InvalidPackage1MarikoBodySize.Log(); return ResultLibHac.InvalidPackage1MarikoBodySize.Log();
// Verify the body storage size is not smaller than the size in the header // Verify the body storage size is not smaller than the size in the header
Result rc = _baseStorage.Get.GetSize(out long totalSize); Result res = _baseStorage.Get.GetSize(out long totalSize);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
long bodySize = totalSize - Unsafe.SizeOf<Package1MarikoOemHeader>(); long bodySize = totalSize - Unsafe.SizeOf<Package1MarikoOemHeader>();
if (bodySize < MarikoOemHeader.Size) if (bodySize < MarikoOemHeader.Size)
@ -180,8 +180,8 @@ public class Package1
Span<byte> metaData2 = SpanHelpers.AsByteSpan(ref metaData[1]); Span<byte> metaData2 = SpanHelpers.AsByteSpan(ref metaData[1]);
// Read both the plaintext metadata and encrypted metadata // Read both the plaintext metadata and encrypted metadata
rc = bodySubStorage.Read(0, MemoryMarshal.Cast<Package1MetaData, byte>(metaData)); res = bodySubStorage.Read(0, MemoryMarshal.Cast<Package1MetaData, byte>(metaData));
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Set the body storage and decrypted metadata // Set the body storage and decrypted metadata
_metaData = metaData[0]; _metaData = metaData[0];
@ -233,8 +233,8 @@ public class Package1
// Read the package1ldr footer // Read the package1ldr footer
int footerOffset = stage1Size - Unsafe.SizeOf<Package1Stage1Footer>(); int footerOffset = stage1Size - Unsafe.SizeOf<Package1Stage1Footer>();
Result rc = _bodyStorage.Read(footerOffset, SpanHelpers.AsByteSpan(ref _stage1Footer)); Result res = _bodyStorage.Read(footerOffset, SpanHelpers.AsByteSpan(ref _stage1Footer));
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Get the PK11 size from the field in the unencrypted stage 1 footer // Get the PK11 size from the field in the unencrypted stage 1 footer
Pk11Size = _stage1Footer.Pk11Size; Pk11Size = _stage1Footer.Pk11Size;
@ -259,8 +259,8 @@ public class Package1
// Read the PK11 header from the body storage // Read the PK11 header from the body storage
int pk11Offset = IsModern ? ModernStage1Size : LegacyStage1Size; int pk11Offset = IsModern ? ModernStage1Size : LegacyStage1Size;
Result rc = _bodyStorage.Read(pk11Offset, SpanHelpers.AsByteSpan(ref _pk11Header)); Result res = _bodyStorage.Read(pk11Offset, SpanHelpers.AsByteSpan(ref _pk11Header));
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Check if PK11 is already decrypted, creating the PK11 storage if it is // Check if PK11 is already decrypted, creating the PK11 storage if it is
IsDecrypted = _pk11Header.Magic == Package1Pk11Header.ExpectedMagic; IsDecrypted = _pk11Header.Magic == Package1Pk11Header.ExpectedMagic;

View File

@ -39,8 +39,8 @@ public class Package2StorageReader : IDisposable
/// <returns>The <see cref="Result"/> of the operation.</returns> /// <returns>The <see cref="Result"/> of the operation.</returns>
public Result Initialize(KeySet keySet, in SharedRef<IStorage> storage) public Result Initialize(KeySet keySet, in SharedRef<IStorage> storage)
{ {
Result rc = storage.Get.Read(0, SpanHelpers.AsByteSpan(ref _header)); Result res = storage.Get.Read(0, SpanHelpers.AsByteSpan(ref _header));
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
_key = keySet.Package2Keys[_header.Meta.GetKeyGeneration()]; _key = keySet.Package2Keys[_header.Meta.GetKeyGeneration()];
DecryptHeader(_key, ref _header.Meta, ref _header.Meta); DecryptHeader(_key, ref _header.Meta, ref _header.Meta);
@ -105,8 +105,8 @@ public class Package2StorageReader : IDisposable
// Ini is embedded in the kernel // Ini is embedded in the kernel
using var kernelStorage = new UniqueRef<IStorage>(); using var kernelStorage = new UniqueRef<IStorage>();
Result rc = OpenKernel(ref kernelStorage.Ref()); Result res = OpenKernel(ref kernelStorage.Ref());
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!IniExtract.TryGetIni1Offset(out int offset, out int size, kernelStorage.Get)) if (!IniExtract.TryGetIni1Offset(out int offset, out int size, kernelStorage.Get))
{ {
@ -124,11 +124,11 @@ public class Package2StorageReader : IDisposable
/// <returns>The <see cref="Result"/> of the operation.</returns> /// <returns>The <see cref="Result"/> of the operation.</returns>
public Result Verify() public Result Verify()
{ {
Result rc = VerifySignature(); Result res = VerifySignature();
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = VerifyMeta(); res = VerifyMeta();
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return VerifyPayloads(); return VerifyPayloads();
} }
@ -143,8 +143,8 @@ public class Package2StorageReader : IDisposable
Unsafe.SkipInit(out Package2Meta meta); Unsafe.SkipInit(out Package2Meta meta);
Span<byte> metaBytes = SpanHelpers.AsByteSpan(ref meta); Span<byte> metaBytes = SpanHelpers.AsByteSpan(ref meta);
Result rc = _storage.Get.Read(Package2Header.SignatureSize, metaBytes); Result res = _storage.Get.Read(Package2Header.SignatureSize, metaBytes);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return _header.VerifySignature(_keySet.Package2SigningKeyParams.Modulus, metaBytes); return _header.VerifySignature(_keySet.Package2SigningKeyParams.Modulus, metaBytes);
} }
@ -188,8 +188,8 @@ public class Package2StorageReader : IDisposable
int toRead = Math.Min(array.Length, size); int toRead = Math.Min(array.Length, size);
Span<byte> span = array.AsSpan(0, toRead); Span<byte> span = array.AsSpan(0, toRead);
Result rc = payloadSubStorage.Read(offset, span); Result res = payloadSubStorage.Read(offset, span);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
sha.Update(span); sha.Update(span);
@ -243,8 +243,8 @@ public class Package2StorageReader : IDisposable
continue; continue;
using var payloadStorage = new UniqueRef<IStorage>(); using var payloadStorage = new UniqueRef<IStorage>();
Result rc = OpenPayload(ref payloadStorage.Ref(), i); Result res = OpenPayload(ref payloadStorage.Ref(), i);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
storages.Add(payloadStorage.Release()); storages.Add(payloadStorage.Release());
} }

View File

@ -66,9 +66,9 @@ namespace LibHac.Fs
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.GetGlobalAccessLogMode(out mode); Result res = fileSystemProxy.Get.GetGlobalAccessLogMode(out mode);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static Result SetGlobalAccessLogMode(this FileSystemClient fs, GlobalAccessLogMode mode) public static Result SetGlobalAccessLogMode(this FileSystemClient fs, GlobalAccessLogMode mode)
@ -82,9 +82,9 @@ namespace LibHac.Fs
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.SetGlobalAccessLogMode(mode); Result res = fileSystemProxy.Get.SetGlobalAccessLogMode(mode);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static void SetLocalAccessLog(this FileSystemClient fs, bool enabled) public static void SetLocalAccessLog(this FileSystemClient fs, bool enabled)
@ -503,8 +503,8 @@ namespace LibHac.Fs.Impl
private static void GetProgramIndexForAccessLog(FileSystemClientImpl fs, out int index, out int count) private static void GetProgramIndexForAccessLog(FileSystemClientImpl fs, out int index, out int count)
{ {
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.GetProgramIndexForAccessLog(out index, out count); Result res = fileSystemProxy.Get.GetProgramIndexForAccessLog(out index, out count);
Abort.DoAbortUnless(rc.IsSuccess()); Abort.DoAbortUnless(res.IsSuccess());
} }
private static void OutputAccessLogStart(FileSystemClientImpl fs) private static void OutputAccessLogStart(FileSystemClientImpl fs)
@ -713,9 +713,9 @@ namespace LibHac.Fs.Impl
} }
else else
{ {
Result rc = fs.Fs.GetGlobalAccessLogMode(out g.GlobalAccessLogMode); Result res = fs.Fs.GetGlobalAccessLogMode(out g.GlobalAccessLogMode);
fs.LogResultErrorMessage(rc); fs.LogResultErrorMessage(res);
if (rc.IsFailure()) Abort.DoAbort(rc); if (res.IsFailure()) Abort.DoAbort(res);
if (g.GlobalAccessLogMode != GlobalAccessLogMode.None) if (g.GlobalAccessLogMode != GlobalAccessLogMode.None)
{ {
@ -771,9 +771,9 @@ namespace LibHac.Fs.Impl
internal static bool IsEnabledFileSystemAccessorAccessLog(this FileSystemClientImpl fs, U8Span mountName) internal static bool IsEnabledFileSystemAccessorAccessLog(this FileSystemClientImpl fs, U8Span mountName)
{ {
Result rc = fs.Find(out FileSystemAccessor accessor, mountName); Result res = fs.Find(out FileSystemAccessor accessor, mountName);
if (rc.IsFailure()) if (res.IsFailure())
return true; return true;
return accessor.IsEnabledAccessLog(); return accessor.IsEnabledAccessLog();
@ -781,9 +781,9 @@ namespace LibHac.Fs.Impl
public static void EnableFileSystemAccessorAccessLog(this FileSystemClientImpl fs, U8Span mountName) public static void EnableFileSystemAccessorAccessLog(this FileSystemClientImpl fs, U8Span mountName)
{ {
Result rc = fs.Find(out FileSystemAccessor fileSystem, mountName); Result res = fs.Find(out FileSystemAccessor fileSystem, mountName);
fs.LogResultErrorMessage(rc); fs.LogResultErrorMessage(res);
Abort.DoAbortUnless(rc.IsSuccess()); Abort.DoAbortUnless(res.IsSuccess());
fileSystem.SetAccessLog(true); fileSystem.SetAccessLog(true);
} }

View File

@ -38,11 +38,11 @@ public static class ApplicationSaveDataManagement
// ReSharper disable HeuristicUnreachableCode // ReSharper disable HeuristicUnreachableCode
// Get the current save data size // Get the current save data size
Result rc = fs.Impl.GetSaveDataAvailableSize(out long availableSize, spaceId, saveDataId); Result res = fs.Impl.GetSaveDataAvailableSize(out long availableSize, spaceId, saveDataId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = fs.Impl.GetSaveDataJournalSize(out long journalSize, spaceId, saveDataId); res = fs.Impl.GetSaveDataJournalSize(out long journalSize, spaceId, saveDataId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
// Check if the save data needs to be extended // Check if the save data needs to be extended
if (availableSize < saveDataSize || journalSize < saveDataJournalSize) if (availableSize < saveDataSize || journalSize < saveDataJournalSize)
@ -57,18 +57,18 @@ public static class ApplicationSaveDataManagement
long newSaveDataSize = Math.Max(saveDataSize, availableSize); long newSaveDataSize = Math.Max(saveDataSize, availableSize);
long newSaveDataJournalSize = Math.Max(saveDataJournalSize, journalSize); long newSaveDataJournalSize = Math.Max(saveDataJournalSize, journalSize);
rc = fs.Impl.ExtendSaveData(spaceId, saveDataId, newSaveDataSize, newSaveDataJournalSize); res = fs.Impl.ExtendSaveData(spaceId, saveDataId, newSaveDataSize, newSaveDataJournalSize);
if (rc.IsFailure()) if (res.IsFailure())
{ {
if (ResultFs.UsableSpaceNotEnough.Includes(rc)) if (ResultFs.UsableSpaceNotEnough.Includes(res))
{ {
// Calculate how much space we need to extend the save data // Calculate how much space we need to extend the save data
rc = fs.QuerySaveDataTotalSize(out long currentSaveDataTotalSize, availableSize, journalSize); res = fs.QuerySaveDataTotalSize(out long currentSaveDataTotalSize, availableSize, journalSize);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = fs.QuerySaveDataTotalSize(out long newSaveDataTotalSize, newSaveDataSize, newSaveDataJournalSize); res = fs.QuerySaveDataTotalSize(out long newSaveDataTotalSize, newSaveDataSize, newSaveDataJournalSize);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
long newSaveDataSizeDifference = RoundUpOccupationSize(newSaveDataTotalSize) - long newSaveDataSizeDifference = RoundUpOccupationSize(newSaveDataTotalSize) -
RoundUpOccupationSize(currentSaveDataTotalSize); RoundUpOccupationSize(currentSaveDataTotalSize);
@ -80,7 +80,7 @@ public static class ApplicationSaveDataManagement
return ResultFs.UsableSpaceNotEnough.Log(); return ResultFs.UsableSpaceNotEnough.Log();
} }
return rc.Miss(); return res.Miss();
} }
} }
@ -92,21 +92,21 @@ public static class ApplicationSaveDataManagement
private static Result CreateSaveData(FileSystemClient fs, ref long inOutRequiredSize, Func<Result> createFunc, private static Result CreateSaveData(FileSystemClient fs, ref long inOutRequiredSize, Func<Result> createFunc,
long saveDataSize, long saveDataJournalSize, long saveDataBaseSize) long saveDataSize, long saveDataJournalSize, long saveDataBaseSize)
{ {
Result rc = createFunc(); Result res = createFunc();
if (rc.IsSuccess()) if (res.IsSuccess())
return Result.Success; return Result.Success;
if (ResultFs.UsableSpaceNotEnough.Includes(rc)) if (ResultFs.UsableSpaceNotEnough.Includes(res))
{ {
rc = fs.QuerySaveDataTotalSize(out long saveDataTotalSize, saveDataSize, saveDataJournalSize); res = fs.QuerySaveDataTotalSize(out long saveDataTotalSize, saveDataSize, saveDataJournalSize);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
inOutRequiredSize += RoundUpOccupationSize(saveDataTotalSize) + saveDataBaseSize; inOutRequiredSize += RoundUpOccupationSize(saveDataTotalSize) + saveDataBaseSize;
} }
else if (!ResultFs.PathAlreadyExists.Includes(rc)) else if (!ResultFs.PathAlreadyExists.Includes(res))
{ {
return rc.Miss(); return res.Miss();
} }
return Result.Success; return Result.Success;
@ -116,30 +116,30 @@ public static class ApplicationSaveDataManagement
in SaveDataFilter filter, Func<Result> createFunc, long saveDataSize, long saveDataJournalSize, in SaveDataFilter filter, Func<Result> createFunc, long saveDataSize, long saveDataJournalSize,
long saveDataBaseSize) long saveDataBaseSize)
{ {
Result rc = fs.FindSaveDataWithFilter(out SaveDataInfo info, SaveDataSpaceId.User, in filter); Result res = fs.FindSaveDataWithFilter(out SaveDataInfo info, SaveDataSpaceId.User, in filter);
if (rc.IsFailure()) if (res.IsFailure())
{ {
if (ResultFs.TargetNotFound.Includes(rc)) if (ResultFs.TargetNotFound.Includes(res))
{ {
rc = CreateSaveData(fs, ref inOutRequiredSize, createFunc, saveDataSize, saveDataJournalSize, res = CreateSaveData(fs, ref inOutRequiredSize, createFunc, saveDataSize, saveDataJournalSize,
saveDataBaseSize); saveDataBaseSize);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
return rc.Miss(); return res.Miss();
} }
long requiredSize = 0; long requiredSize = 0;
rc = ExtendSaveDataIfNeeded(fs, ref requiredSize, SaveDataSpaceId.User, info.SaveDataId, saveDataSize, res = ExtendSaveDataIfNeeded(fs, ref requiredSize, SaveDataSpaceId.User, info.SaveDataId, saveDataSize,
saveDataJournalSize); saveDataJournalSize);
if (rc.IsFailure()) if (res.IsFailure())
{ {
if (!ResultFs.UsableSpaceNotEnough.Includes(rc)) if (!ResultFs.UsableSpaceNotEnough.Includes(res))
return rc.Miss(); return res.Miss();
inOutRequiredSize += requiredSize; inOutRequiredSize += requiredSize;
} }
@ -210,15 +210,15 @@ public static class ApplicationSaveDataManagement
if (bcatDeliveryCacheStorageSize > 0) if (bcatDeliveryCacheStorageSize > 0)
{ {
Result rc = SaveDataFilter.Make(out SaveDataFilter filter, programId: default, SaveDataType.Bcat, Result res = SaveDataFilter.Make(out SaveDataFilter filter, programId: default, SaveDataType.Bcat,
userId: default, saveDataId: default, index: default); userId: default, saveDataId: default, index: default);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
Result CreateBcatStorageFunc() => fs.CreateBcatSaveData(applicationId, bcatDeliveryCacheStorageSize); Result CreateBcatStorageFunc() => fs.CreateBcatSaveData(applicationId, bcatDeliveryCacheStorageSize);
rc = EnsureAndExtendSaveData(fs, ref requiredSize, in filter, CreateBcatStorageFunc, res = EnsureAndExtendSaveData(fs, ref requiredSize, in filter, CreateBcatStorageFunc,
bcatDeliveryCacheStorageSize, bcatDeliveryCacheJournalSize, 0x4000); bcatDeliveryCacheStorageSize, bcatDeliveryCacheJournalSize, 0x4000);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
} }
if (requiredSize == 0) if (requiredSize == 0)
@ -235,12 +235,12 @@ public static class ApplicationSaveDataManagement
Ncm.ApplicationId applicationId) Ncm.ApplicationId applicationId)
{ {
UnsafeHelpers.SkipParamInit(out targetMedia); UnsafeHelpers.SkipParamInit(out targetMedia);
Result rc; Result res;
if (fs.IsSdCardAccessible()) if (fs.IsSdCardAccessible())
{ {
rc = DoesCacheStorageExist(out bool existsOnSd, SaveDataSpaceId.SdUser, fs, applicationId); res = DoesCacheStorageExist(out bool existsOnSd, SaveDataSpaceId.SdUser, fs, applicationId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
if (existsOnSd) if (existsOnSd)
{ {
@ -249,8 +249,8 @@ public static class ApplicationSaveDataManagement
} }
} }
rc = DoesCacheStorageExist(out bool existsOnNand, SaveDataSpaceId.User, fs, applicationId); res = DoesCacheStorageExist(out bool existsOnNand, SaveDataSpaceId.User, fs, applicationId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
targetMedia = existsOnNand ? CacheStorageTargetMedia.Nand : CacheStorageTargetMedia.None; targetMedia = existsOnNand ? CacheStorageTargetMedia.Nand : CacheStorageTargetMedia.None;
return Result.Success; return Result.Success;
@ -262,16 +262,16 @@ public static class ApplicationSaveDataManagement
bool doesStorageExist = true; bool doesStorageExist = true;
Result rc = SaveDataFilter.Make(out SaveDataFilter filter, applicationId.Value, SaveDataType.Cache, Result res = SaveDataFilter.Make(out SaveDataFilter filter, applicationId.Value, SaveDataType.Cache,
userId: default, saveDataId: default, index: default); userId: default, saveDataId: default, index: default);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = fs.Impl.FindSaveDataWithFilter(out SaveDataInfo _, spaceId, in filter); res = fs.Impl.FindSaveDataWithFilter(out SaveDataInfo _, spaceId, in filter);
if (rc.IsFailure()) if (res.IsFailure())
{ {
if (!ResultFs.TargetNotFound.Includes(rc)) if (!ResultFs.TargetNotFound.Includes(res))
return rc.Miss(); return res.Miss();
doesStorageExist = false; doesStorageExist = false;
} }
@ -287,26 +287,26 @@ public static class ApplicationSaveDataManagement
{ {
long requiredSize = 0; long requiredSize = 0;
Result rc = SaveDataFilter.Make(out SaveDataFilter filter, applicationId.Value, SaveDataType.Cache, Result res = SaveDataFilter.Make(out SaveDataFilter filter, applicationId.Value, SaveDataType.Cache,
userId: default, saveDataId: default, index); userId: default, saveDataId: default, index);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
// Check if the cache storage already exists or not. // Check if the cache storage already exists or not.
bool doesStorageExist = true; bool doesStorageExist = true;
rc = fs.Impl.FindSaveDataWithFilter(out SaveDataInfo info, spaceId, in filter); res = fs.Impl.FindSaveDataWithFilter(out SaveDataInfo info, spaceId, in filter);
if (rc.IsFailure()) if (res.IsFailure())
{ {
if (ResultFs.TargetNotFound.Includes(rc)) if (ResultFs.TargetNotFound.Includes(res))
{ {
doesStorageExist = false; doesStorageExist = false;
} }
else else
{ {
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc.Miss(); return res.Miss();
} }
} }
@ -315,32 +315,32 @@ public static class ApplicationSaveDataManagement
// The cache storage already exists. Ensure it's large enough. // The cache storage already exists. Ensure it's large enough.
if (!allowExisting) if (!allowExisting)
{ {
rc = ResultFs.AlreadyExists.Value; res = ResultFs.AlreadyExists.Value;
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc.Miss(); return res.Miss();
} }
rc = ExtendSaveDataIfNeeded(fs, ref requiredSize, spaceId, info.SaveDataId, cacheStorageSize, res = ExtendSaveDataIfNeeded(fs, ref requiredSize, spaceId, info.SaveDataId, cacheStorageSize,
cacheStorageJournalSize); cacheStorageJournalSize);
if (rc.IsFailure()) if (res.IsFailure())
{ {
if (ResultFs.UsableSpaceNotEnough.Includes(rc)) if (ResultFs.UsableSpaceNotEnough.Includes(res))
{ {
// Don't return this error. If there's not enough space we return Success along with // Don't return this error. If there's not enough space we return Success along with
// The amount of space required to create the cache storage. // The amount of space required to create the cache storage.
} }
else if (ResultFs.SaveDataExtending.Includes(rc)) else if (ResultFs.SaveDataExtending.Includes(res))
{ {
rc = ResultFs.SaveDataCorrupted.LogConverted(rc); res = ResultFs.SaveDataCorrupted.LogConverted(res);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc.Miss(); return res.Miss();
} }
else else
{ {
rc.Miss(); res.Miss();
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
} }
} }
@ -350,11 +350,11 @@ public static class ApplicationSaveDataManagement
Result CreateCacheFunc() => fs.CreateCacheStorage(applicationId, spaceId, saveDataOwnerId, index, Result CreateCacheFunc() => fs.CreateCacheStorage(applicationId, spaceId, saveDataOwnerId, index,
cacheStorageSize, cacheStorageJournalSize, SaveDataFlags.None); cacheStorageSize, cacheStorageJournalSize, SaveDataFlags.None);
rc = CreateSaveData(fs, ref requiredSize, CreateCacheFunc, cacheStorageSize, cacheStorageJournalSize, res = CreateSaveData(fs, ref requiredSize, CreateCacheFunc, cacheStorageSize, cacheStorageJournalSize,
0x4000); 0x4000);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
} }
outRequiredSize = requiredSize; outRequiredSize = requiredSize;
@ -369,26 +369,26 @@ public static class ApplicationSaveDataManagement
long requiredSize = 0; long requiredSize = 0;
// Check if the cache storage already exists // Check if the cache storage already exists
Result rc = GetCacheStorageTargetMediaImpl(fs, out CacheStorageTargetMedia media, applicationId); Result res = GetCacheStorageTargetMediaImpl(fs, out CacheStorageTargetMedia media, applicationId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
if (media == CacheStorageTargetMedia.SdCard) if (media == CacheStorageTargetMedia.SdCard)
{ {
// If it exists on the SD card, ensure it's large enough. // If it exists on the SD card, ensure it's large enough.
targetMedia = CacheStorageTargetMedia.SdCard; targetMedia = CacheStorageTargetMedia.SdCard;
rc = TryCreateCacheStorage(fs, ref requiredSize, SaveDataSpaceId.SdUser, applicationId, saveDataOwnerId, res = TryCreateCacheStorage(fs, ref requiredSize, SaveDataSpaceId.SdUser, applicationId, saveDataOwnerId,
index, cacheStorageSize, cacheStorageJournalSize, allowExisting); index, cacheStorageSize, cacheStorageJournalSize, allowExisting);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
} }
else if (media == CacheStorageTargetMedia.Nand) else if (media == CacheStorageTargetMedia.Nand)
{ {
// If it exists on the BIS, ensure it's large enough. // If it exists on the BIS, ensure it's large enough.
targetMedia = CacheStorageTargetMedia.Nand; targetMedia = CacheStorageTargetMedia.Nand;
rc = TryCreateCacheStorage(fs, ref requiredSize, SaveDataSpaceId.User, applicationId, saveDataOwnerId, res = TryCreateCacheStorage(fs, ref requiredSize, SaveDataSpaceId.User, applicationId, saveDataOwnerId,
index, cacheStorageSize, cacheStorageJournalSize, allowExisting); index, cacheStorageSize, cacheStorageJournalSize, allowExisting);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
} }
else else
{ {
@ -401,9 +401,9 @@ public static class ApplicationSaveDataManagement
Result CreateStorageOnSdCard() => fs.CreateCacheStorage(applicationId, SaveDataSpaceId.SdUser, Result CreateStorageOnSdCard() => fs.CreateCacheStorage(applicationId, SaveDataSpaceId.SdUser,
saveDataOwnerId, index, cacheStorageSize, cacheStorageJournalSize, SaveDataFlags.None); saveDataOwnerId, index, cacheStorageSize, cacheStorageJournalSize, SaveDataFlags.None);
rc = CreateSaveData(fs, ref requiredSize, CreateStorageOnSdCard, cacheStorageSize, cacheStorageJournalSize, res = CreateSaveData(fs, ref requiredSize, CreateStorageOnSdCard, cacheStorageSize, cacheStorageJournalSize,
0x4000); 0x4000);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
// Don't use the SD card if it doesn't have enough space. // Don't use the SD card if it doesn't have enough space.
if (requiredSize != 0) if (requiredSize != 0)
@ -419,9 +419,9 @@ public static class ApplicationSaveDataManagement
Result CreateStorageOnNand() => fs.CreateCacheStorage(applicationId, SaveDataSpaceId.User, saveDataOwnerId, Result CreateStorageOnNand() => fs.CreateCacheStorage(applicationId, SaveDataSpaceId.User, saveDataOwnerId,
index, cacheStorageSize, cacheStorageSize, SaveDataFlags.None); index, cacheStorageSize, cacheStorageSize, SaveDataFlags.None);
rc = CreateSaveData(fs, ref requiredSize, CreateStorageOnNand, cacheStorageSize, cacheStorageJournalSize, res = CreateSaveData(fs, ref requiredSize, CreateStorageOnNand, cacheStorageSize, cacheStorageJournalSize,
0x4000); 0x4000);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
if (requiredSize != 0) if (requiredSize != 0)
targetMedia = CacheStorageTargetMedia.None; targetMedia = CacheStorageTargetMedia.None;
@ -443,18 +443,18 @@ public static class ApplicationSaveDataManagement
long requiredSize = 0; long requiredSize = 0;
Result rc = SaveDataFilter.Make(out SaveDataFilter filter, applicationId.Value, SaveDataType.Device, Result res = SaveDataFilter.Make(out SaveDataFilter filter, applicationId.Value, SaveDataType.Device,
userId: default, saveDataId: default, index: default); userId: default, saveDataId: default, index: default);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
const SaveDataFlags flags = SaveDataFlags.None; const SaveDataFlags flags = SaveDataFlags.None;
Result CreateSave() => Result CreateSave() =>
fs.CreateDeviceSaveData(applicationId, applicationId.Value, saveDataSize, saveDataJournalSize, flags); fs.CreateDeviceSaveData(applicationId, applicationId.Value, saveDataSize, saveDataJournalSize, flags);
rc = EnsureAndExtendSaveData(fs.Fs, ref requiredSize, in filter, CreateSave, saveDataSize, saveDataJournalSize, res = EnsureAndExtendSaveData(fs.Fs, ref requiredSize, in filter, CreateSave, saveDataSize, saveDataJournalSize,
0x4000); 0x4000);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outRequiredSize = requiredSize; outRequiredSize = requiredSize;
return Result.Success; return Result.Success;
@ -463,9 +463,9 @@ public static class ApplicationSaveDataManagement
public static Result GetCacheStorageTargetMedia(this FileSystemClient fs, out CacheStorageTargetMedia targetMedia, public static Result GetCacheStorageTargetMedia(this FileSystemClient fs, out CacheStorageTargetMedia targetMedia,
Ncm.ApplicationId applicationId) Ncm.ApplicationId applicationId)
{ {
Result rc = GetCacheStorageTargetMediaImpl(fs, out targetMedia, applicationId); Result res = GetCacheStorageTargetMediaImpl(fs, out targetMedia, applicationId);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -476,11 +476,11 @@ public static class ApplicationSaveDataManagement
{ {
outRequiredSize = 0; outRequiredSize = 0;
Result rc = EnsureApplicationCacheStorageImpl(fs, ref outRequiredSize, out targetMedia, applicationId, Result res = EnsureApplicationCacheStorageImpl(fs, ref outRequiredSize, out targetMedia, applicationId,
saveDataOwnerId, index, cacheStorageSize, cacheStorageJournalSize, allowExisting); saveDataOwnerId, index, cacheStorageSize, cacheStorageJournalSize, allowExisting);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -490,12 +490,12 @@ public static class ApplicationSaveDataManagement
{ {
outRequiredSize = 0; outRequiredSize = 0;
Result rc = EnsureApplicationCacheStorageImpl(fs, ref outRequiredSize, out _, applicationId, Result res = EnsureApplicationCacheStorageImpl(fs, ref outRequiredSize, out _, applicationId,
controlProperty.SaveDataOwnerId, index: 0, controlProperty.CacheStorageSize, controlProperty.SaveDataOwnerId, index: 0, controlProperty.CacheStorageSize,
controlProperty.CacheStorageJournalSize, true); controlProperty.CacheStorageJournalSize, true);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -509,12 +509,12 @@ public static class ApplicationSaveDataManagement
if (controlProperty.CacheStorageSize > 0) if (controlProperty.CacheStorageSize > 0)
{ {
Result rc = EnsureApplicationCacheStorageImpl(fs, ref outRequiredSize, out targetMedia, applicationId, Result res = EnsureApplicationCacheStorageImpl(fs, ref outRequiredSize, out targetMedia, applicationId,
controlProperty.SaveDataOwnerId, index: 0, controlProperty.CacheStorageSize, controlProperty.SaveDataOwnerId, index: 0, controlProperty.CacheStorageSize,
controlProperty.CacheStorageJournalSize, true); controlProperty.CacheStorageJournalSize, true);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
} }
return Result.Success; return Result.Success;
@ -527,27 +527,27 @@ public static class ApplicationSaveDataManagement
{ {
UnsafeHelpers.SkipParamInit(out outRequiredSize, out targetMedia); UnsafeHelpers.SkipParamInit(out outRequiredSize, out targetMedia);
Result rc; Result res;
if (index > controlProperty.CacheStorageIndexMax) if (index > controlProperty.CacheStorageIndexMax)
{ {
rc = ResultFs.CacheStorageIndexTooLarge.Value; res = ResultFs.CacheStorageIndexTooLarge.Value;
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc.Miss(); return res.Miss();
} }
if (cacheStorageSize + cacheStorageJournalSize > controlProperty.CacheStorageDataAndJournalSizeMax) if (cacheStorageSize + cacheStorageJournalSize > controlProperty.CacheStorageDataAndJournalSizeMax)
{ {
rc = ResultFs.CacheStorageSizeTooLarge.Value; res = ResultFs.CacheStorageSizeTooLarge.Value;
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc.Miss(); return res.Miss();
} }
rc = EnsureApplicationCacheStorageImpl(fs, ref outRequiredSize, out targetMedia, applicationId, res = EnsureApplicationCacheStorageImpl(fs, ref outRequiredSize, out targetMedia, applicationId,
controlProperty.SaveDataOwnerId, index, cacheStorageSize, cacheStorageJournalSize, false); controlProperty.SaveDataOwnerId, index, cacheStorageSize, cacheStorageJournalSize, false);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -556,31 +556,31 @@ public static class ApplicationSaveDataManagement
{ {
while (true) while (true)
{ {
Result rc = SaveDataFilter.Make(out SaveDataFilter filter, programId: default, SaveDataType.Temporary, Result res = SaveDataFilter.Make(out SaveDataFilter filter, programId: default, SaveDataType.Temporary,
userId: default, saveDataId: default, index: default); userId: default, saveDataId: default, index: default);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
// Try to find any temporary save data. // Try to find any temporary save data.
rc = fs.Impl.FindSaveDataWithFilter(out SaveDataInfo info, SaveDataSpaceId.Temporary, in filter); res = fs.Impl.FindSaveDataWithFilter(out SaveDataInfo info, SaveDataSpaceId.Temporary, in filter);
if (rc.IsFailure()) if (res.IsFailure())
{ {
if (ResultFs.TargetNotFound.Includes(rc)) if (ResultFs.TargetNotFound.Includes(res))
{ {
// No more save data found. We're done cleaning. // No more save data found. We're done cleaning.
return Result.Success; return Result.Success;
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc.Miss(); return res.Miss();
} }
// Delete the found save data. // Delete the found save data.
rc = fs.Impl.DeleteSaveData(SaveDataSpaceId.Temporary, info.SaveDataId); res = fs.Impl.DeleteSaveData(SaveDataSpaceId.Temporary, info.SaveDataId);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
} }
} }
@ -589,11 +589,11 @@ public static class ApplicationSaveDataManagement
{ {
outRequiredSize = 0; outRequiredSize = 0;
Result rc = EnsureApplicationBcatDeliveryCacheStorageImpl(fs, ref outRequiredSize, applicationId, Result res = EnsureApplicationBcatDeliveryCacheStorageImpl(fs, ref outRequiredSize, applicationId,
in controlProperty); in controlProperty);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -604,9 +604,9 @@ public static class ApplicationSaveDataManagement
UnsafeHelpers.SkipParamInit(out outRequiredSize); UnsafeHelpers.SkipParamInit(out outRequiredSize);
using var prohibiter = new UniqueRef<SaveDataTransferProhibiterForCloudBackUp>(); using var prohibiter = new UniqueRef<SaveDataTransferProhibiterForCloudBackUp>();
Result rc = fs.Impl.OpenSaveDataTransferProhibiterForCloudBackUp(ref prohibiter.Ref(), applicationId); Result res = fs.Impl.OpenSaveDataTransferProhibiterForCloudBackUp(ref prohibiter.Ref(), applicationId);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
long requiredSize = 0; long requiredSize = 0;
@ -629,20 +629,20 @@ public static class ApplicationSaveDataManagement
} }
UserId userId = Unsafe.As<Uid, UserId>(ref Unsafe.AsRef(in user)); UserId userId = Unsafe.As<Uid, UserId>(ref Unsafe.AsRef(in user));
rc = SaveDataFilter.Make(out SaveDataFilter filter, applicationId.Value, SaveDataType.Account, userId, res = SaveDataFilter.Make(out SaveDataFilter filter, applicationId.Value, SaveDataType.Account, userId,
saveDataId: default, index: default); saveDataId: default, index: default);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
long baseSize = RoundUpOccupationSize(new SaveDataMetaPolicy(SaveDataType.Account).GetSaveDataMetaSize()) + long baseSize = RoundUpOccupationSize(new SaveDataMetaPolicy(SaveDataType.Account).GetSaveDataMetaSize()) +
0x8000; 0x8000;
rc = EnsureAndExtendSaveData(fs, ref requiredSize, in filter, CreateAccountSaveFunc, accountSaveDataSize, res = EnsureAndExtendSaveData(fs, ref requiredSize, in filter, CreateAccountSaveFunc, accountSaveDataSize,
accountSaveJournalSize, baseSize); accountSaveJournalSize, baseSize);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
} }
// Ensure the device save exists // Ensure the device save exists
@ -651,35 +651,35 @@ public static class ApplicationSaveDataManagement
Result CreateDeviceSaveFunc() => fs.Impl.CreateDeviceSaveData(applicationId, saveDataOwnerId, Result CreateDeviceSaveFunc() => fs.Impl.CreateDeviceSaveData(applicationId, saveDataOwnerId,
deviceSaveDataSize, deviceSaveJournalSize, SaveDataFlags.None); deviceSaveDataSize, deviceSaveJournalSize, SaveDataFlags.None);
rc = SaveDataFilter.Make(out SaveDataFilter filter, applicationId.Value, SaveDataType.Device, res = SaveDataFilter.Make(out SaveDataFilter filter, applicationId.Value, SaveDataType.Device,
userId: default, saveDataId: default, index: default); userId: default, saveDataId: default, index: default);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
long baseSize = RoundUpOccupationSize(new SaveDataMetaPolicy(SaveDataType.Device).GetSaveDataMetaSize()) + long baseSize = RoundUpOccupationSize(new SaveDataMetaPolicy(SaveDataType.Device).GetSaveDataMetaSize()) +
0x8000; 0x8000;
long requiredSizeForDeviceSaveData = 0; long requiredSizeForDeviceSaveData = 0;
rc = EnsureAndExtendSaveData(fs, ref requiredSizeForDeviceSaveData, in filter, CreateDeviceSaveFunc, res = EnsureAndExtendSaveData(fs, ref requiredSizeForDeviceSaveData, in filter, CreateDeviceSaveFunc,
deviceSaveDataSize, deviceSaveJournalSize, baseSize); deviceSaveDataSize, deviceSaveJournalSize, baseSize);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
if (requiredSizeForDeviceSaveData == 0) if (requiredSizeForDeviceSaveData == 0)
{ {
rc = fs.Impl.CreateDeviceSaveData(applicationId, saveDataOwnerId, deviceSaveDataSize, res = fs.Impl.CreateDeviceSaveData(applicationId, saveDataOwnerId, deviceSaveDataSize,
deviceSaveJournalSize, SaveDataFlags.None); deviceSaveJournalSize, SaveDataFlags.None);
if (rc.IsFailure()) if (res.IsFailure())
{ {
if (ResultFs.PathAlreadyExists.Includes(rc)) if (ResultFs.PathAlreadyExists.Includes(res))
{ {
// Nothing to do if the save already exists. // Nothing to do if the save already exists.
rc.Catch().Handle(); res.Catch().Handle();
} }
else if (ResultFs.UsableSpaceNotEnough.Includes(rc)) else if (ResultFs.UsableSpaceNotEnough.Includes(res))
{ {
requiredSizeForDeviceSaveData += requiredSizeForDeviceSaveData +=
RoundUpOccupationSize(new SaveDataMetaPolicy(SaveDataType.Device).GetSaveDataMetaSize()) + RoundUpOccupationSize(new SaveDataMetaPolicy(SaveDataType.Device).GetSaveDataMetaSize()) +
@ -687,8 +687,8 @@ public static class ApplicationSaveDataManagement
} }
else else
{ {
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc.Miss(); return res.Miss();
} }
} }
} }
@ -697,19 +697,19 @@ public static class ApplicationSaveDataManagement
} }
long requiredSizeForBcat = 0; long requiredSizeForBcat = 0;
rc = EnsureApplicationBcatDeliveryCacheStorageImpl(fs, ref requiredSizeForBcat, applicationId, res = EnsureApplicationBcatDeliveryCacheStorageImpl(fs, ref requiredSizeForBcat, applicationId,
in controlProperty); in controlProperty);
if (rc.IsFailure()) if (res.IsFailure())
{ {
if (ResultFs.UsableSpaceNotEnough.Includes(rc)) if (ResultFs.UsableSpaceNotEnough.Includes(res))
{ {
requiredSize += requiredSizeForBcat; requiredSize += requiredSizeForBcat;
} }
else else
{ {
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc.Miss(); return res.Miss();
} }
} }
@ -720,9 +720,9 @@ public static class ApplicationSaveDataManagement
{ {
UnsafeHelpers.SkipParamInit(out requiredSize); UnsafeHelpers.SkipParamInit(out requiredSize);
Result rc = fs.Impl.QuerySaveDataTotalSize(out long saveDataTotalSize, Result res = fs.Impl.QuerySaveDataTotalSize(out long saveDataTotalSize,
controlProperty.TemporaryStorageSize, saveDataJournalSize: 0); controlProperty.TemporaryStorageSize, saveDataJournalSize: 0);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
requiredSize = RoundUpOccupationSize(saveDataTotalSize) + 0x4000; requiredSize = RoundUpOccupationSize(saveDataTotalSize) + 0x4000;
return Result.Success; return Result.Success;
@ -730,30 +730,30 @@ public static class ApplicationSaveDataManagement
if (requiredSize == 0) if (requiredSize == 0)
{ {
rc = fs.Impl.CreateTemporaryStorage(applicationId, saveDataOwnerId, res = fs.Impl.CreateTemporaryStorage(applicationId, saveDataOwnerId,
controlProperty.TemporaryStorageSize, SaveDataFlags.None); controlProperty.TemporaryStorageSize, SaveDataFlags.None);
if (rc.IsFailure()) if (res.IsFailure())
{ {
if (ResultFs.UsableSpaceNotEnough.Includes(rc)) if (ResultFs.UsableSpaceNotEnough.Includes(res))
{ {
rc = CalculateRequiredSizeForTemporaryStorage(fs, out long temporaryStorageSize, res = CalculateRequiredSizeForTemporaryStorage(fs, out long temporaryStorageSize,
in controlProperty); in controlProperty);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
requiredSize += temporaryStorageSize; requiredSize += temporaryStorageSize;
} }
else if (ResultFs.PathAlreadyExists.Includes(rc)) else if (ResultFs.PathAlreadyExists.Includes(res))
{ {
// Nothing to do if the save already exists. // Nothing to do if the save already exists.
rc.Catch().Handle(); res.Catch().Handle();
} }
else else
{ {
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc.Miss(); return res.Miss();
} }
} }
} }
@ -761,32 +761,32 @@ public static class ApplicationSaveDataManagement
{ {
// If there was already insufficient space to create the previous saves, check if the temp // If there was already insufficient space to create the previous saves, check if the temp
// save already exists instead of trying to create a new one. // save already exists instead of trying to create a new one.
rc = SaveDataFilter.Make(out SaveDataFilter filter, applicationId.Value, SaveDataType.Temporary, res = SaveDataFilter.Make(out SaveDataFilter filter, applicationId.Value, SaveDataType.Temporary,
userId: default, saveDataId: default, index: default); userId: default, saveDataId: default, index: default);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
// Check if the temporary save exists // Check if the temporary save exists
rc = fs.Impl.FindSaveDataWithFilter(out SaveDataInfo _, SaveDataSpaceId.Temporary, in filter); res = fs.Impl.FindSaveDataWithFilter(out SaveDataInfo _, SaveDataSpaceId.Temporary, in filter);
if (rc.IsFailure()) if (res.IsFailure())
{ {
if (ResultFs.TargetNotFound.Includes(rc)) if (ResultFs.TargetNotFound.Includes(res))
{ {
// If it doesn't exist, calculate the size required to create it // If it doesn't exist, calculate the size required to create it
rc = CalculateRequiredSizeForTemporaryStorage(fs, out long temporaryStorageSize, res = CalculateRequiredSizeForTemporaryStorage(fs, out long temporaryStorageSize,
in controlProperty); in controlProperty);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
requiredSize += temporaryStorageSize; requiredSize += temporaryStorageSize;
} }
else else
{ {
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc.Miss(); return res.Miss();
} }
} }
} }
@ -800,9 +800,9 @@ public static class ApplicationSaveDataManagement
outRequiredSize = requiredSize; outRequiredSize = requiredSize;
rc = ResultFs.UsableSpaceNotEnough.Log(); res = ResultFs.UsableSpaceNotEnough.Log();
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static Result ExtendApplicationSaveData(this FileSystemClient fs, out long outRequiredSize, public static Result ExtendApplicationSaveData(this FileSystemClient fs, out long outRequiredSize,
@ -811,40 +811,40 @@ public static class ApplicationSaveDataManagement
{ {
UnsafeHelpers.SkipParamInit(out outRequiredSize); UnsafeHelpers.SkipParamInit(out outRequiredSize);
Result rc = CheckSaveDataType(type, in user); Result res = CheckSaveDataType(type, in user);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
UserId userId = Unsafe.As<Uid, UserId>(ref Unsafe.AsRef(in user)); UserId userId = Unsafe.As<Uid, UserId>(ref Unsafe.AsRef(in user));
rc = SaveDataFilter.Make(out SaveDataFilter filter, applicationId.Value, type, userId, saveDataId: default, res = SaveDataFilter.Make(out SaveDataFilter filter, applicationId.Value, type, userId, saveDataId: default,
index: default); index: default);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = fs.Impl.FindSaveDataWithFilter(out SaveDataInfo info, SaveDataSpaceId.User, in filter); res = fs.Impl.FindSaveDataWithFilter(out SaveDataInfo info, SaveDataSpaceId.User, in filter);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = CheckExtensionSizeUnderMax(type, in controlProperty, saveDataSize, saveDataJournalSize); res = CheckExtensionSizeUnderMax(type, in controlProperty, saveDataSize, saveDataJournalSize);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
long requiredSize = 0; long requiredSize = 0;
rc = ExtendSaveDataIfNeeded(fs, ref requiredSize, SaveDataSpaceId.User, info.SaveDataId, saveDataSize, res = ExtendSaveDataIfNeeded(fs, ref requiredSize, SaveDataSpaceId.User, info.SaveDataId, saveDataSize,
saveDataJournalSize); saveDataJournalSize);
if (rc.IsFailure()) if (res.IsFailure())
{ {
if (ResultFs.UsableSpaceNotEnough.Includes(rc)) if (ResultFs.UsableSpaceNotEnough.Includes(res))
{ {
outRequiredSize = requiredSize; outRequiredSize = requiredSize;
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc.Rethrow(); return res.Rethrow();
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc.Miss(); return res.Miss();
} }
return Result.Success; return Result.Success;
@ -855,27 +855,27 @@ public static class ApplicationSaveDataManagement
{ {
UnsafeHelpers.SkipParamInit(out outSaveDataSize, out outSaveDataJournalSize); UnsafeHelpers.SkipParamInit(out outSaveDataSize, out outSaveDataJournalSize);
Result rc = CheckSaveDataType(type, in user); Result res = CheckSaveDataType(type, in user);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
UserId userId = Unsafe.As<Uid, UserId>(ref Unsafe.AsRef(in user)); UserId userId = Unsafe.As<Uid, UserId>(ref Unsafe.AsRef(in user));
rc = SaveDataFilter.Make(out SaveDataFilter filter, applicationId.Value, type, userId, saveDataId: default, res = SaveDataFilter.Make(out SaveDataFilter filter, applicationId.Value, type, userId, saveDataId: default,
index: default); index: default);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = fs.Impl.FindSaveDataWithFilter(out SaveDataInfo info, SaveDataSpaceId.User, in filter); res = fs.Impl.FindSaveDataWithFilter(out SaveDataInfo info, SaveDataSpaceId.User, in filter);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = fs.Impl.GetSaveDataAvailableSize(out long saveDataSize, info.SaveDataId); res = fs.Impl.GetSaveDataAvailableSize(out long saveDataSize, info.SaveDataId);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = fs.Impl.GetSaveDataJournalSize(out long saveDataJournalSize, info.SaveDataId); res = fs.Impl.GetSaveDataJournalSize(out long saveDataJournalSize, info.SaveDataId);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outSaveDataSize = saveDataSize; outSaveDataSize = saveDataSize;
outSaveDataJournalSize = saveDataJournalSize; outSaveDataJournalSize = saveDataJournalSize;

View File

@ -49,8 +49,8 @@ public ref struct DirectoryPathParser
if (windowsSkipLength != 0) if (windowsSkipLength != 0)
{ {
Result rc = CurrentPath.InitializeWithNormalization(pathBuffer, windowsSkipLength + 1); Result res = CurrentPath.InitializeWithNormalization(pathBuffer, windowsSkipLength + 1);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
_buffer = _buffer.Slice(1); _buffer = _buffer.Slice(1);
} }
@ -60,8 +60,8 @@ public ref struct DirectoryPathParser
if (!initialPath.IsEmpty) if (!initialPath.IsEmpty)
{ {
Result rc = CurrentPath.InitializeWithNormalization(initialPath); Result res = CurrentPath.InitializeWithNormalization(initialPath);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
} }

View File

@ -57,11 +57,11 @@ public class FileStorage : IStorage
if (destination.Length == 0) if (destination.Length == 0)
return Result.Success; return Result.Success;
Result rc = UpdateSize(); Result res = UpdateSize();
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = CheckAccessRange(offset, destination.Length, _fileSize); res = CheckAccessRange(offset, destination.Length, _fileSize);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return _baseFile.Read(out _, offset, destination, ReadOption.None); return _baseFile.Read(out _, offset, destination, ReadOption.None);
} }
@ -71,11 +71,11 @@ public class FileStorage : IStorage
if (source.Length == 0) if (source.Length == 0)
return Result.Success; return Result.Success;
Result rc = UpdateSize(); Result res = UpdateSize();
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = CheckAccessRange(offset, source.Length, _fileSize); res = CheckAccessRange(offset, source.Length, _fileSize);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return _baseFile.Write(offset, source, WriteOption.None); return _baseFile.Write(offset, source, WriteOption.None);
} }
@ -89,8 +89,8 @@ public class FileStorage : IStorage
{ {
UnsafeHelpers.SkipParamInit(out size); UnsafeHelpers.SkipParamInit(out size);
Result rc = UpdateSize(); Result res = UpdateSize();
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
size = _fileSize; size = _fileSize;
return Result.Success; return Result.Success;
@ -108,8 +108,8 @@ public class FileStorage : IStorage
{ {
case OperationId.InvalidateCache: case OperationId.InvalidateCache:
{ {
Result rc = _baseFile.OperateRange(OperationId.InvalidateCache, offset, size); Result res = _baseFile.OperateRange(OperationId.InvalidateCache, offset, size);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -124,11 +124,11 @@ public class FileStorage : IStorage
return Result.Success; return Result.Success;
} }
Result rc = UpdateSize(); Result res = UpdateSize();
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = CheckOffsetAndSize(offset, size); res = CheckOffsetAndSize(offset, size);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return _baseFile.OperateRange(outBuffer, operationId, offset, size, inBuffer); return _baseFile.OperateRange(outBuffer, operationId, offset, size, inBuffer);
} }
@ -142,8 +142,8 @@ public class FileStorage : IStorage
if (_fileSize != InvalidSize) if (_fileSize != InvalidSize)
return Result.Success; return Result.Success;
Result rc = _baseFile.GetSize(out long size); Result res = _baseFile.GetSize(out long size);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
_fileSize = size; _fileSize = size;
return Result.Success; return Result.Success;
@ -183,8 +183,8 @@ public class FileStorageBasedFileSystem : FileStorage
{ {
using var baseFile = new UniqueRef<IFile>(); using var baseFile = new UniqueRef<IFile>();
Result rc = baseFileSystem.Get.OpenFile(ref baseFile.Ref(), in path, mode); Result res = baseFileSystem.Get.OpenFile(ref baseFile.Ref(), in path, mode);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
SetFile(baseFile.Get); SetFile(baseFile.Get);
_baseFileSystem.SetByMove(ref baseFileSystem); _baseFileSystem.SetByMove(ref baseFileSystem);
@ -254,11 +254,11 @@ public class FileHandleStorage : IStorage
if (destination.Length == 0) if (destination.Length == 0)
return Result.Success; return Result.Success;
Result rc = UpdateSize(); Result res = UpdateSize();
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = CheckAccessRange(offset, destination.Length, _size); res = CheckAccessRange(offset, destination.Length, _size);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return _fsClient.ReadFile(_handle, offset, destination, ReadOption.None); return _fsClient.ReadFile(_handle, offset, destination, ReadOption.None);
} }
@ -270,11 +270,11 @@ public class FileHandleStorage : IStorage
if (source.Length == 0) if (source.Length == 0)
return Result.Success; return Result.Success;
Result rc = UpdateSize(); Result res = UpdateSize();
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = CheckAccessRange(offset, source.Length, _size); res = CheckAccessRange(offset, source.Length, _size);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return _fsClient.WriteFile(_handle, offset, source, WriteOption.None); return _fsClient.WriteFile(_handle, offset, source, WriteOption.None);
} }
@ -288,8 +288,8 @@ public class FileHandleStorage : IStorage
{ {
UnsafeHelpers.SkipParamInit(out size); UnsafeHelpers.SkipParamInit(out size);
Result rc = UpdateSize(); Result res = UpdateSize();
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
size = _size; size = _size;
return Result.Success; return Result.Success;
@ -309,8 +309,8 @@ public class FileHandleStorage : IStorage
if (outBuffer.Length != Unsafe.SizeOf<QueryRangeInfo>()) if (outBuffer.Length != Unsafe.SizeOf<QueryRangeInfo>())
return ResultFs.InvalidSize.Log(); return ResultFs.InvalidSize.Log();
Result rc = _fsClient.QueryRange(out SpanHelpers.AsStruct<QueryRangeInfo>(outBuffer), _handle, offset, size); Result res = _fsClient.QueryRange(out SpanHelpers.AsStruct<QueryRangeInfo>(outBuffer), _handle, offset, size);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -320,8 +320,8 @@ public class FileHandleStorage : IStorage
if (_size != InvalidSize) if (_size != InvalidSize)
return Result.Success; return Result.Success;
Result rc = _fsClient.GetFileSize(out long size, _handle); Result res = _fsClient.GetFileSize(out long size, _handle);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
_size = size; _size = size;
return Result.Success; return Result.Success;

View File

@ -129,8 +129,8 @@ public ref struct Path
_length = path.GetLength(); _length = path.GetLength();
Result rc = Preallocate(_length + NullTerminatorLength); Result res = Preallocate(_length + NullTerminatorLength);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
int bytesCopied = StringUtils.Copy(_buffer, path._string, _length + NullTerminatorLength); int bytesCopied = StringUtils.Copy(_buffer, path._string, _length + NullTerminatorLength);
@ -404,8 +404,8 @@ public ref struct Path
int otherLength = other.GetLength(); int otherLength = other.GetLength();
Result rc = Preallocate(otherLength + NullTerminatorLength); Result res = Preallocate(otherLength + NullTerminatorLength);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
int bytesCopied = StringUtils.Copy(_writeBuffer, other.GetString(), otherLength + NullTerminatorLength); int bytesCopied = StringUtils.Copy(_writeBuffer, other.GetString(), otherLength + NullTerminatorLength);
@ -428,8 +428,8 @@ public ref struct Path
{ {
int otherLength = other.GetLength(); int otherLength = other.GetLength();
Result rc = Preallocate(otherLength + NullTerminatorLength); Result res = Preallocate(otherLength + NullTerminatorLength);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
int bytesCopied = StringUtils.Copy(_writeBuffer, other.GetString(), otherLength + NullTerminatorLength); int bytesCopied = StringUtils.Copy(_writeBuffer, other.GetString(), otherLength + NullTerminatorLength);
@ -457,8 +457,8 @@ public ref struct Path
return Result.Success; return Result.Success;
} }
Result rc = Preallocate(length + NullTerminatorLength); Result res = Preallocate(length + NullTerminatorLength);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
int bytesCopied = StringUtils.Copy(GetWriteBuffer(), path, length + NullTerminatorLength); int bytesCopied = StringUtils.Copy(GetWriteBuffer(), path, length + NullTerminatorLength);
@ -478,8 +478,8 @@ public ref struct Path
/// <returns><see cref="Result.Success"/>: The operation was successful.</returns> /// <returns><see cref="Result.Success"/>: The operation was successful.</returns>
public Result Initialize(ReadOnlySpan<byte> path) public Result Initialize(ReadOnlySpan<byte> path)
{ {
Result rc = InitializeImpl(path, StringUtils.GetLength(path)); Result res = InitializeImpl(path, StringUtils.GetLength(path));
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
_isNormalized = false; _isNormalized = false;
return Result.Success; return Result.Success;
@ -500,8 +500,8 @@ public ref struct Path
/// <see cref="ResultFs.InvalidPathFormat"/>: The path is not in a valid format.</returns> /// <see cref="ResultFs.InvalidPathFormat"/>: The path is not in a valid format.</returns>
public Result InitializeWithNormalization(ReadOnlySpan<byte> path) public Result InitializeWithNormalization(ReadOnlySpan<byte> path)
{ {
Result rc = Initialize(path); Result res = Initialize(path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (_string.At(0) != NullTerminator && !WindowsPath.IsWindowsPath(_string, false) && if (_string.At(0) != NullTerminator && !WindowsPath.IsWindowsPath(_string, false) &&
_string.At(0) != DirectorySeparator) _string.At(0) != DirectorySeparator)
@ -509,21 +509,21 @@ public ref struct Path
var flags = new PathFlags(); var flags = new PathFlags();
flags.AllowRelativePath(); flags.AllowRelativePath();
rc = Normalize(flags); res = Normalize(flags);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
else if (WindowsPath.IsWindowsPath(_string, true)) else if (WindowsPath.IsWindowsPath(_string, true))
{ {
var flags = new PathFlags(); var flags = new PathFlags();
flags.AllowWindowsPath(); flags.AllowWindowsPath();
rc = Normalize(flags); res = Normalize(flags);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
else else
{ {
rc = PathNormalizer.IsNormalized(out _isNormalized, out _, _string); res = PathNormalizer.IsNormalized(out _isNormalized, out _, _string);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
// Note: I have no idea why Nintendo checks if the path is normalized // Note: I have no idea why Nintendo checks if the path is normalized
@ -544,8 +544,8 @@ public ref struct Path
/// <returns><see cref="Result.Success"/>: The operation was successful.</returns> /// <returns><see cref="Result.Success"/>: The operation was successful.</returns>
public Result Initialize(ReadOnlySpan<byte> path, int length) public Result Initialize(ReadOnlySpan<byte> path, int length)
{ {
Result rc = InitializeImpl(path, length); Result res = InitializeImpl(path, length);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
_isNormalized = false; _isNormalized = false;
return Result.Success; return Result.Success;
@ -567,8 +567,8 @@ public ref struct Path
/// <see cref="ResultFs.InvalidPathFormat"/>: The path is not in a valid format.</returns> /// <see cref="ResultFs.InvalidPathFormat"/>: The path is not in a valid format.</returns>
public Result InitializeWithNormalization(ReadOnlySpan<byte> path, int length) public Result InitializeWithNormalization(ReadOnlySpan<byte> path, int length)
{ {
Result rc = Initialize(path, length); Result res = Initialize(path, length);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (_string.At(0) != NullTerminator && !WindowsPath.IsWindowsPath(_string, false) && if (_string.At(0) != NullTerminator && !WindowsPath.IsWindowsPath(_string, false) &&
_string.At(0) != DirectorySeparator) _string.At(0) != DirectorySeparator)
@ -576,21 +576,21 @@ public ref struct Path
var flags = new PathFlags(); var flags = new PathFlags();
flags.AllowRelativePath(); flags.AllowRelativePath();
rc = Normalize(flags); res = Normalize(flags);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
else if (WindowsPath.IsWindowsPath(_string, true)) else if (WindowsPath.IsWindowsPath(_string, true))
{ {
var flags = new PathFlags(); var flags = new PathFlags();
flags.AllowWindowsPath(); flags.AllowWindowsPath();
rc = Normalize(flags); res = Normalize(flags);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
else else
{ {
rc = PathNormalizer.IsNormalized(out _isNormalized, out _, _string); res = PathNormalizer.IsNormalized(out _isNormalized, out _, _string);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
// Note: I have no idea why Nintendo checks if the path is normalized // Note: I have no idea why Nintendo checks if the path is normalized
@ -610,8 +610,8 @@ public ref struct Path
/// <returns><see cref="Result.Success"/>: The operation was successful.</returns> /// <returns><see cref="Result.Success"/>: The operation was successful.</returns>
public Result InitializeWithReplaceBackslash(ReadOnlySpan<byte> path) public Result InitializeWithReplaceBackslash(ReadOnlySpan<byte> path)
{ {
Result rc = InitializeImpl(path, StringUtils.GetLength(path)); Result res = InitializeImpl(path, StringUtils.GetLength(path));
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (_writeBufferLength > 1) if (_writeBufferLength > 1)
{ {
@ -632,8 +632,8 @@ public ref struct Path
/// <returns><see cref="Result.Success"/>: The operation was successful.</returns> /// <returns><see cref="Result.Success"/>: The operation was successful.</returns>
public Result InitializeWithReplaceForwardSlashes(ReadOnlySpan<byte> path) public Result InitializeWithReplaceForwardSlashes(ReadOnlySpan<byte> path)
{ {
Result rc = InitializeImpl(path, StringUtils.GetLength(path)); Result res = InitializeImpl(path, StringUtils.GetLength(path));
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (_writeBufferLength > 1) if (_writeBufferLength > 1)
{ {
@ -663,8 +663,8 @@ public ref struct Path
/// <returns><see cref="Result.Success"/>: The operation was successful.</returns> /// <returns><see cref="Result.Success"/>: The operation was successful.</returns>
public Result InitializeWithReplaceUnc(ReadOnlySpan<byte> path) public Result InitializeWithReplaceUnc(ReadOnlySpan<byte> path)
{ {
Result rc = InitializeImpl(path, StringUtils.GetLength(path)); Result res = InitializeImpl(path, StringUtils.GetLength(path));
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
_isNormalized = false; _isNormalized = false;
@ -763,8 +763,8 @@ public ref struct Path
} }
// Give our Path a buffer that can hold the combined string. // Give our Path a buffer that can hold the combined string.
Result rc = Preallocate(parentLength + DirectorySeparator + childLength + NullTerminatorLength); Result res = Preallocate(parentLength + DirectorySeparator + childLength + NullTerminatorLength);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
Span<byte> destBuffer = GetWriteBuffer(); Span<byte> destBuffer = GetWriteBuffer();
@ -887,8 +887,8 @@ public ref struct Path
ClearBuffer(); ClearBuffer();
} }
Result rc = Preallocate(parentLength + SeparatorLength + childLength + NullTerminatorLength); Result res = Preallocate(parentLength + SeparatorLength + childLength + NullTerminatorLength);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
Span<byte> destBuffer = GetWriteBuffer(); Span<byte> destBuffer = GetWriteBuffer();
@ -946,21 +946,21 @@ public ref struct Path
int path1Length = path1.GetLength(); int path1Length = path1.GetLength();
int path2Length = path2.GetLength(); int path2Length = path2.GetLength();
Result rc = Preallocate(path1Length + SeparatorLength + path2Length + NullTerminatorLength); Result res = Preallocate(path1Length + SeparatorLength + path2Length + NullTerminatorLength);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = Initialize(in path1); res = Initialize(in path1);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (IsEmpty()) if (IsEmpty())
{ {
rc = Initialize(in path2); res = Initialize(in path2);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
else else
{ {
rc = AppendChild(in path2); res = AppendChild(in path2);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
return Result.Success; return Result.Success;
@ -982,14 +982,14 @@ public ref struct Path
int path1Length = path1.GetLength(); int path1Length = path1.GetLength();
int path2Length = StringUtils.GetLength(path2); int path2Length = StringUtils.GetLength(path2);
Result rc = Preallocate(path1Length + SeparatorLength + path2Length + NullTerminatorLength); Result res = Preallocate(path1Length + SeparatorLength + path2Length + NullTerminatorLength);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = Initialize(in path1); res = Initialize(in path1);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = AppendChild(path2); res = AppendChild(path2);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -1007,14 +1007,14 @@ public ref struct Path
int path1Length = StringUtils.GetLength(path1); int path1Length = StringUtils.GetLength(path1);
int path2Length = path2.GetLength(); int path2Length = path2.GetLength();
Result rc = Preallocate(path1Length + SeparatorLength + path2Length + NullTerminatorLength); Result res = Preallocate(path1Length + SeparatorLength + path2Length + NullTerminatorLength);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = Initialize(path1); res = Initialize(path1);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = AppendChild(in path2); res = AppendChild(in path2);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -1036,8 +1036,8 @@ public ref struct Path
if (oldLength > 0) if (oldLength > 0)
{ {
ReadOnlySpan<byte> oldString = _string; ReadOnlySpan<byte> oldString = _string;
Result rc = Preallocate(oldLength); Result res = Preallocate(oldLength);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
StringUtils.Copy(_writeBuffer, oldString, oldLength + NullTerminatorLength); StringUtils.Copy(_writeBuffer, oldString, oldLength + NullTerminatorLength);
} }
@ -1109,8 +1109,8 @@ public ref struct Path
if (_isNormalized) if (_isNormalized)
return Result.Success; return Result.Success;
Result rc = PathFormatter.IsNormalized(out bool isNormalized, out _, _string, flags); Result res = PathFormatter.IsNormalized(out bool isNormalized, out _, _string, flags);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (isNormalized) if (isNormalized)
{ {
@ -1133,8 +1133,8 @@ public ref struct Path
{ {
rentedArray = ArrayPool<byte>.Shared.Rent(alignedBufferLength); rentedArray = ArrayPool<byte>.Shared.Rent(alignedBufferLength);
rc = PathFormatter.Normalize(rentedArray, GetWriteBuffer(), flags); res = PathFormatter.Normalize(rentedArray, GetWriteBuffer(), flags);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
SetModifiableBuffer(Shared.Move(ref rentedArray), alignedBufferLength); SetModifiableBuffer(Shared.Move(ref rentedArray), alignedBufferLength);
_isNormalized = true; _isNormalized = true;
@ -1169,14 +1169,14 @@ public static class PathFunctions
/// <see cref="ResultFs.InvalidPathFormat"/>: The path is in an invalid format or is not normalized.</returns> /// <see cref="ResultFs.InvalidPathFormat"/>: The path is in an invalid format or is not normalized.</returns>
public static Result SetUpFixedPath(ref Path path, ReadOnlySpan<byte> pathBuffer) public static Result SetUpFixedPath(ref Path path, ReadOnlySpan<byte> pathBuffer)
{ {
Result rc = PathNormalizer.IsNormalized(out bool isNormalized, out _, pathBuffer); Result res = PathNormalizer.IsNormalized(out bool isNormalized, out _, pathBuffer);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!isNormalized) if (!isNormalized)
return ResultFs.InvalidPathFormat.Log(); return ResultFs.InvalidPathFormat.Log();
rc = path.SetShallowBuffer(pathBuffer); res = path.SetShallowBuffer(pathBuffer);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }

View File

@ -238,7 +238,7 @@ public static class PathFormatter
if (WindowsPath.IsUncPath(currentPath, false, true)) if (WindowsPath.IsUncPath(currentPath, false, true))
{ {
Result rc; Result res;
ReadOnlySpan<byte> finalPath = currentPath; ReadOnlySpan<byte> finalPath = currentPath;
@ -253,9 +253,9 @@ public static class PathFormatter
{ {
if (currentComponentOffset != 0) if (currentComponentOffset != 0)
{ {
rc = CheckSharedName( res = CheckSharedName(
currentPath.Slice(currentComponentOffset, pos - currentComponentOffset)); currentPath.Slice(currentComponentOffset, pos - currentComponentOffset));
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
finalPath = currentPath.Slice(pos); finalPath = currentPath.Slice(pos);
break; break;
@ -264,8 +264,8 @@ public static class PathFormatter
if (currentPath.At(pos + 1) == DirectorySeparator || currentPath.At(pos + 1) == AltDirectorySeparator) if (currentPath.At(pos + 1) == DirectorySeparator || currentPath.At(pos + 1) == AltDirectorySeparator)
return ResultFs.InvalidPathFormat.Log(); return ResultFs.InvalidPathFormat.Log();
rc = CheckHostName(currentPath.Slice(2, pos - 2)); res = CheckHostName(currentPath.Slice(2, pos - 2));
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
currentComponentOffset = pos + 1; currentComponentOffset = pos + 1;
} }
@ -276,8 +276,8 @@ public static class PathFormatter
if (currentComponentOffset != 0 && finalPath == currentPath) if (currentComponentOffset != 0 && finalPath == currentPath)
{ {
rc = CheckSharedName(currentPath.Slice(currentComponentOffset, pos - currentComponentOffset)); res = CheckSharedName(currentPath.Slice(currentComponentOffset, pos - currentComponentOffset));
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
finalPath = currentPath.Slice(pos); finalPath = currentPath.Slice(pos);
} }
@ -326,16 +326,16 @@ public static class PathFormatter
{ {
isNormalized = true; isNormalized = true;
Result rc = ParseWindowsPathImpl(out newPath, out windowsPathLength, Span<byte>.Empty, path, hasMountName); Result res = ParseWindowsPathImpl(out newPath, out windowsPathLength, Span<byte>.Empty, path, hasMountName);
if (!rc.IsSuccess()) if (!res.IsSuccess())
{ {
if (ResultFs.NotNormalized.Includes(rc)) if (ResultFs.NotNormalized.Includes(res))
{ {
isNormalized = false; isNormalized = false;
} }
else else
{ {
return rc; return res;
} }
} }
@ -396,8 +396,8 @@ public static class PathFormatter
{ {
UnsafeHelpers.SkipParamInit(out isNormalized, out normalizedLength); UnsafeHelpers.SkipParamInit(out isNormalized, out normalizedLength);
Result rc = PathUtility.CheckUtf8(path); Result res = PathUtility.CheckUtf8(path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
ReadOnlySpan<byte> buffer = path; ReadOnlySpan<byte> buffer = path;
int totalLength = 0; int totalLength = 0;
@ -425,8 +425,8 @@ public static class PathFormatter
bool hasMountName = false; bool hasMountName = false;
rc = SkipMountName(out buffer, out int mountNameLength, buffer); res = SkipMountName(out buffer, out int mountNameLength, buffer);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (mountNameLength != 0) if (mountNameLength != 0)
{ {
@ -449,8 +449,8 @@ public static class PathFormatter
bool isRelativePath = false; bool isRelativePath = false;
rc = SkipRelativeDotPath(out buffer, out int relativePathLength, buffer); res = SkipRelativeDotPath(out buffer, out int relativePathLength, buffer);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (relativePathLength != 0) if (relativePathLength != 0)
{ {
@ -469,8 +469,8 @@ public static class PathFormatter
isRelativePath = true; isRelativePath = true;
} }
rc = SkipWindowsPath(out buffer, out int windowsPathLength, out bool isNormalizedWin, buffer, hasMountName); res = SkipWindowsPath(out buffer, out int windowsPathLength, out bool isNormalizedWin, buffer, hasMountName);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!isNormalizedWin) if (!isNormalizedWin)
{ {
@ -513,9 +513,9 @@ public static class PathFormatter
return Result.Success; return Result.Success;
} }
rc = PathUtility.CheckInvalidBackslash(out bool isBackslashContained, buffer, res = PathUtility.CheckInvalidBackslash(out bool isBackslashContained, buffer,
flags.IsWindowsPathAllowed() || flags.IsBackslashAllowed()); flags.IsWindowsPathAllowed() || flags.IsBackslashAllowed());
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (isBackslashContained && !flags.IsBackslashAllowed()) if (isBackslashContained && !flags.IsBackslashAllowed())
{ {
@ -523,8 +523,8 @@ public static class PathFormatter
return Result.Success; return Result.Success;
} }
rc = PathNormalizer.IsNormalized(out isNormalized, out int length, buffer, flags.AreAllCharactersAllowed()); res = PathNormalizer.IsNormalized(out isNormalized, out int length, buffer, flags.AreAllCharactersAllowed());
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
totalLength += length; totalLength += length;
normalizedLength = totalLength; normalizedLength = totalLength;
@ -533,7 +533,7 @@ public static class PathFormatter
public static Result Normalize(Span<byte> outputBuffer, ReadOnlySpan<byte> path, PathFlags flags) public static Result Normalize(Span<byte> outputBuffer, ReadOnlySpan<byte> path, PathFlags flags)
{ {
Result rc; Result res;
ReadOnlySpan<byte> src = path; ReadOnlySpan<byte> src = path;
int currentPos = 0; int currentPos = 0;
@ -554,8 +554,8 @@ public static class PathFormatter
if (flags.IsMountNameAllowed()) if (flags.IsMountNameAllowed())
{ {
rc = ParseMountName(out src, out int mountNameLength, outputBuffer.Slice(currentPos), src); res = ParseMountName(out src, out int mountNameLength, outputBuffer.Slice(currentPos), src);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
currentPos += mountNameLength; currentPos += mountNameLength;
hasMountName = mountNameLength != 0; hasMountName = mountNameLength != 0;
@ -578,8 +578,8 @@ public static class PathFormatter
if (currentPos >= outputBuffer.Length) if (currentPos >= outputBuffer.Length)
return ResultFs.TooLongPath.Log(); return ResultFs.TooLongPath.Log();
rc = ParseRelativeDotPath(out src, out int relativePathLength, outputBuffer.Slice(currentPos), src); res = ParseRelativeDotPath(out src, out int relativePathLength, outputBuffer.Slice(currentPos), src);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
currentPos += relativePathLength; currentPos += relativePathLength;
@ -600,9 +600,9 @@ public static class PathFormatter
if (currentPos >= outputBuffer.Length) if (currentPos >= outputBuffer.Length)
return ResultFs.TooLongPath.Log(); return ResultFs.TooLongPath.Log();
rc = ParseWindowsPath(out src, out int windowsPathLength, outputBuffer.Slice(currentPos), src, res = ParseWindowsPath(out src, out int windowsPathLength, outputBuffer.Slice(currentPos), src,
hasMountName); hasMountName);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
currentPos += windowsPathLength; currentPos += windowsPathLength;
@ -624,9 +624,9 @@ public static class PathFormatter
isWindowsPath = true; isWindowsPath = true;
} }
rc = PathUtility.CheckInvalidBackslash(out bool isBackslashContained, src, res = PathUtility.CheckInvalidBackslash(out bool isBackslashContained, src,
flags.IsWindowsPathAllowed() || flags.IsBackslashAllowed()); flags.IsWindowsPathAllowed() || flags.IsBackslashAllowed());
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
byte[] srcBufferSlashReplaced = null; byte[] srcBufferSlashReplaced = null;
try try
@ -644,9 +644,9 @@ public static class PathFormatter
src = srcBufferSlashReplaced.AsSpan(srcOffset); src = srcBufferSlashReplaced.AsSpan(srcOffset);
} }
rc = PathNormalizer.Normalize(outputBuffer.Slice(currentPos), out _, src, isWindowsPath, isDriveRelative, res = PathNormalizer.Normalize(outputBuffer.Slice(currentPos), out _, src, isWindowsPath, isDriveRelative,
flags.AreAllCharactersAllowed()); flags.AreAllCharactersAllowed());
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }

View File

@ -49,7 +49,7 @@ public static class PathNormalizer
var convertedPath = new RentedArray<byte>(); var convertedPath = new RentedArray<byte>();
try try
{ {
Result rc; Result res;
// Check if parent directory path replacement is needed. // Check if parent directory path replacement is needed.
if (IsParentDirectoryPathReplacementNeeded(currentPath)) if (IsParentDirectoryPathReplacementNeeded(currentPath))
{ {
@ -100,8 +100,8 @@ public static class PathNormalizer
{ {
if (!allowAllCharacters) if (!allowAllCharacters)
{ {
rc = CheckInvalidCharacter(currentPath[i + dirLen]); res = CheckInvalidCharacter(currentPath[i + dirLen]);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
} }
dirLen++; dirLen++;
@ -185,8 +185,8 @@ public static class PathNormalizer
outputBuffer[totalLength] = NullTerminator; outputBuffer[totalLength] = NullTerminator;
rc = IsNormalized(out bool isNormalized, out _, outputBuffer, allowAllCharacters); res = IsNormalized(out bool isNormalized, out _, outputBuffer, allowAllCharacters);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
Assert.SdkAssert(isNormalized); Assert.SdkAssert(isNormalized);
@ -238,8 +238,8 @@ public static class PathNormalizer
if (!allowAllCharacters && state != PathState.Initial) if (!allowAllCharacters && state != PathState.Initial)
{ {
Result rc = CheckInvalidCharacter(c); Result res = CheckInvalidCharacter(c);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
switch (state) switch (state)

View File

@ -56,9 +56,9 @@ public static class PathUtility
if (length >= PathTool.EntryNameLengthMax + 1) if (length >= PathTool.EntryNameLengthMax + 1)
return ResultFs.TooLongPath.Log(); return ResultFs.TooLongPath.Log();
Result rc = PathFormatter.SkipMountName(out ReadOnlySpan<byte> pathWithoutMountName, out int skipLength, Result res = PathFormatter.SkipMountName(out ReadOnlySpan<byte> pathWithoutMountName, out int skipLength,
new U8Span(path)); new U8Span(path));
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!WindowsPath.IsWindowsPath(pathWithoutMountName, true)) if (!WindowsPath.IsWindowsPath(pathWithoutMountName, true))
{ {

View File

@ -93,7 +93,7 @@ internal class FileAccessor : IDisposable
{ {
UnsafeHelpers.SkipParamInit(out bytesRead); UnsafeHelpers.SkipParamInit(out bytesRead);
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x50]; Span<byte> logBuffer = stackalloc byte[0x50];
var handle = new FileHandle(this); var handle = new FileHandle(this);
@ -102,15 +102,15 @@ internal class FileAccessor : IDisposable
if (Hos.Fs.Impl.IsEnabledAccessLog() && Hos.Fs.Impl.IsEnabledHandleAccessLog(handle)) if (Hos.Fs.Impl.IsEnabledAccessLog() && Hos.Fs.Impl.IsEnabledHandleAccessLog(handle))
{ {
Tick start = Hos.Os.GetSystemTick(); Tick start = Hos.Os.GetSystemTick();
rc = _lastResult; res = _lastResult;
Tick end = Hos.Os.GetSystemTick(); Tick end = Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogOffset).AppendFormat(offset) sb.Append(LogOffset).AppendFormat(offset)
.Append(LogSize).AppendFormat(destination.Length) .Append(LogSize).AppendFormat(destination.Length)
.Append(LogReadSize).AppendFormat(AccessLogImpl.DereferenceOutValue(in bytesRead, rc)); .Append(LogReadSize).AppendFormat(AccessLogImpl.DereferenceOutValue(in bytesRead, res));
Hos.Fs.Impl.OutputAccessLog(rc, start, end, handle, new U8Span(logBuffer), Hos.Fs.Impl.OutputAccessLog(res, start, end, handle, new U8Span(logBuffer),
nameof(UserFile.ReadFile)); nameof(UserFile.ReadFile));
} }
@ -130,23 +130,23 @@ internal class FileAccessor : IDisposable
if (Hos.Fs.Impl.IsEnabledAccessLog() && Hos.Fs.Impl.IsEnabledHandleAccessLog(handle)) if (Hos.Fs.Impl.IsEnabledAccessLog() && Hos.Fs.Impl.IsEnabledHandleAccessLog(handle))
{ {
Tick start = Hos.Os.GetSystemTick(); Tick start = Hos.Os.GetSystemTick();
rc = ReadWithoutCacheAccessLog(out bytesRead, offset, destination, in option); res = ReadWithoutCacheAccessLog(out bytesRead, offset, destination, in option);
Tick end = Hos.Os.GetSystemTick(); Tick end = Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogOffset).AppendFormat(offset) sb.Append(LogOffset).AppendFormat(offset)
.Append(LogSize).AppendFormat(destination.Length) .Append(LogSize).AppendFormat(destination.Length)
.Append(LogReadSize).AppendFormat(AccessLogImpl.DereferenceOutValue(in bytesRead, rc)); .Append(LogReadSize).AppendFormat(AccessLogImpl.DereferenceOutValue(in bytesRead, res));
Hos.Fs.Impl.OutputAccessLog(rc, start, end, handle, new U8Span(logBuffer), Hos.Fs.Impl.OutputAccessLog(res, start, end, handle, new U8Span(logBuffer),
nameof(UserFile.ReadFile)); nameof(UserFile.ReadFile));
} }
else else
{ {
rc = ReadWithoutCacheAccessLog(out bytesRead, offset, destination, in option); res = ReadWithoutCacheAccessLog(out bytesRead, offset, destination, in option);
} }
return rc; return res;
} }
public Result Write(long offset, ReadOnlySpan<byte> source, in WriteOption option) public Result Write(long offset, ReadOnlySpan<byte> source, in WriteOption option)
@ -159,14 +159,14 @@ internal class FileAccessor : IDisposable
if (_filePathHash is not null) if (_filePathHash is not null)
{ {
Result rc = UpdateLastResult(Hos.Fs.Impl.WriteViaPathBasedFileDataCache(_file.Get, (int)GetOpenMode(), Result res = UpdateLastResult(Hos.Fs.Impl.WriteViaPathBasedFileDataCache(_file.Get, (int)GetOpenMode(),
_parentFileSystem, in _filePathHash.Value, _pathHashIndex, offset, source, in option)); _parentFileSystem, in _filePathHash.Value, _pathHashIndex, offset, source, in option));
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
} }
else else
{ {
Result rc = UpdateLastResult(_file.Get.Write(offset, source, in option)); Result res = UpdateLastResult(_file.Get.Write(offset, source, in option));
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
setter.Set(option.HasFlushFlag() ? WriteState.None : WriteState.NeedsFlush); setter.Set(option.HasFlushFlag() ? WriteState.None : WriteState.NeedsFlush);
@ -181,8 +181,8 @@ internal class FileAccessor : IDisposable
using ScopedSetter<WriteState> setter = using ScopedSetter<WriteState> setter =
ScopedSetter<WriteState>.MakeScopedSetter(ref _writeState, WriteState.Failed); ScopedSetter<WriteState>.MakeScopedSetter(ref _writeState, WriteState.Failed);
Result rc = UpdateLastResult(_file.Get.Flush()); Result res = UpdateLastResult(_file.Get.Flush());
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
setter.Set(WriteState.None); setter.Set(WriteState.None);
return Result.Success; return Result.Success;
@ -201,16 +201,16 @@ internal class FileAccessor : IDisposable
{ {
using UniqueLock lk = Hos.Fs.Impl.LockPathBasedFileDataCacheEntries(); using UniqueLock lk = Hos.Fs.Impl.LockPathBasedFileDataCacheEntries();
Result rc = UpdateLastResult(_file.Get.SetSize(size)); Result res = UpdateLastResult(_file.Get.SetSize(size));
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
Hos.Fs.Impl.InvalidatePathBasedFileDataCacheEntry(_parentFileSystem, in _filePathHash.Value, _pathHashIndex); Hos.Fs.Impl.InvalidatePathBasedFileDataCacheEntry(_parentFileSystem, in _filePathHash.Value, _pathHashIndex);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
} }
else else
{ {
Result rc = UpdateLastResult(_file.Get.SetSize(size)); Result res = UpdateLastResult(_file.Get.SetSize(size));
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
setter.Set(originalWriteState); setter.Set(originalWriteState);

View File

@ -146,9 +146,9 @@ internal class FileSystemAccessor : IDisposable
private Result SetUpPath(ref Path path, U8Span pathBuffer) private Result SetUpPath(ref Path path, U8Span pathBuffer)
{ {
Result rc = PathFormatter.IsNormalized(out bool isNormalized, out _, pathBuffer, _pathFlags); Result res = PathFormatter.IsNormalized(out bool isNormalized, out _, pathBuffer, _pathFlags);
if (rc.IsSuccess() && isNormalized) if (res.IsSuccess() && isNormalized)
{ {
path.SetShallowBuffer(pathBuffer); path.SetShallowBuffer(pathBuffer);
} }
@ -156,17 +156,17 @@ internal class FileSystemAccessor : IDisposable
{ {
if (_pathFlags.IsWindowsPathAllowed()) if (_pathFlags.IsWindowsPathAllowed())
{ {
rc = path.InitializeWithReplaceForwardSlashes(pathBuffer); res = path.InitializeWithReplaceForwardSlashes(pathBuffer);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
else else
{ {
rc = path.InitializeWithReplaceBackslash(pathBuffer); res = path.InitializeWithReplaceBackslash(pathBuffer);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
rc = path.Normalize(_pathFlags); res = path.Normalize(_pathFlags);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
if (path.GetLength() > PathTool.EntryNameLengthMax) if (path.GetLength() > PathTool.EntryNameLengthMax)
@ -178,22 +178,22 @@ internal class FileSystemAccessor : IDisposable
public Result CreateFile(U8Span path, long size, CreateFileOptions option) public Result CreateFile(U8Span path, long size, CreateFileOptions option)
{ {
using var pathNormalized = new Path(); using var pathNormalized = new Path();
Result rc = SetUpPath(ref pathNormalized.Ref(), path); Result res = SetUpPath(ref pathNormalized.Ref(), path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (_isPathCacheAttached) if (_isPathCacheAttached)
{ {
using UniqueLock lk = Hos.Fs.Impl.LockPathBasedFileDataCacheEntries(); using UniqueLock lk = Hos.Fs.Impl.LockPathBasedFileDataCacheEntries();
rc = _fileSystem.Get.CreateFile(in pathNormalized, size, option); res = _fileSystem.Get.CreateFile(in pathNormalized, size, option);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
Hos.Fs.Impl.InvalidatePathBasedFileDataCacheEntry(this, in pathNormalized); Hos.Fs.Impl.InvalidatePathBasedFileDataCacheEntry(this, in pathNormalized);
} }
else else
{ {
rc = _fileSystem.Get.CreateFile(in pathNormalized, size, option); res = _fileSystem.Get.CreateFile(in pathNormalized, size, option);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
return Result.Success; return Result.Success;
@ -202,11 +202,11 @@ internal class FileSystemAccessor : IDisposable
public Result DeleteFile(U8Span path) public Result DeleteFile(U8Span path)
{ {
using var pathNormalized = new Path(); using var pathNormalized = new Path();
Result rc = SetUpPath(ref pathNormalized.Ref(), path); Result res = SetUpPath(ref pathNormalized.Ref(), path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _fileSystem.Get.DeleteFile(in pathNormalized); res = _fileSystem.Get.DeleteFile(in pathNormalized);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -214,11 +214,11 @@ internal class FileSystemAccessor : IDisposable
public Result CreateDirectory(U8Span path) public Result CreateDirectory(U8Span path)
{ {
using var pathNormalized = new Path(); using var pathNormalized = new Path();
Result rc = SetUpPath(ref pathNormalized.Ref(), path); Result res = SetUpPath(ref pathNormalized.Ref(), path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _fileSystem.Get.CreateDirectory(in pathNormalized); res = _fileSystem.Get.CreateDirectory(in pathNormalized);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -226,11 +226,11 @@ internal class FileSystemAccessor : IDisposable
public Result DeleteDirectory(U8Span path) public Result DeleteDirectory(U8Span path)
{ {
using var pathNormalized = new Path(); using var pathNormalized = new Path();
Result rc = SetUpPath(ref pathNormalized.Ref(), path); Result res = SetUpPath(ref pathNormalized.Ref(), path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _fileSystem.Get.CreateDirectory(in pathNormalized); res = _fileSystem.Get.CreateDirectory(in pathNormalized);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -238,11 +238,11 @@ internal class FileSystemAccessor : IDisposable
public Result DeleteDirectoryRecursively(U8Span path) public Result DeleteDirectoryRecursively(U8Span path)
{ {
using var pathNormalized = new Path(); using var pathNormalized = new Path();
Result rc = SetUpPath(ref pathNormalized.Ref(), path); Result res = SetUpPath(ref pathNormalized.Ref(), path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _fileSystem.Get.DeleteDirectoryRecursively(in pathNormalized); res = _fileSystem.Get.DeleteDirectoryRecursively(in pathNormalized);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -250,11 +250,11 @@ internal class FileSystemAccessor : IDisposable
public Result CleanDirectoryRecursively(U8Span path) public Result CleanDirectoryRecursively(U8Span path)
{ {
using var pathNormalized = new Path(); using var pathNormalized = new Path();
Result rc = SetUpPath(ref pathNormalized.Ref(), path); Result res = SetUpPath(ref pathNormalized.Ref(), path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _fileSystem.Get.CleanDirectoryRecursively(in pathNormalized); res = _fileSystem.Get.CleanDirectoryRecursively(in pathNormalized);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -262,26 +262,26 @@ internal class FileSystemAccessor : IDisposable
public Result RenameFile(U8Span currentPath, U8Span newPath) public Result RenameFile(U8Span currentPath, U8Span newPath)
{ {
using var currentPathNormalized = new Path(); using var currentPathNormalized = new Path();
Result rc = SetUpPath(ref currentPathNormalized.Ref(), currentPath); Result res = SetUpPath(ref currentPathNormalized.Ref(), currentPath);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var newPathNormalized = new Path(); using var newPathNormalized = new Path();
rc = SetUpPath(ref newPathNormalized.Ref(), newPath); res = SetUpPath(ref newPathNormalized.Ref(), newPath);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (_isPathCacheAttached) if (_isPathCacheAttached)
{ {
using UniqueLock lk = Hos.Fs.Impl.LockPathBasedFileDataCacheEntries(); using UniqueLock lk = Hos.Fs.Impl.LockPathBasedFileDataCacheEntries();
rc = _fileSystem.Get.RenameFile(in currentPathNormalized, in newPathNormalized); res = _fileSystem.Get.RenameFile(in currentPathNormalized, in newPathNormalized);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
Hos.Fs.Impl.InvalidatePathBasedFileDataCacheEntry(this, in newPathNormalized); Hos.Fs.Impl.InvalidatePathBasedFileDataCacheEntry(this, in newPathNormalized);
} }
else else
{ {
rc = _fileSystem.Get.RenameFile(in currentPathNormalized, in newPathNormalized); res = _fileSystem.Get.RenameFile(in currentPathNormalized, in newPathNormalized);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
return Result.Success; return Result.Success;
@ -290,26 +290,26 @@ internal class FileSystemAccessor : IDisposable
public Result RenameDirectory(U8Span currentPath, U8Span newPath) public Result RenameDirectory(U8Span currentPath, U8Span newPath)
{ {
using var currentPathNormalized = new Path(); using var currentPathNormalized = new Path();
Result rc = SetUpPath(ref currentPathNormalized.Ref(), currentPath); Result res = SetUpPath(ref currentPathNormalized.Ref(), currentPath);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var newPathNormalized = new Path(); using var newPathNormalized = new Path();
rc = SetUpPath(ref newPathNormalized.Ref(), newPath); res = SetUpPath(ref newPathNormalized.Ref(), newPath);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (_isPathCacheAttached) if (_isPathCacheAttached)
{ {
using UniqueLock lk = Hos.Fs.Impl.LockPathBasedFileDataCacheEntries(); using UniqueLock lk = Hos.Fs.Impl.LockPathBasedFileDataCacheEntries();
rc = _fileSystem.Get.RenameDirectory(in currentPathNormalized, in newPathNormalized); res = _fileSystem.Get.RenameDirectory(in currentPathNormalized, in newPathNormalized);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
Hos.Fs.Impl.InvalidatePathBasedFileDataCacheEntries(this); Hos.Fs.Impl.InvalidatePathBasedFileDataCacheEntries(this);
} }
else else
{ {
rc = _fileSystem.Get.RenameDirectory(in currentPathNormalized, in newPathNormalized); res = _fileSystem.Get.RenameDirectory(in currentPathNormalized, in newPathNormalized);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
return Result.Success; return Result.Success;
} }
@ -319,11 +319,11 @@ internal class FileSystemAccessor : IDisposable
UnsafeHelpers.SkipParamInit(out entryType); UnsafeHelpers.SkipParamInit(out entryType);
using var pathNormalized = new Path(); using var pathNormalized = new Path();
Result rc = SetUpPath(ref pathNormalized.Ref(), path); Result res = SetUpPath(ref pathNormalized.Ref(), path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _fileSystem.Get.GetEntryType(out entryType, in pathNormalized); res = _fileSystem.Get.GetEntryType(out entryType, in pathNormalized);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -333,11 +333,11 @@ internal class FileSystemAccessor : IDisposable
UnsafeHelpers.SkipParamInit(out freeSpace); UnsafeHelpers.SkipParamInit(out freeSpace);
using var pathNormalized = new Path(); using var pathNormalized = new Path();
Result rc = SetUpPath(ref pathNormalized.Ref(), path); Result res = SetUpPath(ref pathNormalized.Ref(), path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _fileSystem.Get.GetFreeSpaceSize(out freeSpace, in pathNormalized); res = _fileSystem.Get.GetFreeSpaceSize(out freeSpace, in pathNormalized);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -347,11 +347,11 @@ internal class FileSystemAccessor : IDisposable
UnsafeHelpers.SkipParamInit(out totalSpace); UnsafeHelpers.SkipParamInit(out totalSpace);
using var pathNormalized = new Path(); using var pathNormalized = new Path();
Result rc = SetUpPath(ref pathNormalized.Ref(), path); Result res = SetUpPath(ref pathNormalized.Ref(), path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _fileSystem.Get.GetTotalSpaceSize(out totalSpace, in pathNormalized); res = _fileSystem.Get.GetTotalSpaceSize(out totalSpace, in pathNormalized);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -359,12 +359,12 @@ internal class FileSystemAccessor : IDisposable
public Result OpenFile(ref UniqueRef<FileAccessor> outFile, U8Span path, OpenMode mode) public Result OpenFile(ref UniqueRef<FileAccessor> outFile, U8Span path, OpenMode mode)
{ {
using var pathNormalized = new Path(); using var pathNormalized = new Path();
Result rc = SetUpPath(ref pathNormalized.Ref(), path); Result res = SetUpPath(ref pathNormalized.Ref(), path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var file = new UniqueRef<IFile>(); using var file = new UniqueRef<IFile>();
rc = _fileSystem.Get.OpenFile(ref file.Ref(), in pathNormalized, mode); res = _fileSystem.Get.OpenFile(ref file.Ref(), in pathNormalized, mode);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
var accessor = new FileAccessor(Hos, ref file.Ref(), this, mode); var accessor = new FileAccessor(Hos, ref file.Ref(), this, mode);
@ -398,12 +398,12 @@ internal class FileSystemAccessor : IDisposable
public Result OpenDirectory(ref UniqueRef<DirectoryAccessor> outDirectory, U8Span path, OpenDirectoryMode mode) public Result OpenDirectory(ref UniqueRef<DirectoryAccessor> outDirectory, U8Span path, OpenDirectoryMode mode)
{ {
using var pathNormalized = new Path(); using var pathNormalized = new Path();
Result rc = SetUpPath(ref pathNormalized.Ref(), path); Result res = SetUpPath(ref pathNormalized.Ref(), path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var directory = new UniqueRef<IDirectory>(); using var directory = new UniqueRef<IDirectory>();
rc = _fileSystem.Get.OpenDirectory(ref directory.Ref(), in pathNormalized, mode); res = _fileSystem.Get.OpenDirectory(ref directory.Ref(), in pathNormalized, mode);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
var accessor = new DirectoryAccessor(ref directory.Ref(), this); var accessor = new DirectoryAccessor(ref directory.Ref(), this);
@ -447,11 +447,11 @@ internal class FileSystemAccessor : IDisposable
UnsafeHelpers.SkipParamInit(out timeStamp); UnsafeHelpers.SkipParamInit(out timeStamp);
using var pathNormalized = new Path(); using var pathNormalized = new Path();
Result rc = SetUpPath(ref pathNormalized.Ref(), path); Result res = SetUpPath(ref pathNormalized.Ref(), path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _fileSystem.Get.GetFileTimeStampRaw(out timeStamp, in pathNormalized); res = _fileSystem.Get.GetFileTimeStampRaw(out timeStamp, in pathNormalized);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -459,11 +459,11 @@ internal class FileSystemAccessor : IDisposable
public Result QueryEntry(Span<byte> outBuffer, ReadOnlySpan<byte> inBuffer, QueryId queryId, U8Span path) public Result QueryEntry(Span<byte> outBuffer, ReadOnlySpan<byte> inBuffer, QueryId queryId, U8Span path)
{ {
using var pathNormalized = new Path(); using var pathNormalized = new Path();
Result rc = SetUpPath(ref pathNormalized.Ref(), path); Result res = SetUpPath(ref pathNormalized.Ref(), path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _fileSystem.Get.QueryEntry(outBuffer, inBuffer, queryId, in pathNormalized); res = _fileSystem.Get.QueryEntry(outBuffer, inBuffer, queryId, in pathNormalized);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -495,8 +495,8 @@ internal class FileSystemAccessor : IDisposable
if (!_saveDataAttributeGetter.HasValue) if (!_saveDataAttributeGetter.HasValue)
return ResultFs.PreconditionViolation.Log(); return ResultFs.PreconditionViolation.Log();
Result rc = _saveDataAttributeGetter.Get.GetSaveDataAttribute(out attribute); Result res = _saveDataAttributeGetter.Get.GetSaveDataAttribute(out attribute);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -669,8 +669,8 @@ internal class FileSystemAccessor : IDisposable
if ((openMode & fileOpenModeMask) == 0) if ((openMode & fileOpenModeMask) == 0)
continue; continue;
Result rc = file.Value.GetSize(out long fileSize); Result res = file.Value.GetSize(out long fileSize);
if (rc.IsFailure()) if (res.IsFailure())
fileSize = -1; fileSize = -1;
var openModeString = new U8StringBuilder(openModeStringBuffer); var openModeString = new U8StringBuilder(openModeStringBuffer);

View File

@ -83,8 +83,8 @@ public abstract class IFile : IDisposable
{ {
if (option.HasFlushFlag()) if (option.HasFlushFlag())
{ {
Result rc = Flush(); Result res = Flush();
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
return Result.Success; return Result.Success;
@ -167,8 +167,8 @@ public abstract class IFile : IDisposable
return ResultFs.ReadUnpermitted.Log(); return ResultFs.ReadUnpermitted.Log();
// Get the file size, and validate our offset. // Get the file size, and validate our offset.
Result rc = GetSize(out long fileSize); Result res = GetSize(out long fileSize);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (offset > fileSize) if (offset > fileSize)
return ResultFs.OutOfRange.Log(); return ResultFs.OutOfRange.Log();
@ -187,8 +187,8 @@ public abstract class IFile : IDisposable
return ResultFs.WriteUnpermitted.Log(); return ResultFs.WriteUnpermitted.Log();
// Get the file size. // Get the file size.
Result rc = GetSize(out long fileSize); Result res = GetSize(out long fileSize);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
needsAppend = false; needsAppend = false;

View File

@ -167,8 +167,8 @@ public abstract class IFileSystem : IDisposable
return ResultFs.NullptrArgument.Log(); return ResultFs.NullptrArgument.Log();
using var pathNormalized = new Path(); using var pathNormalized = new Path();
Result rs = pathNormalized.InitializeWithNormalization(path); Result res = pathNormalized.InitializeWithNormalization(path);
if (rs.IsFailure()) return rs; if (res.IsFailure()) return res;
return DoGetEntryType(out entryType, in pathNormalized); return DoGetEntryType(out entryType, in pathNormalized);
} }
@ -209,8 +209,8 @@ public abstract class IFileSystem : IDisposable
return ResultFs.NullptrArgument.Log(); return ResultFs.NullptrArgument.Log();
using var pathNormalized = new Path(); using var pathNormalized = new Path();
Result rs = pathNormalized.InitializeWithNormalization(path); Result res = pathNormalized.InitializeWithNormalization(path);
if (rs.IsFailure()) return rs; if (res.IsFailure()) return res;
return DoOpenFile(ref file, in pathNormalized, mode); return DoOpenFile(ref file, in pathNormalized, mode);
} }

View File

@ -124,8 +124,8 @@ public static class MountUtility
return ResultFs.NotMounted.Log(); return ResultFs.NotMounted.Log();
} }
Result rc = GetMountNameAndSubPath(out MountName mountName, out subPath, path); Result res = GetMountNameAndSubPath(out MountName mountName, out subPath, path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return fs.Find(out fileSystem, new U8Span(mountName.Name)); return fs.Find(out fileSystem, new U8Span(mountName.Name));
} }
@ -157,8 +157,8 @@ public static class MountUtility
public static Result Unmount(this FileSystemClientImpl fs, U8Span mountName) public static Result Unmount(this FileSystemClientImpl fs, U8Span mountName)
{ {
Result rc = fs.Find(out FileSystemAccessor fileSystem, mountName); Result res = fs.Find(out FileSystemAccessor fileSystem, mountName);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fileSystem.IsFileDataCacheAttachable()) if (fileSystem.IsFileDataCacheAttachable())
{ {
@ -178,11 +178,11 @@ public static class MountUtility
{ {
UnsafeHelpers.SkipParamInit(out isMounted); UnsafeHelpers.SkipParamInit(out isMounted);
Result rc = fs.Find(out _, mountName); Result res = fs.Find(out _, mountName);
if (rc.IsFailure()) if (res.IsFailure())
{ {
if (!ResultFs.NotMounted.Includes(rc)) if (!ResultFs.NotMounted.Includes(res))
return rc; return res;
isMounted = false; isMounted = false;
} }
@ -196,52 +196,52 @@ public static class MountUtility
public static void Unmount(this FileSystemClient fs, U8Span mountName) public static void Unmount(this FileSystemClient fs, U8Span mountName)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x30]; Span<byte> logBuffer = stackalloc byte[0x30];
if (fs.Impl.IsEnabledAccessLog() && fs.Impl.IsEnabledFileSystemAccessorAccessLog(mountName)) if (fs.Impl.IsEnabledAccessLog() && fs.Impl.IsEnabledFileSystemAccessorAccessLog(mountName))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fs.Impl.Unmount(mountName); res = fs.Impl.Unmount(mountName);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogName).Append(mountName).Append((byte)'"'); sb.Append(LogName).Append(mountName).Append((byte)'"');
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = fs.Impl.Unmount(mountName); res = fs.Impl.Unmount(mountName);
} }
fs.Impl.LogResultErrorMessage(rc); fs.Impl.LogResultErrorMessage(res);
Abort.DoAbortUnless(rc.IsSuccess()); Abort.DoAbortUnless(res.IsSuccess());
} }
public static bool IsMounted(this FileSystemClient fs, U8Span mountName) public static bool IsMounted(this FileSystemClient fs, U8Span mountName)
{ {
Result rc; Result res;
bool isMounted; bool isMounted;
Span<byte> logBuffer = stackalloc byte[0x30]; Span<byte> logBuffer = stackalloc byte[0x30];
if (fs.Impl.IsEnabledAccessLog() && fs.Impl.IsEnabledFileSystemAccessorAccessLog(mountName)) if (fs.Impl.IsEnabledAccessLog() && fs.Impl.IsEnabledFileSystemAccessorAccessLog(mountName))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fs.Impl.IsMounted(out isMounted, mountName); res = fs.Impl.IsMounted(out isMounted, mountName);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
ReadOnlySpan<byte> boolString = AccessLogImpl.ConvertFromBoolToAccessLogBooleanValue(isMounted); ReadOnlySpan<byte> boolString = AccessLogImpl.ConvertFromBoolToAccessLogBooleanValue(isMounted);
sb.Append(LogName).Append(mountName).Append(LogIsMounted).Append(boolString).Append((byte)'"'); sb.Append(LogName).Append(mountName).Append(LogIsMounted).Append(boolString).Append((byte)'"');
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = fs.Impl.IsMounted(out isMounted, mountName); res = fs.Impl.IsMounted(out isMounted, mountName);
} }
fs.Impl.LogResultErrorMessage(rc); fs.Impl.LogResultErrorMessage(res);
Abort.DoAbortUnless(rc.IsSuccess()); Abort.DoAbortUnless(res.IsSuccess());
return isMounted; return isMounted;
} }
@ -249,33 +249,33 @@ public static class MountUtility
public static Result ConvertToFsCommonPath(this FileSystemClient fs, U8SpanMutable commonPathBuffer, public static Result ConvertToFsCommonPath(this FileSystemClient fs, U8SpanMutable commonPathBuffer,
U8Span path) U8Span path)
{ {
Result rc; Result res;
if (commonPathBuffer.IsNull()) if (commonPathBuffer.IsNull())
{ {
rc = ResultFs.NullptrArgument.Value; res = ResultFs.NullptrArgument.Value;
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
if (path.IsNull()) if (path.IsNull())
{ {
rc = ResultFs.NullptrArgument.Value; res = ResultFs.NullptrArgument.Value;
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
rc = GetMountNameAndSubPath(out MountName mountName, out U8Span subPath, path); res = GetMountNameAndSubPath(out MountName mountName, out U8Span subPath, path);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = fs.Impl.Find(out FileSystemAccessor fileSystem, new U8Span(mountName.Name)); res = fs.Impl.Find(out FileSystemAccessor fileSystem, new U8Span(mountName.Name));
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = fileSystem.GetCommonMountName(commonPathBuffer.Value); res = fileSystem.GetCommonMountName(commonPathBuffer.Value);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
int mountNameLength = StringUtils.GetLength(commonPathBuffer); int mountNameLength = StringUtils.GetLength(commonPathBuffer);
int commonPathLength = StringUtils.GetLength(subPath); int commonPathLength = StringUtils.GetLength(subPath);

View File

@ -110,8 +110,8 @@ public static class Registrar
using var accessor = new UniqueRef<FileSystemAccessor>(new FileSystemAccessor(fs.Hos, name, null, using var accessor = new UniqueRef<FileSystemAccessor>(new FileSystemAccessor(fs.Hos, name, null,
ref fileSystem, ref mountNameGenerator.Ref(), ref attributeGetter.Ref())); ref fileSystem, ref mountNameGenerator.Ref(), ref attributeGetter.Ref()));
Result rc = fs.Impl.Register(ref accessor.Ref()); Result res = fs.Impl.Register(ref accessor.Ref());
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -124,8 +124,8 @@ public static class Registrar
using var accessor = new UniqueRef<FileSystemAccessor>(new FileSystemAccessor(fs.Hos, name, null, using var accessor = new UniqueRef<FileSystemAccessor>(new FileSystemAccessor(fs.Hos, name, null,
ref fileSystem, ref mountNameGenerator, ref attributeGetter.Ref())); ref fileSystem, ref mountNameGenerator, ref attributeGetter.Ref()));
Result rc = fs.Impl.Register(ref accessor.Ref()); Result res = fs.Impl.Register(ref accessor.Ref());
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -137,10 +137,10 @@ public static class Registrar
using var unmountHookInvoker = new UniqueRef<IUnmountHookInvoker>(); using var unmountHookInvoker = new UniqueRef<IUnmountHookInvoker>();
using var attributeGetter = new UniqueRef<ISaveDataAttributeGetter>(); using var attributeGetter = new UniqueRef<ISaveDataAttributeGetter>();
Result rc = Register(fs, name, multiCommitTarget, ref fileSystem, ref mountNameGenerator, Result res = Register(fs, name, multiCommitTarget, ref fileSystem, ref mountNameGenerator,
ref attributeGetter.Ref(), useDataCache, storageForPurgeFileDataCache, usePathCache, ref attributeGetter.Ref(), useDataCache, storageForPurgeFileDataCache, usePathCache,
ref unmountHookInvoker.Ref()); ref unmountHookInvoker.Ref());
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -152,9 +152,9 @@ public static class Registrar
{ {
using var attributeGetter = new UniqueRef<ISaveDataAttributeGetter>(); using var attributeGetter = new UniqueRef<ISaveDataAttributeGetter>();
Result rc = Register(fs, name, multiCommitTarget, ref fileSystem, ref mountNameGenerator, Result res = Register(fs, name, multiCommitTarget, ref fileSystem, ref mountNameGenerator,
ref attributeGetter.Ref(), useDataCache, storageForPurgeFileDataCache, usePathCache, ref unmountHook); ref attributeGetter.Ref(), useDataCache, storageForPurgeFileDataCache, usePathCache, ref unmountHook);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -166,10 +166,10 @@ public static class Registrar
{ {
using var unmountHookInvoker = new UniqueRef<IUnmountHookInvoker>(); using var unmountHookInvoker = new UniqueRef<IUnmountHookInvoker>();
Result rc = Register(fs, name, multiCommitTarget, ref fileSystem, ref mountNameGenerator, Result res = Register(fs, name, multiCommitTarget, ref fileSystem, ref mountNameGenerator,
ref saveAttributeGetter, useDataCache, storageForPurgeFileDataCache, usePathCache, ref saveAttributeGetter, useDataCache, storageForPurgeFileDataCache, usePathCache,
ref unmountHookInvoker.Ref()); ref unmountHookInvoker.Ref());
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -200,8 +200,8 @@ public static class Registrar
accessor.Get.SetFileDataCacheAttachable(useDataCache, storageForPurgeFileDataCache); accessor.Get.SetFileDataCacheAttachable(useDataCache, storageForPurgeFileDataCache);
accessor.Get.SetPathBasedFileDataCacheAttachable(usePathCache); accessor.Get.SetPathBasedFileDataCacheAttachable(usePathCache);
Result rc = fs.Impl.Register(ref accessor.Ref()); Result res = fs.Impl.Register(ref accessor.Ref());
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }

View File

@ -22,12 +22,12 @@ public static class UserDirectory
public static Result ReadDirectory(this FileSystemClient fs, out long entriesRead, public static Result ReadDirectory(this FileSystemClient fs, out long entriesRead,
Span<DirectoryEntry> entryBuffer, DirectoryHandle handle) Span<DirectoryEntry> entryBuffer, DirectoryHandle handle)
{ {
Result rc; Result res;
if (fs.Impl.IsEnabledAccessLog() && fs.Impl.IsEnabledHandleAccessLog(handle)) if (fs.Impl.IsEnabledAccessLog() && fs.Impl.IsEnabledHandleAccessLog(handle))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = Get(handle).Read(out entriesRead, entryBuffer); res = Get(handle).Read(out entriesRead, entryBuffer);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
Span<byte> buffer = stackalloc byte[0x50]; Span<byte> buffer = stackalloc byte[0x50];
@ -35,40 +35,40 @@ public static class UserDirectory
sb.Append(LogEntryBufferCount).AppendFormat(entryBuffer.Length) sb.Append(LogEntryBufferCount).AppendFormat(entryBuffer.Length)
.Append(LogEntryCount).AppendFormat(entriesRead); .Append(LogEntryCount).AppendFormat(entriesRead);
fs.Impl.OutputAccessLog(rc, start, end, handle, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, handle, new U8Span(sb.Buffer));
} }
else else
{ {
rc = Get(handle).Read(out entriesRead, entryBuffer); res = Get(handle).Read(out entriesRead, entryBuffer);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static Result GetDirectoryEntryCount(this FileSystemClient fs, out long count, DirectoryHandle handle) public static Result GetDirectoryEntryCount(this FileSystemClient fs, out long count, DirectoryHandle handle)
{ {
Result rc; Result res;
if (fs.Impl.IsEnabledAccessLog() && fs.Impl.IsEnabledHandleAccessLog(handle)) if (fs.Impl.IsEnabledAccessLog() && fs.Impl.IsEnabledHandleAccessLog(handle))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = Get(handle).GetEntryCount(out count); res = Get(handle).GetEntryCount(out count);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
Span<byte> buffer = stackalloc byte[0x50]; Span<byte> buffer = stackalloc byte[0x50];
var sb = new U8StringBuilder(buffer, true); var sb = new U8StringBuilder(buffer, true);
sb.Append(LogEntryCount).AppendFormat(count); sb.Append(LogEntryCount).AppendFormat(count);
fs.Impl.OutputAccessLog(rc, start, end, handle, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, handle, new U8Span(sb.Buffer));
} }
else else
{ {
rc = Get(handle).GetEntryCount(out count); res = Get(handle).GetEntryCount(out count);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static void CloseDirectory(this FileSystemClient fs, DirectoryHandle handle) public static void CloseDirectory(this FileSystemClient fs, DirectoryHandle handle)

View File

@ -28,57 +28,57 @@ public static class UserFile
public static Result ReadFile(this FileSystemClient fs, FileHandle handle, long offset, Span<byte> destination, public static Result ReadFile(this FileSystemClient fs, FileHandle handle, long offset, Span<byte> destination,
in ReadOption option) in ReadOption option)
{ {
Result rc = ReadFileImpl(fs, out long bytesRead, handle, offset, destination, in option); Result res = ReadFileImpl(fs, out long bytesRead, handle, offset, destination, in option);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (bytesRead == destination.Length) if (bytesRead == destination.Length)
return Result.Success; return Result.Success;
rc = ResultFs.OutOfRange.Log(); res = ResultFs.OutOfRange.Log();
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static Result ReadFile(this FileSystemClient fs, FileHandle handle, long offset, Span<byte> destination) public static Result ReadFile(this FileSystemClient fs, FileHandle handle, long offset, Span<byte> destination)
{ {
Result rc = ReadFileImpl(fs, out long bytesRead, handle, offset, destination, ReadOption.None); Result res = ReadFileImpl(fs, out long bytesRead, handle, offset, destination, ReadOption.None);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (bytesRead == destination.Length) if (bytesRead == destination.Length)
return Result.Success; return Result.Success;
rc = ResultFs.OutOfRange.Log(); res = ResultFs.OutOfRange.Log();
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static Result ReadFile(this FileSystemClient fs, out long bytesRead, FileHandle handle, long offset, public static Result ReadFile(this FileSystemClient fs, out long bytesRead, FileHandle handle, long offset,
Span<byte> destination, in ReadOption option) Span<byte> destination, in ReadOption option)
{ {
Result rc = ReadFileImpl(fs, out bytesRead, handle, offset, destination, in option); Result res = ReadFileImpl(fs, out bytesRead, handle, offset, destination, in option);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static Result ReadFile(this FileSystemClient fs, out long bytesRead, FileHandle handle, long offset, public static Result ReadFile(this FileSystemClient fs, out long bytesRead, FileHandle handle, long offset,
Span<byte> destination) Span<byte> destination)
{ {
Result rc = ReadFileImpl(fs, out bytesRead, handle, offset, destination, ReadOption.None); Result res = ReadFileImpl(fs, out bytesRead, handle, offset, destination, ReadOption.None);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static Result WriteFile(this FileSystemClient fs, FileHandle handle, long offset, public static Result WriteFile(this FileSystemClient fs, FileHandle handle, long offset,
ReadOnlySpan<byte> source, in WriteOption option) ReadOnlySpan<byte> source, in WriteOption option)
{ {
Result rc; Result res;
if (fs.Impl.IsEnabledAccessLog() && fs.Impl.IsEnabledHandleAccessLog(handle)) if (fs.Impl.IsEnabledAccessLog() && fs.Impl.IsEnabledHandleAccessLog(handle))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = Get(handle).Write(offset, source, in option); res = Get(handle).Write(offset, source, in option);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
Span<byte> buffer = stackalloc byte[0x60]; Span<byte> buffer = stackalloc byte[0x60];
@ -89,87 +89,87 @@ public static class UserFile
if (option.HasFlushFlag()) if (option.HasFlushFlag())
sb.Append(LogWriteOptionFlush); sb.Append(LogWriteOptionFlush);
fs.Impl.OutputAccessLog(rc, start, end, handle, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, handle, new U8Span(sb.Buffer));
sb.Dispose(); sb.Dispose();
} }
else else
{ {
rc = Get(handle).Write(offset, source, in option); res = Get(handle).Write(offset, source, in option);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static Result FlushFile(this FileSystemClient fs, FileHandle handle) public static Result FlushFile(this FileSystemClient fs, FileHandle handle)
{ {
Result rc; Result res;
if (fs.Impl.IsEnabledAccessLog() && fs.Impl.IsEnabledHandleAccessLog(handle)) if (fs.Impl.IsEnabledAccessLog() && fs.Impl.IsEnabledHandleAccessLog(handle))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = Get(handle).Flush(); res = Get(handle).Flush();
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
fs.Impl.OutputAccessLog(rc, start, end, handle, U8Span.Empty); fs.Impl.OutputAccessLog(res, start, end, handle, U8Span.Empty);
} }
else else
{ {
rc = Get(handle).Flush(); res = Get(handle).Flush();
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static Result SetFileSize(this FileSystemClient fs, FileHandle handle, long size) public static Result SetFileSize(this FileSystemClient fs, FileHandle handle, long size)
{ {
Result rc; Result res;
if (fs.Impl.IsEnabledAccessLog() && fs.Impl.IsEnabledHandleAccessLog(handle)) if (fs.Impl.IsEnabledAccessLog() && fs.Impl.IsEnabledHandleAccessLog(handle))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = Get(handle).SetSize(size); res = Get(handle).SetSize(size);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
Span<byte> buffer = stackalloc byte[0x20]; Span<byte> buffer = stackalloc byte[0x20];
var sb = new U8StringBuilder(buffer, true); var sb = new U8StringBuilder(buffer, true);
sb.Append(LogSize).AppendFormat(size); sb.Append(LogSize).AppendFormat(size);
fs.Impl.OutputAccessLog(rc, start, end, handle, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, handle, new U8Span(sb.Buffer));
} }
else else
{ {
rc = Get(handle).SetSize(size); res = Get(handle).SetSize(size);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static Result GetFileSize(this FileSystemClient fs, out long size, FileHandle handle) public static Result GetFileSize(this FileSystemClient fs, out long size, FileHandle handle)
{ {
Result rc; Result res;
if (fs.Impl.IsEnabledAccessLog() && fs.Impl.IsEnabledHandleAccessLog(handle)) if (fs.Impl.IsEnabledAccessLog() && fs.Impl.IsEnabledHandleAccessLog(handle))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = Get(handle).GetSize(out size); res = Get(handle).GetSize(out size);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
Span<byte> buffer = stackalloc byte[0x20]; Span<byte> buffer = stackalloc byte[0x20];
var sb = new U8StringBuilder(buffer, true); var sb = new U8StringBuilder(buffer, true);
sb.Append(LogSize).AppendFormat(AccessLogImpl.DereferenceOutValue(in size, rc)); sb.Append(LogSize).AppendFormat(AccessLogImpl.DereferenceOutValue(in size, res));
fs.Impl.OutputAccessLog(rc, start, end, handle, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, handle, new U8Span(sb.Buffer));
} }
else else
{ {
rc = Get(handle).GetSize(out size); res = Get(handle).GetSize(out size);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static OpenMode GetFileOpenMode(this FileSystemClient fs, FileHandle handle) public static OpenMode GetFileOpenMode(this FileSystemClient fs, FileHandle handle)
@ -212,20 +212,20 @@ public static class UserFile
{ {
UnsafeHelpers.SkipParamInit(out rangeInfo); UnsafeHelpers.SkipParamInit(out rangeInfo);
Result rc = Get(handle).OperateRange(SpanHelpers.AsByteSpan(ref rangeInfo), OperationId.QueryRange, offset, Result res = Get(handle).OperateRange(SpanHelpers.AsByteSpan(ref rangeInfo), OperationId.QueryRange, offset,
size, ReadOnlySpan<byte>.Empty); size, ReadOnlySpan<byte>.Empty);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static Result InvalidateCache(this FileSystemClient fs, FileHandle handle) public static Result InvalidateCache(this FileSystemClient fs, FileHandle handle)
{ {
Result rc = Get(handle).OperateRange(Span<byte>.Empty, OperationId.InvalidateCache, 0, long.MaxValue, Result res = Get(handle).OperateRange(Span<byte>.Empty, OperationId.InvalidateCache, 0, long.MaxValue,
ReadOnlySpan<byte>.Empty); ReadOnlySpan<byte>.Empty);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static Result QueryUnpreparedRange(this FileSystemClient fs, out Range unpreparedRange, FileHandle handle) public static Result QueryUnpreparedRange(this FileSystemClient fs, out Range unpreparedRange, FileHandle handle)
@ -233,11 +233,11 @@ public static class UserFile
UnsafeHelpers.SkipParamInit(out unpreparedRange); UnsafeHelpers.SkipParamInit(out unpreparedRange);
Unsafe.SkipInit(out UnpreparedRangeInfo info); Unsafe.SkipInit(out UnpreparedRangeInfo info);
Result rc = Get(handle).OperateRange(SpanHelpers.AsByteSpan(ref info), OperationId.QueryUnpreparedRange, 0, 0, Result res = Get(handle).OperateRange(SpanHelpers.AsByteSpan(ref info), OperationId.QueryUnpreparedRange, 0, 0,
ReadOnlySpan<byte>.Empty); ReadOnlySpan<byte>.Empty);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
unpreparedRange = info.Range; unpreparedRange = info.Range;
return Result.Success; return Result.Success;
@ -249,11 +249,11 @@ public static class UserFile
UnsafeHelpers.SkipParamInit(out unpreparedRangeInfo); UnsafeHelpers.SkipParamInit(out unpreparedRangeInfo);
Unsafe.SkipInit(out UnpreparedRangeInfo info); Unsafe.SkipInit(out UnpreparedRangeInfo info);
Result rc = Get(handle).OperateRange(SpanHelpers.AsByteSpan(ref info), OperationId.QueryUnpreparedRange, 0, 0, Result res = Get(handle).OperateRange(SpanHelpers.AsByteSpan(ref info), OperationId.QueryUnpreparedRange, 0, 0,
ReadOnlySpan<byte>.Empty); ReadOnlySpan<byte>.Empty);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
unpreparedRangeInfo = info; unpreparedRangeInfo = info;
return Result.Success; return Result.Success;
@ -267,11 +267,11 @@ public static class UserFile
Unsafe.SkipInit(out UnpreparedRangeInfo info); Unsafe.SkipInit(out UnpreparedRangeInfo info);
var args = new LazyLoadArguments { GuideIndex = guideIndex }; var args = new LazyLoadArguments { GuideIndex = guideIndex };
Result rc = Get(handle).OperateRange(SpanHelpers.AsByteSpan(ref info), OperationId.QueryLazyLoadCompletionRate, Result res = Get(handle).OperateRange(SpanHelpers.AsByteSpan(ref info), OperationId.QueryLazyLoadCompletionRate,
0, 0, SpanHelpers.AsReadOnlyByteSpan(in args)); 0, 0, SpanHelpers.AsReadOnlyByteSpan(in args));
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
completionRate = info.CompletionRate; completionRate = info.CompletionRate;
return Result.Success; return Result.Success;
@ -282,11 +282,11 @@ public static class UserFile
{ {
Unsafe.SkipInit(out UnpreparedRangeInfo info); Unsafe.SkipInit(out UnpreparedRangeInfo info);
Result rc = Get(handle).OperateRange(SpanHelpers.AsByteSpan(ref info), OperationId.ReadyLazyLoadFile, Result res = Get(handle).OperateRange(SpanHelpers.AsByteSpan(ref info), OperationId.ReadyLazyLoadFile,
offset, size, ReadOnlySpan<byte>.Empty); offset, size, ReadOnlySpan<byte>.Empty);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }

View File

@ -25,7 +25,7 @@ public static class UserFileSystem
public static Result DeleteFile(this FileSystemClient fs, U8Span path) public static Result DeleteFile(this FileSystemClient fs, U8Span path)
{ {
Result rc; Result res;
U8Span subPath; U8Span subPath;
FileSystemAccessor fileSystem; FileSystemAccessor fileSystem;
Span<byte> logBuffer = stackalloc byte[0x300]; Span<byte> logBuffer = stackalloc byte[0x300];
@ -33,41 +33,41 @@ public static class UserFileSystem
if (fs.Impl.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fs.Impl.FindFileSystem(out fileSystem, out subPath, path); res = fs.Impl.FindFileSystem(out fileSystem, out subPath, path);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogPath).Append(path).Append((byte)'"'); sb.Append(LogPath).Append(path).Append((byte)'"');
logBuffer = sb.Buffer; logBuffer = sb.Buffer;
fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLogUnlessResultSuccess(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = fs.Impl.FindFileSystem(out fileSystem, out subPath, path); res = fs.Impl.FindFileSystem(out fileSystem, out subPath, path);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fileSystem.DeleteFile(subPath); res = fileSystem.DeleteFile(subPath);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = fileSystem.DeleteFile(subPath); res = fileSystem.DeleteFile(subPath);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static Result CreateDirectory(this FileSystemClient fs, U8Span path) public static Result CreateDirectory(this FileSystemClient fs, U8Span path)
{ {
Result rc; Result res;
U8Span subPath; U8Span subPath;
FileSystemAccessor fileSystem; FileSystemAccessor fileSystem;
Span<byte> logBuffer = stackalloc byte[0x300]; Span<byte> logBuffer = stackalloc byte[0x300];
@ -75,41 +75,41 @@ public static class UserFileSystem
if (fs.Impl.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fs.Impl.FindFileSystem(out fileSystem, out subPath, path); res = fs.Impl.FindFileSystem(out fileSystem, out subPath, path);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogPath).Append(path).Append((byte)'"'); sb.Append(LogPath).Append(path).Append((byte)'"');
logBuffer = sb.Buffer; logBuffer = sb.Buffer;
fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLogUnlessResultSuccess(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = fs.Impl.FindFileSystem(out fileSystem, out subPath, path); res = fs.Impl.FindFileSystem(out fileSystem, out subPath, path);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fileSystem.CreateDirectory(subPath); res = fileSystem.CreateDirectory(subPath);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = fileSystem.CreateDirectory(subPath); res = fileSystem.CreateDirectory(subPath);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static Result DeleteDirectory(this FileSystemClient fs, U8Span path) public static Result DeleteDirectory(this FileSystemClient fs, U8Span path)
{ {
Result rc; Result res;
U8Span subPath; U8Span subPath;
FileSystemAccessor fileSystem; FileSystemAccessor fileSystem;
Span<byte> logBuffer = stackalloc byte[0x300]; Span<byte> logBuffer = stackalloc byte[0x300];
@ -117,41 +117,41 @@ public static class UserFileSystem
if (fs.Impl.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fs.Impl.FindFileSystem(out fileSystem, out subPath, path); res = fs.Impl.FindFileSystem(out fileSystem, out subPath, path);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogPath).Append(path).Append((byte)'"'); sb.Append(LogPath).Append(path).Append((byte)'"');
logBuffer = sb.Buffer; logBuffer = sb.Buffer;
fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLogUnlessResultSuccess(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = fs.Impl.FindFileSystem(out fileSystem, out subPath, path); res = fs.Impl.FindFileSystem(out fileSystem, out subPath, path);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fileSystem.DeleteDirectory(subPath); res = fileSystem.DeleteDirectory(subPath);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = fileSystem.DeleteDirectory(subPath); res = fileSystem.DeleteDirectory(subPath);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static Result DeleteDirectoryRecursively(this FileSystemClient fs, U8Span path) public static Result DeleteDirectoryRecursively(this FileSystemClient fs, U8Span path)
{ {
Result rc; Result res;
U8Span subPath; U8Span subPath;
FileSystemAccessor fileSystem; FileSystemAccessor fileSystem;
Span<byte> logBuffer = stackalloc byte[0x300]; Span<byte> logBuffer = stackalloc byte[0x300];
@ -159,41 +159,41 @@ public static class UserFileSystem
if (fs.Impl.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fs.Impl.FindFileSystem(out fileSystem, out subPath, path); res = fs.Impl.FindFileSystem(out fileSystem, out subPath, path);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogPath).Append(path).Append((byte)'"'); sb.Append(LogPath).Append(path).Append((byte)'"');
logBuffer = sb.Buffer; logBuffer = sb.Buffer;
fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLogUnlessResultSuccess(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = fs.Impl.FindFileSystem(out fileSystem, out subPath, path); res = fs.Impl.FindFileSystem(out fileSystem, out subPath, path);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fileSystem.DeleteDirectoryRecursively(subPath); res = fileSystem.DeleteDirectoryRecursively(subPath);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = fileSystem.DeleteDirectoryRecursively(subPath); res = fileSystem.DeleteDirectoryRecursively(subPath);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static Result CleanDirectoryRecursively(this FileSystemClient fs, U8Span path) public static Result CleanDirectoryRecursively(this FileSystemClient fs, U8Span path)
{ {
Result rc; Result res;
U8Span subPath; U8Span subPath;
FileSystemAccessor fileSystem; FileSystemAccessor fileSystem;
Span<byte> logBuffer = stackalloc byte[0x300]; Span<byte> logBuffer = stackalloc byte[0x300];
@ -201,41 +201,41 @@ public static class UserFileSystem
if (fs.Impl.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fs.Impl.FindFileSystem(out fileSystem, out subPath, path); res = fs.Impl.FindFileSystem(out fileSystem, out subPath, path);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogPath).Append(path).Append((byte)'"'); sb.Append(LogPath).Append(path).Append((byte)'"');
logBuffer = sb.Buffer; logBuffer = sb.Buffer;
fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLogUnlessResultSuccess(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = fs.Impl.FindFileSystem(out fileSystem, out subPath, path); res = fs.Impl.FindFileSystem(out fileSystem, out subPath, path);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fileSystem.CleanDirectoryRecursively(subPath); res = fileSystem.CleanDirectoryRecursively(subPath);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = fileSystem.CleanDirectoryRecursively(subPath); res = fileSystem.CleanDirectoryRecursively(subPath);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static Result RenameFile(this FileSystemClient fs, U8Span currentPath, U8Span newPath) public static Result RenameFile(this FileSystemClient fs, U8Span currentPath, U8Span newPath)
{ {
Result rc; Result res;
U8Span currentSubPath, newSubPath; U8Span currentSubPath, newSubPath;
FileSystemAccessor currentFileSystem, newFileSystem; FileSystemAccessor currentFileSystem, newFileSystem;
Span<byte> logBuffer = stackalloc byte[0x300]; Span<byte> logBuffer = stackalloc byte[0x300];
@ -244,64 +244,64 @@ public static class UserFileSystem
if (fs.Impl.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fs.Impl.FindFileSystem(out currentFileSystem, out currentSubPath, currentPath); res = fs.Impl.FindFileSystem(out currentFileSystem, out currentSubPath, currentPath);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogPath).Append(currentPath).Append(LogNewPath).Append(newPath).Append((byte)'"'); sb.Append(LogPath).Append(currentPath).Append(LogNewPath).Append(newPath).Append((byte)'"');
logBuffer = sb.Buffer; logBuffer = sb.Buffer;
fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLogUnlessResultSuccess(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = fs.Impl.FindFileSystem(out currentFileSystem, out currentSubPath, currentPath); res = fs.Impl.FindFileSystem(out currentFileSystem, out currentSubPath, currentPath);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Get the file system accessor for the new path // Get the file system accessor for the new path
if (fs.Impl.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fs.Impl.FindFileSystem(out newFileSystem, out newSubPath, newPath); res = fs.Impl.FindFileSystem(out newFileSystem, out newSubPath, newPath);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLogUnlessResultSuccess(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = fs.Impl.FindFileSystem(out newFileSystem, out newSubPath, newPath); res = fs.Impl.FindFileSystem(out newFileSystem, out newSubPath, newPath);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Rename the file // Rename the file
if (fs.Impl.IsEnabledAccessLog() && currentFileSystem.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog() && currentFileSystem.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = currentFileSystem != newFileSystem res = currentFileSystem != newFileSystem
? ResultFs.RenameToOtherFileSystem.Log() ? ResultFs.RenameToOtherFileSystem.Log()
: currentFileSystem.RenameFile(currentSubPath, newSubPath); : currentFileSystem.RenameFile(currentSubPath, newSubPath);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = currentFileSystem != newFileSystem res = currentFileSystem != newFileSystem
? ResultFs.RenameToOtherFileSystem.Log() ? ResultFs.RenameToOtherFileSystem.Log()
: currentFileSystem.RenameFile(currentSubPath, newSubPath); : currentFileSystem.RenameFile(currentSubPath, newSubPath);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static Result RenameDirectory(this FileSystemClient fs, U8Span currentPath, U8Span newPath) public static Result RenameDirectory(this FileSystemClient fs, U8Span currentPath, U8Span newPath)
{ {
Result rc; Result res;
U8Span currentSubPath, newSubPath; U8Span currentSubPath, newSubPath;
FileSystemAccessor currentFileSystem, newFileSystem; FileSystemAccessor currentFileSystem, newFileSystem;
Span<byte> logBuffer = stackalloc byte[0x300]; Span<byte> logBuffer = stackalloc byte[0x300];
@ -310,66 +310,66 @@ public static class UserFileSystem
if (fs.Impl.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fs.Impl.FindFileSystem(out currentFileSystem, out currentSubPath, currentPath); res = fs.Impl.FindFileSystem(out currentFileSystem, out currentSubPath, currentPath);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogPath).Append(currentPath).Append(LogNewPath).Append(newPath).Append((byte)'"'); sb.Append(LogPath).Append(currentPath).Append(LogNewPath).Append(newPath).Append((byte)'"');
logBuffer = sb.Buffer; logBuffer = sb.Buffer;
fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLogUnlessResultSuccess(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = fs.Impl.FindFileSystem(out currentFileSystem, out currentSubPath, currentPath); res = fs.Impl.FindFileSystem(out currentFileSystem, out currentSubPath, currentPath);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Get the file system accessor for the new path // Get the file system accessor for the new path
if (fs.Impl.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fs.Impl.FindFileSystem(out newFileSystem, out newSubPath, newPath); res = fs.Impl.FindFileSystem(out newFileSystem, out newSubPath, newPath);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLogUnlessResultSuccess(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = fs.Impl.FindFileSystem(out newFileSystem, out newSubPath, newPath); res = fs.Impl.FindFileSystem(out newFileSystem, out newSubPath, newPath);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Rename the directory // Rename the directory
if (fs.Impl.IsEnabledAccessLog() && currentFileSystem.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog() && currentFileSystem.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = currentFileSystem != newFileSystem res = currentFileSystem != newFileSystem
? ResultFs.RenameToOtherFileSystem.Log() ? ResultFs.RenameToOtherFileSystem.Log()
: currentFileSystem.RenameDirectory(currentSubPath, newSubPath); : currentFileSystem.RenameDirectory(currentSubPath, newSubPath);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = currentFileSystem != newFileSystem res = currentFileSystem != newFileSystem
? ResultFs.RenameToOtherFileSystem.Log() ? ResultFs.RenameToOtherFileSystem.Log()
: currentFileSystem.RenameDirectory(currentSubPath, newSubPath); : currentFileSystem.RenameDirectory(currentSubPath, newSubPath);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static Result GetEntryType(this FileSystemClient fs, out DirectoryEntryType type, U8Span path) public static Result GetEntryType(this FileSystemClient fs, out DirectoryEntryType type, U8Span path)
{ {
UnsafeHelpers.SkipParamInit(out type); UnsafeHelpers.SkipParamInit(out type);
Result rc; Result res;
U8Span subPath; U8Span subPath;
FileSystemAccessor fileSystem; FileSystemAccessor fileSystem;
Span<byte> logBuffer = stackalloc byte[0x300]; Span<byte> logBuffer = stackalloc byte[0x300];
@ -377,51 +377,51 @@ public static class UserFileSystem
if (fs.Impl.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fs.Impl.FindFileSystem(out fileSystem, out subPath, path); res = fs.Impl.FindFileSystem(out fileSystem, out subPath, path);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var idString = new IdString(); var idString = new IdString();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogPath).Append(path).Append(LogEntryType) sb.Append(LogPath).Append(path).Append(LogEntryType)
.Append(idString.ToString(AccessLogImpl.DereferenceOutValue(in type, rc))); .Append(idString.ToString(AccessLogImpl.DereferenceOutValue(in type, res)));
logBuffer = sb.Buffer; logBuffer = sb.Buffer;
fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLogUnlessResultSuccess(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = fs.Impl.FindFileSystem(out fileSystem, out subPath, path); res = fs.Impl.FindFileSystem(out fileSystem, out subPath, path);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fileSystem.GetEntryType(out type, subPath); res = fileSystem.GetEntryType(out type, subPath);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var idString = new IdString(); var idString = new IdString();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogPath).Append(path).Append(LogEntryType) sb.Append(LogPath).Append(path).Append(LogEntryType)
.Append(idString.ToString(AccessLogImpl.DereferenceOutValue(in type, rc))); .Append(idString.ToString(AccessLogImpl.DereferenceOutValue(in type, res)));
logBuffer = sb.Buffer; logBuffer = sb.Buffer;
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = fileSystem.GetEntryType(out type, subPath); res = fileSystem.GetEntryType(out type, subPath);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static Result GetFreeSpaceSize(this FileSystemClient fs, out long freeSpace, U8Span path) public static Result GetFreeSpaceSize(this FileSystemClient fs, out long freeSpace, U8Span path)
{ {
UnsafeHelpers.SkipParamInit(out freeSpace); UnsafeHelpers.SkipParamInit(out freeSpace);
Result rc; Result res;
var subPath = U8Span.Empty; var subPath = U8Span.Empty;
FileSystemAccessor fileSystem; FileSystemAccessor fileSystem;
Span<byte> logBuffer = stackalloc byte[0x300]; Span<byte> logBuffer = stackalloc byte[0x300];
@ -437,22 +437,22 @@ public static class UserFileSystem
if (fs.Impl.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = FindImpl(fs, path, out fileSystem, ref subPath); res = FindImpl(fs, path, out fileSystem, ref subPath);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogPath).Append(path).Append((byte)'"').Append(LogSize) sb.Append(LogPath).Append(path).Append((byte)'"').Append(LogSize)
.AppendFormat(AccessLogImpl.DereferenceOutValue(in freeSpace, rc)); .AppendFormat(AccessLogImpl.DereferenceOutValue(in freeSpace, res));
logBuffer = sb.Buffer; logBuffer = sb.Buffer;
fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLogUnlessResultSuccess(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = FindImpl(fs, path, out fileSystem, ref subPath); res = FindImpl(fs, path, out fileSystem, ref subPath);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
static Result GetImpl(out long freeSpace, FileSystemAccessor fileSystem, U8Span subPath) static Result GetImpl(out long freeSpace, FileSystemAccessor fileSystem, U8Span subPath)
{ {
@ -467,29 +467,29 @@ public static class UserFileSystem
if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = GetImpl(out freeSpace, fileSystem, subPath); res = GetImpl(out freeSpace, fileSystem, subPath);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogPath).Append(path).Append((byte)'"').Append(LogSize) sb.Append(LogPath).Append(path).Append((byte)'"').Append(LogSize)
.AppendFormat(AccessLogImpl.DereferenceOutValue(in freeSpace, rc)); .AppendFormat(AccessLogImpl.DereferenceOutValue(in freeSpace, res));
logBuffer = sb.Buffer; logBuffer = sb.Buffer;
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = GetImpl(out freeSpace, fileSystem, subPath); res = GetImpl(out freeSpace, fileSystem, subPath);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static Result OpenFile(this FileSystemClient fs, out FileHandle handle, U8Span path, OpenMode mode) public static Result OpenFile(this FileSystemClient fs, out FileHandle handle, U8Span path, OpenMode mode)
{ {
UnsafeHelpers.SkipParamInit(out handle); UnsafeHelpers.SkipParamInit(out handle);
Result rc; Result res;
U8Span subPath; U8Span subPath;
FileSystemAccessor fileSystem; FileSystemAccessor fileSystem;
Span<byte> logBuffer = stackalloc byte[0x300]; Span<byte> logBuffer = stackalloc byte[0x300];
@ -497,37 +497,37 @@ public static class UserFileSystem
if (fs.Impl.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fs.Impl.FindFileSystem(out fileSystem, out subPath, path); res = fs.Impl.FindFileSystem(out fileSystem, out subPath, path);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogPath).Append(path).Append((byte)'"').Append(LogOpenMode).AppendFormat((int)mode, 'X'); sb.Append(LogPath).Append(path).Append((byte)'"').Append(LogOpenMode).AppendFormat((int)mode, 'X');
logBuffer = sb.Buffer; logBuffer = sb.Buffer;
fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLogUnlessResultSuccess(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = fs.Impl.FindFileSystem(out fileSystem, out subPath, path); res = fs.Impl.FindFileSystem(out fileSystem, out subPath, path);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var file = new UniqueRef<FileAccessor>(); using var file = new UniqueRef<FileAccessor>();
if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fileSystem.OpenFile(ref file.Ref(), subPath, mode); res = fileSystem.OpenFile(ref file.Ref(), subPath, mode);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
fs.Impl.OutputAccessLog(rc, start, end, file.Get, new U8Span(logBuffer)); fs.Impl.OutputAccessLog(res, start, end, file.Get, new U8Span(logBuffer));
} }
else else
{ {
rc = fileSystem.OpenFile(ref file.Ref(), subPath, mode); res = fileSystem.OpenFile(ref file.Ref(), subPath, mode);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
handle = new FileHandle(file.Release()); handle = new FileHandle(file.Release());
return Result.Success; return Result.Success;
@ -546,7 +546,7 @@ public static class UserFileSystem
{ {
UnsafeHelpers.SkipParamInit(out handle); UnsafeHelpers.SkipParamInit(out handle);
Result rc; Result res;
U8Span subPath; U8Span subPath;
FileSystemAccessor fileSystem; FileSystemAccessor fileSystem;
Span<byte> logBuffer = stackalloc byte[0x300]; Span<byte> logBuffer = stackalloc byte[0x300];
@ -554,38 +554,38 @@ public static class UserFileSystem
if (fs.Impl.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fs.Impl.FindFileSystem(out fileSystem, out subPath, path); res = fs.Impl.FindFileSystem(out fileSystem, out subPath, path);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogPath).Append(path).Append((byte)'"').Append(LogOpenMode).AppendFormat((int)mode, 'X'); sb.Append(LogPath).Append(path).Append((byte)'"').Append(LogOpenMode).AppendFormat((int)mode, 'X');
logBuffer = sb.Buffer; logBuffer = sb.Buffer;
fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLogUnlessResultSuccess(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = fs.Impl.FindFileSystem(out fileSystem, out subPath, path); res = fs.Impl.FindFileSystem(out fileSystem, out subPath, path);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var accessor = new UniqueRef<DirectoryAccessor>(); using var accessor = new UniqueRef<DirectoryAccessor>();
if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fileSystem.OpenDirectory(ref accessor.Ref(), subPath, mode); res = fileSystem.OpenDirectory(ref accessor.Ref(), subPath, mode);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
fs.Impl.OutputAccessLog(rc, start, end, accessor.Get, new U8Span(logBuffer)); fs.Impl.OutputAccessLog(res, start, end, accessor.Get, new U8Span(logBuffer));
} }
else else
{ {
rc = fileSystem.OpenDirectory(ref accessor.Ref(), subPath, mode); res = fileSystem.OpenDirectory(ref accessor.Ref(), subPath, mode);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
handle = new DirectoryHandle(accessor.Release()); handle = new DirectoryHandle(accessor.Release());
return Result.Success; return Result.Success;
@ -594,43 +594,43 @@ public static class UserFileSystem
private static Result CommitImpl(FileSystemClient fs, U8Span mountName, private static Result CommitImpl(FileSystemClient fs, U8Span mountName,
[CallerMemberName] string functionName = "") [CallerMemberName] string functionName = "")
{ {
Result rc; Result res;
FileSystemAccessor fileSystem; FileSystemAccessor fileSystem;
Span<byte> logBuffer = stackalloc byte[0x30]; Span<byte> logBuffer = stackalloc byte[0x30];
if (fs.Impl.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fs.Impl.Find(out fileSystem, mountName); res = fs.Impl.Find(out fileSystem, mountName);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogName).Append(mountName).Append((byte)'"'); sb.Append(LogName).Append(mountName).Append((byte)'"');
logBuffer = sb.Buffer; logBuffer = sb.Buffer;
fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(logBuffer), functionName); fs.Impl.OutputAccessLogUnlessResultSuccess(res, start, end, null, new U8Span(logBuffer), functionName);
} }
else else
{ {
rc = fs.Impl.Find(out fileSystem, mountName); res = fs.Impl.Find(out fileSystem, mountName);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fileSystem.Commit(); res = fileSystem.Commit();
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(logBuffer), functionName); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(logBuffer), functionName);
} }
else else
{ {
rc = fileSystem.Commit(); res = fileSystem.Commit();
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static Result Commit(this FileSystemClient fs, ReadOnlySpan<U8String> mountNames) public static Result Commit(this FileSystemClient fs, ReadOnlySpan<U8String> mountNames)
@ -649,67 +649,67 @@ public static class UserFileSystem
using var commitManager = new SharedRef<IMultiCommitManager>(); using var commitManager = new SharedRef<IMultiCommitManager>();
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.OpenMultiCommitManager(ref commitManager.Ref()); Result res = fileSystemProxy.Get.OpenMultiCommitManager(ref commitManager.Ref());
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
for (int i = 0; i < mountNames.Length; i++) for (int i = 0; i < mountNames.Length; i++)
{ {
rc = fs.Impl.Find(out FileSystemAccessor accessor, mountNames[i]); res = fs.Impl.Find(out FileSystemAccessor accessor, mountNames[i]);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using SharedRef<IFileSystemSf> fileSystem = accessor.GetMultiCommitTarget(); using SharedRef<IFileSystemSf> fileSystem = accessor.GetMultiCommitTarget();
if (!fileSystem.HasValue) if (!fileSystem.HasValue)
return ResultFs.UnsupportedCommitTarget.Log(); return ResultFs.UnsupportedCommitTarget.Log();
rc = commitManager.Get.Add(ref fileSystem.Ref()); res = commitManager.Get.Add(ref fileSystem.Ref());
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
rc = commitManager.Get.Commit(); res = commitManager.Get.Commit();
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
public static Result Commit(this FileSystemClient fs, U8Span mountName, CommitOption option) public static Result Commit(this FileSystemClient fs, U8Span mountName, CommitOption option)
{ {
Result rc; Result res;
FileSystemAccessor fileSystem; FileSystemAccessor fileSystem;
Span<byte> logBuffer = stackalloc byte[0x40]; Span<byte> logBuffer = stackalloc byte[0x40];
if (fs.Impl.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fs.Impl.Find(out fileSystem, mountName); res = fs.Impl.Find(out fileSystem, mountName);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogName).Append(mountName).Append(LogCommitOption).AppendFormat((int)option.Flags, 'X'); sb.Append(LogName).Append(mountName).Append(LogCommitOption).AppendFormat((int)option.Flags, 'X');
logBuffer = sb.Buffer; logBuffer = sb.Buffer;
fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLogUnlessResultSuccess(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = fs.Impl.Find(out fileSystem, mountName); res = fs.Impl.Find(out fileSystem, mountName);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = RunCommit(fs, option, fileSystem); res = RunCommit(fs, option, fileSystem);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = RunCommit(fs, option, fileSystem); res = RunCommit(fs, option, fileSystem);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
static Result RunCommit(FileSystemClient fs, CommitOption option, FileSystemAccessor fileSystem) static Result RunCommit(FileSystemClient fs, CommitOption option, FileSystemAccessor fileSystem)
{ {
@ -724,8 +724,8 @@ public static class UserFileSystem
return ResultFs.InvalidCommitOption.Log(); return ResultFs.InvalidCommitOption.Log();
} }
Result rc = fileSystem.GetSaveDataAttribute(out SaveDataAttribute attribute); Result res = fileSystem.GetSaveDataAttribute(out SaveDataAttribute attribute);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (attribute.ProgramId == SaveData.InvalidProgramId) if (attribute.ProgramId == SaveData.InvalidProgramId)
attribute.ProgramId = SaveData.AutoResolveCallerProgramId; attribute.ProgramId = SaveData.AutoResolveCallerProgramId;

View File

@ -14,8 +14,8 @@ public static class UserFileSystemForDebug
{ {
UnsafeHelpers.SkipParamInit(out timeStamp); UnsafeHelpers.SkipParamInit(out timeStamp);
Result rc = fs.FindFileSystem(out FileSystemAccessor fileSystem, out U8Span subPath, path); Result res = fs.FindFileSystem(out FileSystemAccessor fileSystem, out U8Span subPath, path);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return fileSystem.GetFileTimeStampRaw(out timeStamp, subPath); return fileSystem.GetFileTimeStampRaw(out timeStamp, subPath);
} }
@ -23,8 +23,8 @@ public static class UserFileSystemForDebug
public static Result GetFileTimeStampRawForDebug(this FileSystemClient fs, out FileTimeStampRaw timeStamp, public static Result GetFileTimeStampRawForDebug(this FileSystemClient fs, out FileTimeStampRaw timeStamp,
U8Span path) U8Span path)
{ {
Result rc = fs.Impl.GetFileTimeStampRawForDebug(out timeStamp, path); Result res = fs.Impl.GetFileTimeStampRawForDebug(out timeStamp, path);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
} }

View File

@ -14,7 +14,7 @@ public static class UserFileSystemPrivate
{ {
public static Result CreateFile(this FileSystemClient fs, U8Span path, long size, CreateFileOptions option) public static Result CreateFile(this FileSystemClient fs, U8Span path, long size, CreateFileOptions option)
{ {
Result rc; Result res;
U8Span subPath; U8Span subPath;
FileSystemAccessor fileSystem; FileSystemAccessor fileSystem;
Span<byte> logBuffer = stackalloc byte[0x300]; Span<byte> logBuffer = stackalloc byte[0x300];
@ -22,65 +22,65 @@ public static class UserFileSystemPrivate
if (fs.Impl.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fs.Impl.FindFileSystem(out fileSystem, out subPath, path); res = fs.Impl.FindFileSystem(out fileSystem, out subPath, path);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogPath).Append(path).Append((byte)'"'); sb.Append(LogPath).Append(path).Append((byte)'"');
logBuffer = sb.Buffer; logBuffer = sb.Buffer;
fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLogUnlessResultSuccess(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = fs.Impl.FindFileSystem(out fileSystem, out subPath, path); res = fs.Impl.FindFileSystem(out fileSystem, out subPath, path);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog()) if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog())
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fileSystem.CreateFile(subPath, size, option); res = fileSystem.CreateFile(subPath, size, option);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogPath).Append(path).Append((byte)'"').Append(LogSize).AppendFormat(size); sb.Append(LogPath).Append(path).Append((byte)'"').Append(LogSize).AppendFormat(size);
logBuffer = sb.Buffer; logBuffer = sb.Buffer;
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = fileSystem.CreateFile(subPath, size, option); res = fileSystem.CreateFile(subPath, size, option);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static Result GetTotalSpaceSize(this FileSystemClient fs, out long totalSpace, U8Span path) public static Result GetTotalSpaceSize(this FileSystemClient fs, out long totalSpace, U8Span path)
{ {
UnsafeHelpers.SkipParamInit(out totalSpace); UnsafeHelpers.SkipParamInit(out totalSpace);
Result rc = fs.Impl.FindFileSystem(out FileSystemAccessor fileSystem, out U8Span subPath, path); Result res = fs.Impl.FindFileSystem(out FileSystemAccessor fileSystem, out U8Span subPath, path);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = fileSystem.GetTotalSpaceSize(out totalSpace, subPath); res = fileSystem.GetTotalSpaceSize(out totalSpace, subPath);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static Result SetConcatenationFileAttribute(this FileSystemClient fs, U8Span path) public static Result SetConcatenationFileAttribute(this FileSystemClient fs, U8Span path)
{ {
Result rc = fs.Impl.FindFileSystem(out FileSystemAccessor fileSystem, out U8Span subPath, path); Result res = fs.Impl.FindFileSystem(out FileSystemAccessor fileSystem, out U8Span subPath, path);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = fileSystem.QueryEntry(Span<byte>.Empty, ReadOnlySpan<byte>.Empty, QueryId.SetConcatenationFileAttribute, res = fileSystem.QueryEntry(Span<byte>.Empty, ReadOnlySpan<byte>.Empty, QueryId.SetConcatenationFileAttribute,
subPath); subPath);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static Result QueryUnpreparedFileInformation(this FileSystemClient fs, out UnpreparedFileInformation info, public static Result QueryUnpreparedFileInformation(this FileSystemClient fs, out UnpreparedFileInformation info,
@ -88,13 +88,13 @@ public static class UserFileSystemPrivate
{ {
UnsafeHelpers.SkipParamInit(out info); UnsafeHelpers.SkipParamInit(out info);
Result rc = fs.Impl.FindFileSystem(out FileSystemAccessor fileSystem, out _, path); Result res = fs.Impl.FindFileSystem(out FileSystemAccessor fileSystem, out _, path);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = fileSystem.QueryEntry(SpanHelpers.AsByteSpan(ref info), ReadOnlySpan<byte>.Empty, res = fileSystem.QueryEntry(SpanHelpers.AsByteSpan(ref info), ReadOnlySpan<byte>.Empty,
QueryId.QueryUnpreparedFileInformation, new U8Span(new[] { (byte)'/' })); QueryId.QueryUnpreparedFileInformation, new U8Span(new[] { (byte)'/' }));
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
} }

View File

@ -93,8 +93,8 @@ public abstract class IStorage : IDisposable
public static Result CheckAccessRange(long offset, ulong size, long totalSize) public static Result CheckAccessRange(long offset, ulong size, long totalSize)
{ {
Result rc = CheckAccessRange(offset, unchecked((long)size), totalSize); Result res = CheckAccessRange(offset, unchecked((long)size), totalSize);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -115,17 +115,17 @@ public abstract class IStorage : IDisposable
public static Result CheckOffsetAndSize(long offset, ulong size) public static Result CheckOffsetAndSize(long offset, ulong size)
{ {
Result rc = CheckOffsetAndSize(offset, unchecked((long)size)); Result res = CheckOffsetAndSize(offset, unchecked((long)size));
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
public static Result CheckOffsetAndSizeWithResult(long offset, long size, Result resultOnFailure) public static Result CheckOffsetAndSizeWithResult(long offset, long size, Result resultOnFailure)
{ {
Result rc = CheckOffsetAndSize(offset, size); Result res = CheckOffsetAndSize(offset, size);
if (rc.IsFailure()) if (res.IsFailure())
return resultOnFailure.Log(); return resultOnFailure.Log();
return Result.Success; return Result.Success;
@ -133,9 +133,9 @@ public abstract class IStorage : IDisposable
public static Result CheckOffsetAndSizeWithResult(long offset, ulong size, Result resultOnFailure) public static Result CheckOffsetAndSizeWithResult(long offset, ulong size, Result resultOnFailure)
{ {
Result rc = CheckOffsetAndSize(offset, size); Result res = CheckOffsetAndSize(offset, size);
if (rc.IsFailure()) if (res.IsFailure())
return resultOnFailure.Log(); return resultOnFailure.Log();
return Result.Success; return Result.Success;

View File

@ -22,8 +22,8 @@ public class MemoryStorage : IStorage
if (destination.Length == 0) if (destination.Length == 0)
return Result.Success; return Result.Success;
Result rc = CheckAccessRange(offset, destination.Length, _storageBuffer.Length); Result res = CheckAccessRange(offset, destination.Length, _storageBuffer.Length);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
_storageBuffer.AsSpan((int)offset, destination.Length).CopyTo(destination); _storageBuffer.AsSpan((int)offset, destination.Length).CopyTo(destination);
@ -35,8 +35,8 @@ public class MemoryStorage : IStorage
if (source.Length == 0) if (source.Length == 0)
return Result.Success; return Result.Success;
Result rc = CheckAccessRange(offset, source.Length, _storageBuffer.Length); Result res = CheckAccessRange(offset, source.Length, _storageBuffer.Length);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
source.CopyTo(_storageBuffer.AsSpan((int)offset)); source.CopyTo(_storageBuffer.AsSpan((int)offset));

View File

@ -97,8 +97,8 @@ public class ReadOnlyFileSystem : IFileSystem
return ResultFs.InvalidModeForFileOpen.Log(); return ResultFs.InvalidModeForFileOpen.Log();
using var baseFile = new UniqueRef<IFile>(); using var baseFile = new UniqueRef<IFile>();
Result rc = _baseFileSystem.Get.OpenFile(ref baseFile.Ref(), in path, mode); Result res = _baseFileSystem.Get.OpenFile(ref baseFile.Ref(), in path, mode);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
outFile.Reset(new ReadOnlyFile(ref baseFile.Ref())); outFile.Reset(new ReadOnlyFile(ref baseFile.Ref()));
return Result.Success; return Result.Success;

View File

@ -20,12 +20,12 @@ public static class Application
{ {
public static Result MountApplicationPackage(this FileSystemClient fs, U8Span mountName, U8Span path) public static Result MountApplicationPackage(this FileSystemClient fs, U8Span mountName, U8Span path)
{ {
Result rc; Result res;
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = Mount(fs, mountName, path); res = Mount(fs, mountName, path);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
Span<byte> logBuffer = stackalloc byte[0x300]; Span<byte> logBuffer = stackalloc byte[0x300];
@ -34,15 +34,15 @@ public static class Application
sb.Append(LogName).Append(mountName).Append(LogQuote) sb.Append(LogName).Append(mountName).Append(LogQuote)
.Append(LogPath).Append(path).Append(LogQuote); .Append(LogPath).Append(path).Append(LogQuote);
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = Mount(fs, mountName, path); res = Mount(fs, mountName, path);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName); fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
@ -51,18 +51,18 @@ public static class Application
static Result Mount(FileSystemClient fs, U8Span mountName, U8Span path) static Result Mount(FileSystemClient fs, U8Span mountName, U8Span path)
{ {
Result rc = fs.Impl.CheckMountName(mountName); Result res = fs.Impl.CheckMountName(mountName);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = PathUtility.ConvertToFspPath(out FspPath sfPath, path); res = PathUtility.ConvertToFspPath(out FspPath sfPath, path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var fileSystem = new SharedRef<IFileSystemSf>(); using var fileSystem = new SharedRef<IFileSystemSf>();
rc = fileSystemProxy.Get.OpenFileSystemWithId(ref fileSystem.Ref(), in sfPath, res = fileSystemProxy.Get.OpenFileSystemWithId(ref fileSystem.Ref(), in sfPath,
Ncm.ProgramId.InvalidId.Value, FileSystemProxyType.Package); Ncm.ProgramId.InvalidId.Value, FileSystemProxyType.Package);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var fileSystemAdapter = using var fileSystemAdapter =
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref())); new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref()));
@ -70,8 +70,8 @@ public static class Application
if (!fileSystemAdapter.HasValue) if (!fileSystemAdapter.HasValue)
return ResultFs.AllocationMemoryFailedInApplicationA.Log(); return ResultFs.AllocationMemoryFailedInApplicationA.Log();
rc = fs.Register(mountName, ref fileSystemAdapter.Ref()); res = fs.Register(mountName, ref fileSystemAdapter.Ref());
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }

View File

@ -19,8 +19,8 @@ public static class BaseFileSystem
{ {
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.OpenBaseFileSystem(ref outFileSystem, fileSystemId); Result res = fileSystemProxy.Get.OpenBaseFileSystem(ref outFileSystem, fileSystemId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -31,26 +31,26 @@ public static class BaseFileSystem
using var fileSystemAdapter = using var fileSystemAdapter =
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref())); new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref()));
Result rc = fs.Register(mountName, ref fileSystemAdapter.Ref()); Result res = fs.Register(mountName, ref fileSystemAdapter.Ref());
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
public static Result MountBaseFileSystem(this FileSystemClient fs, U8Span mountName, BaseFileSystemId fileSystemId) public static Result MountBaseFileSystem(this FileSystemClient fs, U8Span mountName, BaseFileSystemId fileSystemId)
{ {
Result rc = fs.Impl.CheckMountName(mountName); Result res = fs.Impl.CheckMountName(mountName);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
using var fileSystem = new SharedRef<IFileSystemSf>(); using var fileSystem = new SharedRef<IFileSystemSf>();
rc = OpenBaseFileSystem(fs, ref fileSystem.Ref(), fileSystemId); res = OpenBaseFileSystem(fs, ref fileSystem.Ref(), fileSystemId);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = RegisterFileSystem(fs, mountName, ref fileSystem.Ref()); res = RegisterFileSystem(fs, mountName, ref fileSystem.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -59,9 +59,9 @@ public static class BaseFileSystem
{ {
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.FormatBaseFileSystem(fileSystemId); Result res = fileSystemProxy.Get.FormatBaseFileSystem(fileSystemId);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }

View File

@ -23,12 +23,12 @@ public static class BcatSaveData
public static Result MountBcatSaveData(this FileSystemClient fs, U8Span mountName, public static Result MountBcatSaveData(this FileSystemClient fs, U8Span mountName,
Ncm.ApplicationId applicationId) Ncm.ApplicationId applicationId)
{ {
Result rc; Result res;
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = Mount(fs, mountName, applicationId); res = Mount(fs, mountName, applicationId);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
Span<byte> logBuffer = stackalloc byte[0x50]; Span<byte> logBuffer = stackalloc byte[0x50];
@ -37,15 +37,15 @@ public static class BcatSaveData
sb.Append(LogName).Append(mountName).Append(LogQuote) sb.Append(LogName).Append(mountName).Append(LogQuote)
.Append(LogApplicationId).AppendFormat(applicationId.Value, 'X'); .Append(LogApplicationId).AppendFormat(applicationId.Value, 'X');
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = Mount(fs, mountName, applicationId); res = Mount(fs, mountName, applicationId);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName); fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
@ -54,19 +54,19 @@ public static class BcatSaveData
static Result Mount(FileSystemClient fs, U8Span mountName, Ncm.ApplicationId applicationId) static Result Mount(FileSystemClient fs, U8Span mountName, Ncm.ApplicationId applicationId)
{ {
Result rc = fs.Impl.CheckMountName(mountName); Result res = fs.Impl.CheckMountName(mountName);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
rc = SaveDataAttribute.Make(out SaveDataAttribute attribute, applicationId, SaveDataType.Bcat, res = SaveDataAttribute.Make(out SaveDataAttribute attribute, applicationId, SaveDataType.Bcat,
InvalidUserId, InvalidSystemSaveDataId); InvalidUserId, InvalidSystemSaveDataId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var fileSystem = new SharedRef<IFileSystemSf>(); using var fileSystem = new SharedRef<IFileSystemSf>();
rc = fileSystemProxy.Get.OpenSaveDataFileSystem(ref fileSystem.Ref(), SaveDataSpaceId.User, in attribute); res = fileSystemProxy.Get.OpenSaveDataFileSystem(ref fileSystem.Ref(), SaveDataSpaceId.User, in attribute);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var fileSystemAdapter = using var fileSystemAdapter =
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref())); new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref()));
@ -74,8 +74,8 @@ public static class BcatSaveData
if (!fileSystemAdapter.HasValue) if (!fileSystemAdapter.HasValue)
return ResultFs.AllocationMemoryFailedInBcatSaveDataA.Log(); return ResultFs.AllocationMemoryFailedInBcatSaveDataA.Log();
rc = fs.Register(mountName, ref fileSystemAdapter.Ref()); res = fs.Register(mountName, ref fileSystemAdapter.Ref());
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }

View File

@ -55,12 +55,12 @@ public static class Bis
private static Result MountBis(this FileSystemClientImpl fs, U8Span mountName, BisPartitionId partitionId, private static Result MountBis(this FileSystemClientImpl fs, U8Span mountName, BisPartitionId partitionId,
U8Span rootPath) U8Span rootPath)
{ {
Result rc; Result res;
if (fs.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.IsEnabledAccessLog(AccessLogTarget.System))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = Mount(fs, mountName, partitionId); res = Mount(fs, mountName, partitionId);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
Span<byte> logBuffer = stackalloc byte[0x300]; Span<byte> logBuffer = stackalloc byte[0x300];
@ -71,15 +71,15 @@ public static class Bis
.Append(LogBisPartitionId).Append(idString.ToString(partitionId)) .Append(LogBisPartitionId).Append(idString.ToString(partitionId))
.Append(LogPath).Append(rootPath).Append(LogQuote); .Append(LogPath).Append(rootPath).Append(LogQuote);
fs.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = Mount(fs, mountName, partitionId); res = Mount(fs, mountName, partitionId);
} }
fs.AbortIfNeeded(rc); fs.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.IsEnabledAccessLog(AccessLogTarget.System))
fs.EnableFileSystemAccessorAccessLog(mountName); fs.EnableFileSystemAccessorAccessLog(mountName);
@ -88,8 +88,8 @@ public static class Bis
static Result Mount(FileSystemClientImpl fs, U8Span mountName, BisPartitionId partitionId) static Result Mount(FileSystemClientImpl fs, U8Span mountName, BisPartitionId partitionId)
{ {
Result rc = fs.CheckMountNameAcceptingReservedMountName(mountName); Result res = fs.CheckMountNameAcceptingReservedMountName(mountName);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.GetFileSystemProxyServiceObject();
@ -98,8 +98,8 @@ public static class Bis
using var fileSystem = new SharedRef<IFileSystemSf>(); using var fileSystem = new SharedRef<IFileSystemSf>();
rc = fileSystemProxy.Get.OpenBisFileSystem(ref fileSystem.Ref(), in sfPath, partitionId); res = fileSystemProxy.Get.OpenBisFileSystem(ref fileSystem.Ref(), in sfPath, partitionId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
using var mountNameGenerator = using var mountNameGenerator =
new UniqueRef<ICommonMountNameGenerator>(new BisCommonMountNameGenerator(partitionId)); new UniqueRef<ICommonMountNameGenerator>(new BisCommonMountNameGenerator(partitionId));
@ -113,8 +113,8 @@ public static class Bis
if (!fileSystemAdapter.HasValue) if (!fileSystemAdapter.HasValue)
return ResultFs.AllocationMemoryFailedInBisB.Log(); return ResultFs.AllocationMemoryFailedInBisB.Log();
rc = fs.Fs.Register(mountName, ref fileSystemAdapter.Ref(), ref mountNameGenerator.Ref()); res = fs.Fs.Register(mountName, ref fileSystemAdapter.Ref(), ref mountNameGenerator.Ref());
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -170,17 +170,17 @@ public static class Bis
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var storage = new SharedRef<IStorageSf>(); using var storage = new SharedRef<IStorageSf>();
Result rc = fileSystemProxy.Get.OpenBisStorage(ref storage.Ref(), partitionId); Result res = fileSystemProxy.Get.OpenBisStorage(ref storage.Ref(), partitionId);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
using var storageAdapter = new UniqueRef<IStorage>(new StorageServiceObjectAdapter(ref storage.Ref())); using var storageAdapter = new UniqueRef<IStorage>(new StorageServiceObjectAdapter(ref storage.Ref()));
if (!storageAdapter.HasValue) if (!storageAdapter.HasValue)
{ {
rc = ResultFs.AllocationMemoryFailedInBisC.Value; res = ResultFs.AllocationMemoryFailedInBisC.Value;
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Log(); if (res.IsFailure()) return res.Log();
} }
outPartitionStorage.Set(ref storageAdapter.Ref()); outPartitionStorage.Set(ref storageAdapter.Ref());
@ -191,9 +191,9 @@ public static class Bis
{ {
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.InvalidateBisCache(); Result res = fileSystemProxy.Get.InvalidateBisCache();
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }

View File

@ -22,11 +22,11 @@ public static class Code
public static Result MountCode(this FileSystemClient fs, out CodeVerificationData verificationData, public static Result MountCode(this FileSystemClient fs, out CodeVerificationData verificationData,
U8Span mountName, U8Span path, ProgramId programId) U8Span mountName, U8Span path, ProgramId programId)
{ {
Result rc; Result res;
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = Mount(fs, out verificationData, mountName, path, programId); res = Mount(fs, out verificationData, mountName, path, programId);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
Span<byte> logBuffer = stackalloc byte[0x300]; Span<byte> logBuffer = stackalloc byte[0x300];
@ -36,15 +36,15 @@ public static class Code
.Append(LogPath).Append(path).Append(LogQuote) .Append(LogPath).Append(path).Append(LogQuote)
.Append(LogProgramId).AppendFormat(programId.Value, 'X'); .Append(LogProgramId).AppendFormat(programId.Value, 'X');
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = Mount(fs, out verificationData, mountName, path, programId); res = Mount(fs, out verificationData, mountName, path, programId);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName); fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
@ -56,24 +56,24 @@ public static class Code
{ {
UnsafeHelpers.SkipParamInit(out verificationData); UnsafeHelpers.SkipParamInit(out verificationData);
Result rc = fs.Impl.CheckMountName(mountName); Result res = fs.Impl.CheckMountName(mountName);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = PathUtility.ConvertToFspPath(out FspPath sfPath, path); res = PathUtility.ConvertToFspPath(out FspPath sfPath, path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using SharedRef<IFileSystemProxyForLoader> fileSystemProxy = using SharedRef<IFileSystemProxyForLoader> fileSystemProxy =
fs.Impl.GetFileSystemProxyForLoaderServiceObject(); fs.Impl.GetFileSystemProxyForLoaderServiceObject();
// Todo: IPC code should automatically set process ID // Todo: IPC code should automatically set process ID
rc = fileSystemProxy.Get.SetCurrentProcess(fs.Hos.Os.GetCurrentProcessId().Value); res = fileSystemProxy.Get.SetCurrentProcess(fs.Hos.Os.GetCurrentProcessId().Value);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
using var fileSystem = new SharedRef<IFileSystemSf>(); using var fileSystem = new SharedRef<IFileSystemSf>();
rc = fileSystemProxy.Get.OpenCodeFileSystem(ref fileSystem.Ref(), out verificationData, in sfPath, res = fileSystemProxy.Get.OpenCodeFileSystem(ref fileSystem.Ref(), out verificationData, in sfPath,
programId); programId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var fileSystemAdapter = using var fileSystemAdapter =
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref())); new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref()));
@ -81,8 +81,8 @@ public static class Code
if (!fileSystemAdapter.HasValue) if (!fileSystemAdapter.HasValue)
return ResultFs.AllocationMemoryFailedInCodeA.Log(); return ResultFs.AllocationMemoryFailedInCodeA.Log();
rc = fs.Register(mountName, ref fileSystemAdapter.Ref()); res = fs.Register(mountName, ref fileSystemAdapter.Ref());
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }

View File

@ -37,19 +37,19 @@ public static class Content
private static Result MountContentImpl(FileSystemClient fs, U8Span mountName, U8Span path, ulong id, private static Result MountContentImpl(FileSystemClient fs, U8Span mountName, U8Span path, ulong id,
ContentType contentType) ContentType contentType)
{ {
Result rc = fs.Impl.CheckMountNameAcceptingReservedMountName(mountName); Result res = fs.Impl.CheckMountNameAcceptingReservedMountName(mountName);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
FileSystemProxyType fsType = ConvertToFileSystemProxyType(contentType); FileSystemProxyType fsType = ConvertToFileSystemProxyType(contentType);
rc = PathUtility.ConvertToFspPath(out FspPath sfPath, path); res = PathUtility.ConvertToFspPath(out FspPath sfPath, path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var fileSystem = new SharedRef<IFileSystemSf>(); using var fileSystem = new SharedRef<IFileSystemSf>();
rc = fileSystemProxy.Get.OpenFileSystemWithId(ref fileSystem.Ref(), in sfPath, id, fsType); res = fileSystemProxy.Get.OpenFileSystemWithId(ref fileSystem.Ref(), in sfPath, id, fsType);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var fileSystemAdapter = using var fileSystemAdapter =
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref())); new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref()));
@ -57,21 +57,21 @@ public static class Content
if (!fileSystemAdapter.HasValue) if (!fileSystemAdapter.HasValue)
return ResultFs.AllocationMemoryFailedInContentA.Log(); return ResultFs.AllocationMemoryFailedInContentA.Log();
rc = fs.Register(mountName, ref fileSystemAdapter.Ref()); res = fs.Register(mountName, ref fileSystemAdapter.Ref());
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
public static Result MountContent(this FileSystemClient fs, U8Span mountName, U8Span path, ContentType contentType) public static Result MountContent(this FileSystemClient fs, U8Span mountName, U8Span path, ContentType contentType)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x300]; Span<byte> logBuffer = stackalloc byte[0x300];
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = PreMount(contentType); res = PreMount(contentType);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var idString = new IdString(); var idString = new IdString();
@ -81,22 +81,22 @@ public static class Content
.Append(LogPath).Append(path).Append(LogQuote) .Append(LogPath).Append(path).Append(LogQuote)
.Append(LogContentType).Append(idString.ToString(contentType)); .Append(LogContentType).Append(idString.ToString(contentType));
fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLogUnlessResultSuccess(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = PreMount(contentType); res = PreMount(contentType);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
ProgramId programId = default; ProgramId programId = default;
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = MountContentImpl(fs, mountName, path, programId.Value, contentType); res = MountContentImpl(fs, mountName, path, programId.Value, contentType);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var idString = new IdString(); var idString = new IdString();
@ -107,15 +107,15 @@ public static class Content
.Append(LogProgramId).AppendFormat(programId.Value, 'X') .Append(LogProgramId).AppendFormat(programId.Value, 'X')
.Append(LogContentType).Append(idString.ToString(contentType)); .Append(LogContentType).Append(idString.ToString(contentType));
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = MountContentImpl(fs, mountName, path, programId.Value, contentType); res = MountContentImpl(fs, mountName, path, programId.Value, contentType);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName); fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
@ -134,13 +134,13 @@ public static class Content
public static Result MountContent(this FileSystemClient fs, U8Span mountName, U8Span path, ProgramId programId, public static Result MountContent(this FileSystemClient fs, U8Span mountName, U8Span path, ProgramId programId,
ContentType contentType) ContentType contentType)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x300]; Span<byte> logBuffer = stackalloc byte[0x300];
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = MountContentImpl(fs, mountName, path, programId.Value, contentType); res = MountContentImpl(fs, mountName, path, programId.Value, contentType);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var idString = new IdString(); var idString = new IdString();
@ -153,15 +153,15 @@ public static class Content
logBuffer = sb.Buffer; logBuffer = sb.Buffer;
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = MountContentImpl(fs, mountName, path, programId.Value, contentType); res = MountContentImpl(fs, mountName, path, programId.Value, contentType);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName); fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
@ -172,13 +172,13 @@ public static class Content
public static Result MountContent(this FileSystemClient fs, U8Span mountName, U8Span path, DataId dataId, public static Result MountContent(this FileSystemClient fs, U8Span mountName, U8Span path, DataId dataId,
ContentType contentType) ContentType contentType)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x300]; Span<byte> logBuffer = stackalloc byte[0x300];
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = MountContentImpl(fs, mountName, path, dataId.Value, contentType); res = MountContentImpl(fs, mountName, path, dataId.Value, contentType);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var idString = new IdString(); var idString = new IdString();
@ -189,15 +189,15 @@ public static class Content
.Append(LogDataId).AppendFormat(dataId.Value, 'X') .Append(LogDataId).AppendFormat(dataId.Value, 'X')
.Append(LogContentType).Append(idString.ToString(contentType)); .Append(LogContentType).Append(idString.ToString(contentType));
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = MountContentImpl(fs, mountName, path, dataId.Value, contentType); res = MountContentImpl(fs, mountName, path, dataId.Value, contentType);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName); fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
@ -208,13 +208,13 @@ public static class Content
public static Result MountContent(this FileSystemClient fs, U8Span mountName, ProgramId programId, public static Result MountContent(this FileSystemClient fs, U8Span mountName, ProgramId programId,
ContentType contentType) ContentType contentType)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x300]; Span<byte> logBuffer = stackalloc byte[0x300];
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = Mount(fs, mountName, programId, contentType); res = Mount(fs, mountName, programId, contentType);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var idString = new IdString(); var idString = new IdString();
@ -224,15 +224,15 @@ public static class Content
.Append(LogProgramId).AppendFormat(programId.Value, 'X') .Append(LogProgramId).AppendFormat(programId.Value, 'X')
.Append(LogContentType).Append(idString.ToString(contentType)); .Append(LogContentType).Append(idString.ToString(contentType));
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = Mount(fs, mountName, programId, contentType); res = Mount(fs, mountName, programId, contentType);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName); fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
@ -241,16 +241,16 @@ public static class Content
static Result Mount(FileSystemClient fs, U8Span mountName, ProgramId programId, ContentType contentType) static Result Mount(FileSystemClient fs, U8Span mountName, ProgramId programId, ContentType contentType)
{ {
Result rc = fs.Impl.CheckMountNameAcceptingReservedMountName(mountName); Result res = fs.Impl.CheckMountNameAcceptingReservedMountName(mountName);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
FileSystemProxyType fsType = ConvertToFileSystemProxyType(contentType); FileSystemProxyType fsType = ConvertToFileSystemProxyType(contentType);
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var fileSystem = new SharedRef<IFileSystemSf>(); using var fileSystem = new SharedRef<IFileSystemSf>();
rc = fileSystemProxy.Get.OpenFileSystemWithPatch(ref fileSystem.Ref(), programId, fsType); res = fileSystemProxy.Get.OpenFileSystemWithPatch(ref fileSystem.Ref(), programId, fsType);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var fileSystemAdapter = using var fileSystemAdapter =
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref())); new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref()));
@ -258,8 +258,8 @@ public static class Content
if (!fileSystemAdapter.HasValue) if (!fileSystemAdapter.HasValue)
return ResultFs.AllocationMemoryFailedInContentA.Log(); return ResultFs.AllocationMemoryFailedInContentA.Log();
rc = fs.Register(mountName, ref fileSystemAdapter.Ref()); res = fs.Register(mountName, ref fileSystemAdapter.Ref());
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }

View File

@ -56,13 +56,13 @@ public static class ContentStorage
public static Result MountContentStorage(this FileSystemClient fs, U8Span mountName, ContentStorageId storageId) public static Result MountContentStorage(this FileSystemClient fs, U8Span mountName, ContentStorageId storageId)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x40]; Span<byte> logBuffer = stackalloc byte[0x40];
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = Mount(fs, mountName, storageId); res = Mount(fs, mountName, storageId);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var idString = new IdString(); var idString = new IdString();
@ -71,15 +71,15 @@ public static class ContentStorage
sb.Append(LogName).Append(mountName).Append(LogQuote) sb.Append(LogName).Append(mountName).Append(LogQuote)
.Append(LogContentStorageId).Append(idString.ToString(storageId)); .Append(LogContentStorageId).Append(idString.ToString(storageId));
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = Mount(fs, mountName, storageId); res = Mount(fs, mountName, storageId);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName); fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
@ -93,26 +93,26 @@ public static class ContentStorage
const int maxRetries = 10; const int maxRetries = 10;
const int retryInterval = 1000; const int retryInterval = 1000;
Result rc = fs.Impl.CheckMountNameAcceptingReservedMountName(mountName); Result res = fs.Impl.CheckMountNameAcceptingReservedMountName(mountName);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var fileSystem = new SharedRef<IFileSystemSf>(); using var fileSystem = new SharedRef<IFileSystemSf>();
for (int i = 0; i < maxRetries; i++) for (int i = 0; i < maxRetries; i++)
{ {
rc = fileSystemProxy.Get.OpenContentStorageFileSystem(ref fileSystem.Ref(), storageId); res = fileSystemProxy.Get.OpenContentStorageFileSystem(ref fileSystem.Ref(), storageId);
if (rc.IsSuccess()) if (res.IsSuccess())
break; break;
if (!ResultFs.SystemPartitionNotReady.Includes(rc)) if (!ResultFs.SystemPartitionNotReady.Includes(res))
return rc; return res;
// Note: Nintendo has an off-by-one error where they check if // Note: Nintendo has an off-by-one error where they check if
// "i == maxRetries" instead of "i == maxRetries - 1" // "i == maxRetries" instead of "i == maxRetries - 1"
if (i == maxRetries - 1) if (i == maxRetries - 1)
return rc; return res;
fs.Hos.Os.SleepThread(TimeSpan.FromMilliSeconds(retryInterval)); fs.Hos.Os.SleepThread(TimeSpan.FromMilliSeconds(retryInterval));
} }
@ -129,8 +129,8 @@ public static class ContentStorage
if (!mountNameGenerator.HasValue) if (!mountNameGenerator.HasValue)
return ResultFs.AllocationMemoryFailedInContentStorageB.Log(); return ResultFs.AllocationMemoryFailedInContentStorageB.Log();
rc = fs.Register(mountName, ref fileSystemAdapter.Ref(), ref mountNameGenerator.Ref()); res = fs.Register(mountName, ref fileSystemAdapter.Ref(), ref mountNameGenerator.Ref());
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }

View File

@ -32,29 +32,29 @@ public static class CustomStorage
public static Result MountCustomStorage(this FileSystemClient fs, U8Span mountName, CustomStorageId storageId) public static Result MountCustomStorage(this FileSystemClient fs, U8Span mountName, CustomStorageId storageId)
{ {
Result rc = Mount(fs, mountName, storageId); Result res = Mount(fs, mountName, storageId);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
static Result Mount(FileSystemClient fs, U8Span mountName, CustomStorageId storageId) static Result Mount(FileSystemClient fs, U8Span mountName, CustomStorageId storageId)
{ {
Result rc = fs.Impl.CheckMountName(mountName); Result res = fs.Impl.CheckMountName(mountName);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var fileSystem = new SharedRef<IFileSystemSf>(); using var fileSystem = new SharedRef<IFileSystemSf>();
rc = fileSystemProxy.Get.OpenCustomStorageFileSystem(ref fileSystem.Ref(), storageId); res = fileSystemProxy.Get.OpenCustomStorageFileSystem(ref fileSystem.Ref(), storageId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
using var fileSystemAdapter = using var fileSystemAdapter =
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref())); new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref()));
rc = fs.Register(mountName, ref fileSystemAdapter.Ref()); res = fs.Register(mountName, ref fileSystemAdapter.Ref());
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }

View File

@ -24,9 +24,9 @@ public static class DebugShim
{ {
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.CreatePaddingFile(size); Result res = fileSystemProxy.Get.CreatePaddingFile(size);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -35,9 +35,9 @@ public static class DebugShim
{ {
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.DeleteAllPaddingFiles(); Result res = fileSystemProxy.Get.DeleteAllPaddingFiles();
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -47,9 +47,9 @@ public static class DebugShim
{ {
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.OverrideSaveDataTransferTokenSignVerificationKey(new InBuffer(keyBuffer)); Result res = fileSystemProxy.Get.OverrideSaveDataTransferTokenSignVerificationKey(new InBuffer(keyBuffer));
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -58,9 +58,9 @@ public static class DebugShim
{ {
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.RegisterDebugConfiguration((uint)key, value); Result res = fileSystemProxy.Get.RegisterDebugConfiguration((uint)key, value);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -69,9 +69,9 @@ public static class DebugShim
{ {
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.UnregisterDebugConfiguration((uint)key); Result res = fileSystemProxy.Get.UnregisterDebugConfiguration((uint)key);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }

View File

@ -29,9 +29,9 @@ public static class DeviceSaveData
public Result GetSaveDataAttribute(out SaveDataAttribute attribute) public Result GetSaveDataAttribute(out SaveDataAttribute attribute)
{ {
Result rc = SaveDataAttribute.Make(out attribute, _programId, SaveDataType.Device, InvalidUserId, Result res = SaveDataAttribute.Make(out attribute, _programId, SaveDataType.Device, InvalidUserId,
InvalidSystemSaveDataId); InvalidSystemSaveDataId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -42,14 +42,14 @@ public static class DeviceSaveData
private static Result MountDeviceSaveDataImpl(this FileSystemClientImpl fs, U8Span mountName, private static Result MountDeviceSaveDataImpl(this FileSystemClientImpl fs, U8Span mountName,
in SaveDataAttribute attribute) in SaveDataAttribute attribute)
{ {
Result rc = fs.CheckMountName(mountName); Result res = fs.CheckMountName(mountName);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.GetFileSystemProxyServiceObject();
using var fileSystem = new SharedRef<IFileSystemSf>(); using var fileSystem = new SharedRef<IFileSystemSf>();
rc = fileSystemProxy.Get.OpenSaveDataFileSystem(ref fileSystem.Ref(), DeviceSaveDataSpaceId, in attribute); res = fileSystemProxy.Get.OpenSaveDataFileSystem(ref fileSystem.Ref(), DeviceSaveDataSpaceId, in attribute);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
var fileSystemAdapterRaw = new FileSystemServiceObjectAdapter(ref fileSystem.Ref()); var fileSystemAdapterRaw = new FileSystemServiceObjectAdapter(ref fileSystem.Ref());
using var fileSystemAdapter = new UniqueRef<IFileSystem>(fileSystemAdapterRaw); using var fileSystemAdapter = new UniqueRef<IFileSystem>(fileSystemAdapterRaw);
@ -62,10 +62,10 @@ public static class DeviceSaveData
using var mountNameGenerator = new UniqueRef<ICommonMountNameGenerator>(); using var mountNameGenerator = new UniqueRef<ICommonMountNameGenerator>();
rc = fs.Fs.Register(mountName, fileSystemAdapterRaw, ref fileSystemAdapter.Ref(), ref mountNameGenerator.Ref(), res = fs.Fs.Register(mountName, fileSystemAdapterRaw, ref fileSystemAdapter.Ref(), ref mountNameGenerator.Ref(),
ref saveDataAttributeGetter.Ref(), useDataCache: false, storageForPurgeFileDataCache: null, ref saveDataAttributeGetter.Ref(), useDataCache: false, storageForPurgeFileDataCache: null,
usePathCache: true); usePathCache: true);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -74,30 +74,30 @@ public static class DeviceSaveData
{ {
Span<byte> logBuffer = stackalloc byte[0x30]; Span<byte> logBuffer = stackalloc byte[0x30];
Result rc = SaveDataAttribute.Make(out SaveDataAttribute attribute, InvalidProgramId, SaveDataType.Device, Result res = SaveDataAttribute.Make(out SaveDataAttribute attribute, InvalidProgramId, SaveDataType.Device,
InvalidUserId, InvalidSystemSaveDataId); InvalidUserId, InvalidSystemSaveDataId);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = MountDeviceSaveDataImpl(fs.Impl, mountName, in attribute); res = MountDeviceSaveDataImpl(fs.Impl, mountName, in attribute);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogName).Append(mountName).Append(LogQuote); sb.Append(LogName).Append(mountName).Append(LogQuote);
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = MountDeviceSaveDataImpl(fs.Impl, mountName, in attribute); res = MountDeviceSaveDataImpl(fs.Impl, mountName, in attribute);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName); fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
@ -110,31 +110,31 @@ public static class DeviceSaveData
{ {
Span<byte> logBuffer = stackalloc byte[0x50]; Span<byte> logBuffer = stackalloc byte[0x50];
Result rc = SaveDataAttribute.Make(out SaveDataAttribute attribute, applicationId, SaveDataType.Device, Result res = SaveDataAttribute.Make(out SaveDataAttribute attribute, applicationId, SaveDataType.Device,
InvalidUserId, InvalidSystemSaveDataId); InvalidUserId, InvalidSystemSaveDataId);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = MountDeviceSaveDataImpl(fs.Impl, mountName, in attribute); res = MountDeviceSaveDataImpl(fs.Impl, mountName, in attribute);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogName).Append(mountName).Append(LogQuote) sb.Append(LogName).Append(mountName).Append(LogQuote)
.Append(LogApplicationId).AppendFormat(applicationId.Value, 'X'); .Append(LogApplicationId).AppendFormat(applicationId.Value, 'X');
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = MountDeviceSaveDataImpl(fs.Impl, mountName, in attribute); res = MountDeviceSaveDataImpl(fs.Impl, mountName, in attribute);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName); fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
@ -149,7 +149,7 @@ public static class DeviceSaveData
public static bool IsDeviceSaveDataExisting(this FileSystemClient fs, ApplicationId applicationId) public static bool IsDeviceSaveDataExisting(this FileSystemClient fs, ApplicationId applicationId)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x30]; Span<byte> logBuffer = stackalloc byte[0x30];
bool exists; bool exists;
@ -158,21 +158,21 @@ public static class DeviceSaveData
if (fs.Impl.IsEnabledAccessLog() && fs.Impl.IsEnabledHandleAccessLog(null)) if (fs.Impl.IsEnabledAccessLog() && fs.Impl.IsEnabledHandleAccessLog(null))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fs.Impl.IsSaveDataExisting(out exists, appId, SaveDataType.Device, InvalidUserId); res = fs.Impl.IsSaveDataExisting(out exists, appId, SaveDataType.Device, InvalidUserId);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogApplicationId).AppendFormat(applicationId.Value, 'X'); sb.Append(LogApplicationId).AppendFormat(applicationId.Value, 'X');
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = fs.Impl.IsSaveDataExisting(out exists, appId, SaveDataType.Device, InvalidUserId); res = fs.Impl.IsSaveDataExisting(out exists, appId, SaveDataType.Device, InvalidUserId);
} }
fs.Impl.LogResultErrorMessage(rc); fs.Impl.LogResultErrorMessage(res);
Abort.DoAbortUnless(rc.IsSuccess()); Abort.DoAbortUnless(res.IsSuccess());
return exists; return exists;
} }

View File

@ -14,9 +14,9 @@ public static class ErrorInfo
{ {
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.GetAndClearErrorInfo(out outErrorInfo); Result res = fileSystemProxy.Get.GetAndClearErrorInfo(out outErrorInfo);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }

View File

@ -61,11 +61,11 @@ public static class FileSystemProxyServiceObject
} }
using var fileSystemProxy = new SharedRef<IFileSystemProxy>(); using var fileSystemProxy = new SharedRef<IFileSystemProxy>();
Result rc = fs.Hos.Sm.GetService(ref fileSystemProxy.Ref(), "fsp-srv"); Result res = fs.Hos.Sm.GetService(ref fileSystemProxy.Ref(), "fsp-srv");
if (rc.IsFailure()) if (res.IsFailure())
{ {
throw new HorizonResultException(rc, "Failed to get file system proxy service object."); throw new HorizonResultException(res, "Failed to get file system proxy service object.");
} }
fileSystemProxy.Get.SetCurrentProcess(fs.Hos.Os.GetCurrentProcessId().Value).IgnoreResult(); fileSystemProxy.Get.SetCurrentProcess(fs.Hos.Os.GetCurrentProcessId().Value).IgnoreResult();
@ -92,11 +92,11 @@ public static class FileSystemProxyServiceObject
FileSystemClientImpl fs) FileSystemClientImpl fs)
{ {
using var fileSystemProxy = new SharedRef<IFileSystemProxyForLoader>(); using var fileSystemProxy = new SharedRef<IFileSystemProxyForLoader>();
Result rc = fs.Hos.Sm.GetService(ref fileSystemProxy.Ref(), "fsp-ldr"); Result res = fs.Hos.Sm.GetService(ref fileSystemProxy.Ref(), "fsp-ldr");
if (rc.IsFailure()) if (res.IsFailure())
{ {
throw new HorizonResultException(rc, "Failed to get file system proxy service object."); throw new HorizonResultException(res, "Failed to get file system proxy service object.");
} }
fileSystemProxy.Get.SetCurrentProcess(fs.Hos.Os.GetCurrentProcessId().Value).IgnoreResult(); fileSystemProxy.Get.SetCurrentProcess(fs.Hos.Os.GetCurrentProcessId().Value).IgnoreResult();
@ -121,11 +121,11 @@ public static class FileSystemProxyServiceObject
private static SharedRef<IProgramRegistry> GetProgramRegistryServiceObjectImpl(FileSystemClientImpl fs) private static SharedRef<IProgramRegistry> GetProgramRegistryServiceObjectImpl(FileSystemClientImpl fs)
{ {
using var registry = new SharedRef<IProgramRegistry>(); using var registry = new SharedRef<IProgramRegistry>();
Result rc = fs.Hos.Sm.GetService(ref registry.Ref(), "fsp-pr"); Result res = fs.Hos.Sm.GetService(ref registry.Ref(), "fsp-pr");
if (rc.IsFailure()) if (res.IsFailure())
{ {
throw new HorizonResultException(rc, "Failed to get registry service object."); throw new HorizonResultException(res, "Failed to get registry service object.");
} }
registry.Get.SetCurrentProcess(fs.Hos.Os.GetCurrentProcessId().Value).IgnoreResult(); registry.Get.SetCurrentProcess(fs.Hos.Os.GetCurrentProcessId().Value).IgnoreResult();

View File

@ -150,70 +150,70 @@ internal class FileSystemServiceObjectAdapter : IFileSystem, IMultiCommitTarget
protected override Result DoCreateFile(in Path path, long size, CreateFileOptions option) protected override Result DoCreateFile(in Path path, long size, CreateFileOptions option)
{ {
Result rc = GetPathForServiceObject(out PathSf sfPath, in path); Result res = GetPathForServiceObject(out PathSf sfPath, in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return _baseFs.Get.CreateFile(in sfPath, size, (int)option); return _baseFs.Get.CreateFile(in sfPath, size, (int)option);
} }
protected override Result DoDeleteFile(in Path path) protected override Result DoDeleteFile(in Path path)
{ {
Result rc = GetPathForServiceObject(out PathSf sfPath, in path); Result res = GetPathForServiceObject(out PathSf sfPath, in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return _baseFs.Get.DeleteFile(in sfPath); return _baseFs.Get.DeleteFile(in sfPath);
} }
protected override Result DoCreateDirectory(in Path path) protected override Result DoCreateDirectory(in Path path)
{ {
Result rc = GetPathForServiceObject(out PathSf sfPath, in path); Result res = GetPathForServiceObject(out PathSf sfPath, in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return _baseFs.Get.CreateDirectory(in sfPath); return _baseFs.Get.CreateDirectory(in sfPath);
} }
protected override Result DoDeleteDirectory(in Path path) protected override Result DoDeleteDirectory(in Path path)
{ {
Result rc = GetPathForServiceObject(out PathSf sfPath, in path); Result res = GetPathForServiceObject(out PathSf sfPath, in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return _baseFs.Get.DeleteDirectory(in sfPath); return _baseFs.Get.DeleteDirectory(in sfPath);
} }
protected override Result DoDeleteDirectoryRecursively(in Path path) protected override Result DoDeleteDirectoryRecursively(in Path path)
{ {
Result rc = GetPathForServiceObject(out PathSf sfPath, in path); Result res = GetPathForServiceObject(out PathSf sfPath, in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return _baseFs.Get.DeleteDirectoryRecursively(in sfPath); return _baseFs.Get.DeleteDirectoryRecursively(in sfPath);
} }
protected override Result DoCleanDirectoryRecursively(in Path path) protected override Result DoCleanDirectoryRecursively(in Path path)
{ {
Result rc = GetPathForServiceObject(out PathSf sfPath, in path); Result res = GetPathForServiceObject(out PathSf sfPath, in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return _baseFs.Get.CleanDirectoryRecursively(in sfPath); return _baseFs.Get.CleanDirectoryRecursively(in sfPath);
} }
protected override Result DoRenameFile(in Path currentPath, in Path newPath) protected override Result DoRenameFile(in Path currentPath, in Path newPath)
{ {
Result rc = GetPathForServiceObject(out PathSf currentSfPath, in currentPath); Result res = GetPathForServiceObject(out PathSf currentSfPath, in currentPath);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = GetPathForServiceObject(out PathSf newSfPath, in newPath); res = GetPathForServiceObject(out PathSf newSfPath, in newPath);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return _baseFs.Get.RenameFile(in currentSfPath, in newSfPath); return _baseFs.Get.RenameFile(in currentSfPath, in newSfPath);
} }
protected override Result DoRenameDirectory(in Path currentPath, in Path newPath) protected override Result DoRenameDirectory(in Path currentPath, in Path newPath)
{ {
Result rc = GetPathForServiceObject(out PathSf currentSfPath, in currentPath); Result res = GetPathForServiceObject(out PathSf currentSfPath, in currentPath);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = GetPathForServiceObject(out PathSf newSfPath, in newPath); res = GetPathForServiceObject(out PathSf newSfPath, in newPath);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return _baseFs.Get.RenameDirectory(in currentSfPath, in newSfPath); return _baseFs.Get.RenameDirectory(in currentSfPath, in newSfPath);
} }
@ -222,8 +222,8 @@ internal class FileSystemServiceObjectAdapter : IFileSystem, IMultiCommitTarget
{ {
UnsafeHelpers.SkipParamInit(out entryType); UnsafeHelpers.SkipParamInit(out entryType);
Result rc = GetPathForServiceObject(out PathSf sfPath, in path); Result res = GetPathForServiceObject(out PathSf sfPath, in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
ref uint sfEntryType = ref Unsafe.As<DirectoryEntryType, uint>(ref entryType); ref uint sfEntryType = ref Unsafe.As<DirectoryEntryType, uint>(ref entryType);
@ -234,8 +234,8 @@ internal class FileSystemServiceObjectAdapter : IFileSystem, IMultiCommitTarget
{ {
UnsafeHelpers.SkipParamInit(out freeSpace); UnsafeHelpers.SkipParamInit(out freeSpace);
Result rc = GetPathForServiceObject(out PathSf sfPath, in path); Result res = GetPathForServiceObject(out PathSf sfPath, in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return _baseFs.Get.GetFreeSpaceSize(out freeSpace, in sfPath); return _baseFs.Get.GetFreeSpaceSize(out freeSpace, in sfPath);
} }
@ -244,21 +244,21 @@ internal class FileSystemServiceObjectAdapter : IFileSystem, IMultiCommitTarget
{ {
UnsafeHelpers.SkipParamInit(out totalSpace); UnsafeHelpers.SkipParamInit(out totalSpace);
Result rc = GetPathForServiceObject(out PathSf sfPath, in path); Result res = GetPathForServiceObject(out PathSf sfPath, in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return _baseFs.Get.GetTotalSpaceSize(out totalSpace, in sfPath); return _baseFs.Get.GetTotalSpaceSize(out totalSpace, in sfPath);
} }
protected override Result DoOpenFile(ref UniqueRef<IFile> outFile, in Path path, OpenMode mode) protected override Result DoOpenFile(ref UniqueRef<IFile> outFile, in Path path, OpenMode mode)
{ {
Result rc = GetPathForServiceObject(out PathSf sfPath, in path); Result res = GetPathForServiceObject(out PathSf sfPath, in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var fileServiceObject = new SharedRef<IFileSf>(); using var fileServiceObject = new SharedRef<IFileSf>();
rc = _baseFs.Get.OpenFile(ref fileServiceObject.Ref(), in sfPath, (uint)mode); res = _baseFs.Get.OpenFile(ref fileServiceObject.Ref(), in sfPath, (uint)mode);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
outFile.Reset(new FileServiceObjectAdapter(ref fileServiceObject.Ref())); outFile.Reset(new FileServiceObjectAdapter(ref fileServiceObject.Ref()));
return Result.Success; return Result.Success;
@ -267,13 +267,13 @@ internal class FileSystemServiceObjectAdapter : IFileSystem, IMultiCommitTarget
protected override Result DoOpenDirectory(ref UniqueRef<IDirectory> outDirectory, in Path path, protected override Result DoOpenDirectory(ref UniqueRef<IDirectory> outDirectory, in Path path,
OpenDirectoryMode mode) OpenDirectoryMode mode)
{ {
Result rc = GetPathForServiceObject(out PathSf sfPath, in path); Result res = GetPathForServiceObject(out PathSf sfPath, in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var directoryServiceObject = new SharedRef<IDirectorySf>(); using var directoryServiceObject = new SharedRef<IDirectorySf>();
rc = _baseFs.Get.OpenDirectory(ref directoryServiceObject.Ref(), in sfPath, (uint)mode); res = _baseFs.Get.OpenDirectory(ref directoryServiceObject.Ref(), in sfPath, (uint)mode);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
outDirectory.Reset(new DirectoryServiceObjectAdapter(ref directoryServiceObject.Ref())); outDirectory.Reset(new DirectoryServiceObjectAdapter(ref directoryServiceObject.Ref()));
return Result.Success; return Result.Success;
@ -288,8 +288,8 @@ internal class FileSystemServiceObjectAdapter : IFileSystem, IMultiCommitTarget
{ {
UnsafeHelpers.SkipParamInit(out timeStamp); UnsafeHelpers.SkipParamInit(out timeStamp);
Result rc = GetPathForServiceObject(out PathSf sfPath, in path); Result res = GetPathForServiceObject(out PathSf sfPath, in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return _baseFs.Get.GetFileTimeStampRaw(out timeStamp, in sfPath); return _baseFs.Get.GetFileTimeStampRaw(out timeStamp, in sfPath);
} }
@ -297,8 +297,8 @@ internal class FileSystemServiceObjectAdapter : IFileSystem, IMultiCommitTarget
protected override Result DoQueryEntry(Span<byte> outBuffer, ReadOnlySpan<byte> inBuffer, QueryId queryId, protected override Result DoQueryEntry(Span<byte> outBuffer, ReadOnlySpan<byte> inBuffer, QueryId queryId,
in Path path) in Path path)
{ {
Result rc = GetPathForServiceObject(out PathSf sfPath, in path); Result res = GetPathForServiceObject(out PathSf sfPath, in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return _baseFs.Get.QueryEntry(new OutBuffer(outBuffer), new InBuffer(inBuffer), (int)queryId, in sfPath); return _baseFs.Get.QueryEntry(new OutBuffer(outBuffer), new InBuffer(inBuffer), (int)queryId, in sfPath);
} }

View File

@ -84,13 +84,13 @@ public static class GameCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.GetGameCardHandle(out GameCardHandle handle); res = deviceOperator.Get.GetGameCardHandle(out GameCardHandle handle);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outHandle = handle; outHandle = handle;
return Result.Success; return Result.Success;
@ -99,13 +99,13 @@ public static class GameCard
public static Result MountGameCardPartition(this FileSystemClient fs, U8Span mountName, GameCardHandle handle, public static Result MountGameCardPartition(this FileSystemClient fs, U8Span mountName, GameCardHandle handle,
GameCardPartition partitionId) GameCardPartition partitionId)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x60]; Span<byte> logBuffer = stackalloc byte[0x60];
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = Mount(fs, mountName, handle, partitionId); res = Mount(fs, mountName, handle, partitionId);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var idString = new IdString(); var idString = new IdString();
@ -115,15 +115,15 @@ public static class GameCard
.Append(LogGameCardHandle).AppendFormat(handle, 'X') .Append(LogGameCardHandle).AppendFormat(handle, 'X')
.Append(LogGameCardPartition).Append(idString.ToString(partitionId)); .Append(LogGameCardPartition).Append(idString.ToString(partitionId));
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = Mount(fs, mountName, handle, partitionId); res = Mount(fs, mountName, handle, partitionId);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName); fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
@ -132,14 +132,14 @@ public static class GameCard
static Result Mount(FileSystemClient fs, U8Span mountName, GameCardHandle handle, GameCardPartition partitionId) static Result Mount(FileSystemClient fs, U8Span mountName, GameCardHandle handle, GameCardPartition partitionId)
{ {
Result rc = fs.Impl.CheckMountNameAcceptingReservedMountName(mountName); Result res = fs.Impl.CheckMountNameAcceptingReservedMountName(mountName);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var fileSystem = new SharedRef<IFileSystemSf>(); using var fileSystem = new SharedRef<IFileSystemSf>();
rc = fileSystemProxy.Get.OpenGameCardFileSystem(ref fileSystem.Ref(), handle, partitionId); res = fileSystemProxy.Get.OpenGameCardFileSystem(ref fileSystem.Ref(), handle, partitionId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
using var fileSystemAdapter = using var fileSystemAdapter =
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref())); new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref()));
@ -162,13 +162,13 @@ public static class GameCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.LogResultErrorMessage(rc); fs.Impl.LogResultErrorMessage(res);
Abort.DoAbortUnless(rc.IsSuccess()); Abort.DoAbortUnless(res.IsSuccess());
rc = deviceOperator.Get.IsGameCardInserted(out bool isInserted); res = deviceOperator.Get.IsGameCardInserted(out bool isInserted);
fs.Impl.LogResultErrorMessage(rc); fs.Impl.LogResultErrorMessage(res);
Abort.DoAbortUnless(rc.IsSuccess()); Abort.DoAbortUnless(res.IsSuccess());
return isInserted; return isInserted;
} }
@ -179,9 +179,9 @@ public static class GameCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var storage = new SharedRef<IStorageSf>(); using var storage = new SharedRef<IStorageSf>();
Result rc = fileSystemProxy.Get.OpenGameCardStorage(ref storage.Ref(), handle, partitionType); Result res = fileSystemProxy.Get.OpenGameCardStorage(ref storage.Ref(), handle, partitionType);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
using var storageAdapter = new UniqueRef<IStorage>(new StorageServiceObjectAdapter(ref storage.Ref())); using var storageAdapter = new UniqueRef<IStorage>(new StorageServiceObjectAdapter(ref storage.Ref()));
@ -197,13 +197,13 @@ public static class GameCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.EraseGameCard((uint)cardSize, romAreaStartPageAddress); res = deviceOperator.Get.EraseGameCard((uint)cardSize, romAreaStartPageAddress);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -216,13 +216,13 @@ public static class GameCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.GetGameCardUpdatePartitionInfo(out uint cupVersion, out ulong cupId, handle); res = deviceOperator.Get.GetGameCardUpdatePartitionInfo(out uint cupVersion, out ulong cupId, handle);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outPartitionInfo.CupVersion = cupVersion; outPartitionInfo.CupVersion = cupVersion;
outPartitionInfo.CupId = cupId; outPartitionInfo.CupId = cupId;
@ -235,13 +235,13 @@ public static class GameCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.LogResultErrorMessage(rc); fs.Impl.LogResultErrorMessage(res);
Abort.DoAbortUnless(rc.IsSuccess()); Abort.DoAbortUnless(res.IsSuccess());
rc = deviceOperator.Get.FinalizeGameCardDriver(); res = deviceOperator.Get.FinalizeGameCardDriver();
fs.Impl.LogResultErrorMessage(rc); fs.Impl.LogResultErrorMessage(res);
Abort.DoAbortUnless(rc.IsSuccess()); Abort.DoAbortUnless(res.IsSuccess());
} }
public static Result GetGameCardAttribute(this FileSystemClient fs, out GameCardAttribute outAttribute, public static Result GetGameCardAttribute(this FileSystemClient fs, out GameCardAttribute outAttribute,
@ -252,13 +252,13 @@ public static class GameCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.GetGameCardAttribute(out byte gameCardAttribute, handle); res = deviceOperator.Get.GetGameCardAttribute(out byte gameCardAttribute, handle);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outAttribute = (GameCardAttribute)gameCardAttribute; outAttribute = (GameCardAttribute)gameCardAttribute;
@ -273,13 +273,13 @@ public static class GameCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.GetGameCardCompatibilityType(out byte gameCardCompatibilityType, handle); res = deviceOperator.Get.GetGameCardCompatibilityType(out byte gameCardCompatibilityType, handle);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outCompatibilityType = (GameCardCompatibilityType)gameCardCompatibilityType; outCompatibilityType = (GameCardCompatibilityType)gameCardCompatibilityType;
@ -292,13 +292,13 @@ public static class GameCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.GetGameCardDeviceCertificate(new OutBuffer(outBuffer), outBuffer.Length, handle); res = deviceOperator.Get.GetGameCardDeviceCertificate(new OutBuffer(outBuffer), outBuffer.Length, handle);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -309,14 +309,14 @@ public static class GameCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.ChallengeCardExistence(new OutBuffer(responseBuffer), new InBuffer(challengeSeedBuffer), res = deviceOperator.Get.ChallengeCardExistence(new OutBuffer(responseBuffer), new InBuffer(challengeSeedBuffer),
new InBuffer(challengeValueBuffer), handle); new InBuffer(challengeValueBuffer), handle);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -329,16 +329,16 @@ public static class GameCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
Unsafe.SkipInit(out RmaInformation rmaInformation); Unsafe.SkipInit(out RmaInformation rmaInformation);
rc = deviceOperator.Get.GetGameCardAsicInfo(OutBuffer.FromStruct(ref rmaInformation), res = deviceOperator.Get.GetGameCardAsicInfo(OutBuffer.FromStruct(ref rmaInformation),
Unsafe.SizeOf<RmaInformation>(), new InBuffer(asicFirmwareBuffer), asicFirmwareBuffer.Length); Unsafe.SizeOf<RmaInformation>(), new InBuffer(asicFirmwareBuffer), asicFirmwareBuffer.Length);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outRmaInfo = rmaInformation; outRmaInfo = rmaInformation;
@ -352,15 +352,15 @@ public static class GameCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
Unsafe.SkipInit(out GameCardIdSet gcIdSet); Unsafe.SkipInit(out GameCardIdSet gcIdSet);
rc = deviceOperator.Get.GetGameCardIdSet(OutBuffer.FromStruct(ref gcIdSet), Unsafe.SizeOf<GameCardIdSet>()); res = deviceOperator.Get.GetGameCardIdSet(OutBuffer.FromStruct(ref gcIdSet), Unsafe.SizeOf<GameCardIdSet>());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outGcIdSet = gcIdSet; outGcIdSet = gcIdSet;
@ -369,27 +369,27 @@ public static class GameCard
public static Result GetGameCardCid(this FileSystemClient fs, Span<byte> outCidBuffer) public static Result GetGameCardCid(this FileSystemClient fs, Span<byte> outCidBuffer)
{ {
Result rc; Result res;
if (outCidBuffer.Length < Unsafe.SizeOf<GameCardIdSet>()) if (outCidBuffer.Length < Unsafe.SizeOf<GameCardIdSet>())
{ {
rc = ResultFs.InvalidSize.Value; res = ResultFs.InvalidSize.Value;
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc.Log(); return res.Log();
} }
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
Unsafe.SkipInit(out GameCardIdSet gcIdSet); Unsafe.SkipInit(out GameCardIdSet gcIdSet);
rc = deviceOperator.Get.GetGameCardIdSet(OutBuffer.FromStruct(ref gcIdSet), Unsafe.SizeOf<GameCardIdSet>()); res = deviceOperator.Get.GetGameCardIdSet(OutBuffer.FromStruct(ref gcIdSet), Unsafe.SizeOf<GameCardIdSet>());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
SpanHelpers.AsByteSpan(ref gcIdSet).CopyTo(outCidBuffer); SpanHelpers.AsByteSpan(ref gcIdSet).CopyTo(outCidBuffer);
@ -401,13 +401,13 @@ public static class GameCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.WriteToGameCardDirectly(offset, new OutBuffer(buffer), buffer.Length); res = deviceOperator.Get.WriteToGameCardDirectly(offset, new OutBuffer(buffer), buffer.Length);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -417,13 +417,13 @@ public static class GameCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.SetVerifyWriteEnableFlag(isEnabled); res = deviceOperator.Get.SetVerifyWriteEnableFlag(isEnabled);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -433,13 +433,13 @@ public static class GameCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.GetGameCardImageHash(new OutBuffer(outBuffer), outBuffer.Length, handle); res = deviceOperator.Get.GetGameCardImageHash(new OutBuffer(outBuffer), outBuffer.Length, handle);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -450,14 +450,14 @@ public static class GameCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.GetGameCardDeviceIdForProdCard(new OutBuffer(outIdBuffer), outIdBuffer.Length, res = deviceOperator.Get.GetGameCardDeviceIdForProdCard(new OutBuffer(outIdBuffer), outIdBuffer.Length,
new InBuffer(devHeaderBuffer), devHeaderBuffer.Length); new InBuffer(devHeaderBuffer), devHeaderBuffer.Length);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -467,13 +467,13 @@ public static class GameCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.EraseAndWriteParamDirectly(new InBuffer(devParamBuffer), devParamBuffer.Length); res = deviceOperator.Get.EraseAndWriteParamDirectly(new InBuffer(devParamBuffer), devParamBuffer.Length);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -483,13 +483,13 @@ public static class GameCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.ReadParamDirectly(new OutBuffer(outBuffer), outBuffer.Length); res = deviceOperator.Get.ReadParamDirectly(new OutBuffer(outBuffer), outBuffer.Length);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -499,13 +499,13 @@ public static class GameCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.ForceEraseGameCard(); res = deviceOperator.Get.ForceEraseGameCard();
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -517,13 +517,13 @@ public static class GameCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.GetGameCardErrorInfo(out GameCardErrorInfo gameCardErrorInfo); res = deviceOperator.Get.GetGameCardErrorInfo(out GameCardErrorInfo gameCardErrorInfo);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outErrorInfo = gameCardErrorInfo; outErrorInfo = gameCardErrorInfo;
@ -537,13 +537,13 @@ public static class GameCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.GetGameCardErrorReportInfo(out GameCardErrorReportInfo gameCardErrorReportInfo); res = deviceOperator.Get.GetGameCardErrorReportInfo(out GameCardErrorReportInfo gameCardErrorReportInfo);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outErrorInfo = gameCardErrorReportInfo; outErrorInfo = gameCardErrorReportInfo;
@ -556,37 +556,37 @@ public static class GameCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var fileSystem = new SharedRef<IFileSystemSf>(); using var fileSystem = new SharedRef<IFileSystemSf>();
Result rc = fileSystemProxy.Get.OpenGameCardFileSystem(ref fileSystem.Ref(), handle, partitionId); Result res = fileSystemProxy.Get.OpenGameCardFileSystem(ref fileSystem.Ref(), handle, partitionId);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
public static Result GetGameCardDeviceId(this FileSystemClient fs, Span<byte> outBuffer) public static Result GetGameCardDeviceId(this FileSystemClient fs, Span<byte> outBuffer)
{ {
Result rc; Result res;
// Note: Nintendo checks for length 8 here rather than GcCardDeviceIdSize (0x10) // Note: Nintendo checks for length 8 here rather than GcCardDeviceIdSize (0x10)
if (outBuffer.Length < GcCardDeviceIdSize) if (outBuffer.Length < GcCardDeviceIdSize)
{ {
rc = ResultFs.InvalidSize.Value; res = ResultFs.InvalidSize.Value;
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc.Log(); return res.Log();
} }
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
Span<byte> buffer = stackalloc byte[GcCardDeviceIdSize]; Span<byte> buffer = stackalloc byte[GcCardDeviceIdSize];
rc = deviceOperator.Get.GetGameCardDeviceId(new OutBuffer(buffer), GcCardDeviceIdSize); res = deviceOperator.Get.GetGameCardDeviceId(new OutBuffer(buffer), GcCardDeviceIdSize);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
buffer.CopyTo(outBuffer); buffer.CopyTo(outBuffer);
@ -600,12 +600,12 @@ public static class GameCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.SetDeviceSimulationEvent((uint)SdmmcPort.GcAsic, (uint)simulatedOperationType, res = deviceOperator.Get.SetDeviceSimulationEvent((uint)SdmmcPort.GcAsic, (uint)simulatedOperationType,
(uint)simulatedFailureType, failureResult.Value, autoClearEvent); (uint)simulatedFailureType, failureResult.Value, autoClearEvent);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -615,9 +615,9 @@ public static class GameCard
{ {
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.SimulateDeviceDetectionEvent(SdmmcPort.GcAsic, mode, signalEvent); Result res = fileSystemProxy.Get.SimulateDeviceDetectionEvent(SdmmcPort.GcAsic, mode, signalEvent);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -626,10 +626,10 @@ public static class GameCard
SimulatingDeviceTargetOperation simulatedOperationType, SimulatingDeviceTargetOperation simulatedOperationType,
SimulatingDeviceAccessFailureEventType simulatedFailureType) SimulatingDeviceAccessFailureEventType simulatedFailureType)
{ {
Result rc = SetGameCardSimulationEventImpl(fs, simulatedOperationType, simulatedFailureType, Result.Success, Result res = SetGameCardSimulationEventImpl(fs, simulatedOperationType, simulatedFailureType, Result.Success,
autoClearEvent: false); autoClearEvent: false);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -638,10 +638,10 @@ public static class GameCard
SimulatingDeviceTargetOperation simulatedOperationType, SimulatingDeviceTargetOperation simulatedOperationType,
SimulatingDeviceAccessFailureEventType simulatedFailureType, bool autoClearEvent) SimulatingDeviceAccessFailureEventType simulatedFailureType, bool autoClearEvent)
{ {
Result rc = SetGameCardSimulationEventImpl(fs, simulatedOperationType, simulatedFailureType, Result.Success, Result res = SetGameCardSimulationEventImpl(fs, simulatedOperationType, simulatedFailureType, Result.Success,
autoClearEvent); autoClearEvent);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -649,10 +649,10 @@ public static class GameCard
public static Result SetGameCardSimulationEvent(this FileSystemClient fs, public static Result SetGameCardSimulationEvent(this FileSystemClient fs,
SimulatingDeviceTargetOperation simulatedOperationType, Result failureResult, bool autoClearEvent) SimulatingDeviceTargetOperation simulatedOperationType, Result failureResult, bool autoClearEvent)
{ {
Result rc = SetGameCardSimulationEventImpl(fs, simulatedOperationType, Result res = SetGameCardSimulationEventImpl(fs, simulatedOperationType,
SimulatingDeviceAccessFailureEventType.AccessFailure, failureResult, autoClearEvent); SimulatingDeviceAccessFailureEventType.AccessFailure, failureResult, autoClearEvent);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -662,13 +662,13 @@ public static class GameCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.ClearDeviceSimulationEvent((uint)SdmmcPort.GcAsic); res = deviceOperator.Get.ClearDeviceSimulationEvent((uint)SdmmcPort.GcAsic);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }

View File

@ -45,13 +45,13 @@ public static class Host
if (option.Flags != MountHostOptionFlag.None) if (option.Flags != MountHostOptionFlag.None)
{ {
Result rc = fileSystemProxy.Get.OpenHostFileSystemWithOption(ref fileSystem.Ref(), in path, option); Result res = fileSystemProxy.Get.OpenHostFileSystemWithOption(ref fileSystem.Ref(), in path, option);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
else else
{ {
Result rc = fileSystemProxy.Get.OpenHostFileSystem(ref fileSystem.Ref(), in path); Result res = fileSystemProxy.Get.OpenHostFileSystem(ref fileSystem.Ref(), in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
using var fileSystemAdapter = using var fileSystemAdapter =
@ -129,8 +129,8 @@ public static class Host
if (fs.Impl.IsUsedReservedMountName(mountName)) if (fs.Impl.IsUsedReservedMountName(mountName))
return ResultFs.InvalidMountName.Log(); return ResultFs.InvalidMountName.Log();
Result rc = PathUtility.ConvertToFspPath(out FspPath sfPath, path); Result res = PathUtility.ConvertToFspPath(out FspPath sfPath, path);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
if (sfPath.Str[0] == NullTerminator) if (sfPath.Str[0] == NullTerminator)
{ {
@ -140,8 +140,8 @@ public static class Host
using var fileSystem = new UniqueRef<IFileSystem>(); using var fileSystem = new UniqueRef<IFileSystem>();
rc = OpenHostFileSystemImpl(fs, ref fileSystem.Ref(), in sfPath, option); res = OpenHostFileSystemImpl(fs, ref fileSystem.Ref(), in sfPath, option);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outFileSystem.Set(ref fileSystem.Ref()); outFileSystem.Set(ref fileSystem.Ref());
return Result.Success; return Result.Success;
@ -159,8 +159,8 @@ public static class Host
private static Result PreMountHost(FileSystemClient fs, private static Result PreMountHost(FileSystemClient fs,
ref UniqueRef<HostCommonMountNameGenerator> outMountNameGenerator, U8Span mountName, U8Span path) ref UniqueRef<HostCommonMountNameGenerator> outMountNameGenerator, U8Span mountName, U8Span path)
{ {
Result rc = fs.Impl.CheckMountName(mountName); Result res = fs.Impl.CheckMountName(mountName);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
outMountNameGenerator.Reset(new HostCommonMountNameGenerator(path)); outMountNameGenerator.Reset(new HostCommonMountNameGenerator(path));
@ -179,7 +179,7 @@ public static class Host
/// <returns>The <see cref="Result"/> of the operation.</returns> /// <returns>The <see cref="Result"/> of the operation.</returns>
public static Result MountHost(this FileSystemClient fs, U8Span mountName, U8Span path) public static Result MountHost(this FileSystemClient fs, U8Span mountName, U8Span path)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x300]; Span<byte> logBuffer = stackalloc byte[0x300];
using var mountNameGenerator = new UniqueRef<HostCommonMountNameGenerator>(); using var mountNameGenerator = new UniqueRef<HostCommonMountNameGenerator>();
@ -187,7 +187,7 @@ public static class Host
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = PreMountHost(fs, ref mountNameGenerator.Ref(), mountName, path); res = PreMountHost(fs, ref mountNameGenerator.Ref(), mountName, path);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
@ -196,49 +196,49 @@ public static class Host
logBuffer = sb.Buffer; logBuffer = sb.Buffer;
fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLogUnlessResultSuccess(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = PreMountHost(fs, ref mountNameGenerator.Ref(), mountName, path); res = PreMountHost(fs, ref mountNameGenerator.Ref(), mountName, path);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var fileSystem = new UniqueRef<IFileSystem>(); using var fileSystem = new UniqueRef<IFileSystem>();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = OpenHostFileSystem(fs, ref fileSystem.Ref(), mountName, path, MountHostOption.None); res = OpenHostFileSystem(fs, ref fileSystem.Ref(), mountName, path, MountHostOption.None);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLogUnlessResultSuccess(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = OpenHostFileSystem(fs, ref fileSystem.Ref(), mountName, path, MountHostOption.None); res = OpenHostFileSystem(fs, ref fileSystem.Ref(), mountName, path, MountHostOption.None);
} }
// No AbortIfNeeded here // No AbortIfNeeded here
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = PostMount(fs, mountName, ref fileSystem.Ref(), ref mountNameGenerator.Ref()); res = PostMount(fs, mountName, ref fileSystem.Ref(), ref mountNameGenerator.Ref());
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = PostMount(fs, mountName, ref fileSystem.Ref(), ref mountNameGenerator.Ref()); res = PostMount(fs, mountName, ref fileSystem.Ref(), ref mountNameGenerator.Ref());
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName); fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
@ -251,8 +251,8 @@ public static class Host
using UniqueRef<ICommonMountNameGenerator> baseMountNameGenerator = using UniqueRef<ICommonMountNameGenerator> baseMountNameGenerator =
UniqueRef<ICommonMountNameGenerator>.Create(ref mountNameGenerator); UniqueRef<ICommonMountNameGenerator>.Create(ref mountNameGenerator);
Result rc = fs.Register(mountName, ref fileSystem, ref baseMountNameGenerator.Ref()); Result res = fs.Register(mountName, ref fileSystem, ref baseMountNameGenerator.Ref());
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -268,7 +268,7 @@ public static class Host
/// <returns>The <see cref="Result"/> of the operation.</returns> /// <returns>The <see cref="Result"/> of the operation.</returns>
public static Result MountHost(this FileSystemClient fs, U8Span mountName, U8Span path, MountHostOption option) public static Result MountHost(this FileSystemClient fs, U8Span mountName, U8Span path, MountHostOption option)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x300]; Span<byte> logBuffer = stackalloc byte[0x300];
using var mountNameGenerator = new UniqueRef<HostCommonMountNameGenerator>(); using var mountNameGenerator = new UniqueRef<HostCommonMountNameGenerator>();
@ -276,7 +276,7 @@ public static class Host
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = PreMountHost(fs, ref mountNameGenerator.Ref(), mountName, path); res = PreMountHost(fs, ref mountNameGenerator.Ref(), mountName, path);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var idString = new IdString(); var idString = new IdString();
@ -288,49 +288,49 @@ public static class Host
logBuffer = sb.Buffer; logBuffer = sb.Buffer;
fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLogUnlessResultSuccess(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = PreMountHost(fs, ref mountNameGenerator.Ref(), mountName, path); res = PreMountHost(fs, ref mountNameGenerator.Ref(), mountName, path);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var fileSystem = new UniqueRef<IFileSystem>(); using var fileSystem = new UniqueRef<IFileSystem>();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = OpenHostFileSystem(fs, ref fileSystem.Ref(), mountName, path, option); res = OpenHostFileSystem(fs, ref fileSystem.Ref(), mountName, path, option);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLogUnlessResultSuccess(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = OpenHostFileSystem(fs, ref fileSystem.Ref(), mountName, path, option); res = OpenHostFileSystem(fs, ref fileSystem.Ref(), mountName, path, option);
} }
// No AbortIfNeeded here // No AbortIfNeeded here
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = PostMount(fs, mountName, ref fileSystem.Ref(), ref mountNameGenerator.Ref()); res = PostMount(fs, mountName, ref fileSystem.Ref(), ref mountNameGenerator.Ref());
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = PostMount(fs, mountName, ref fileSystem.Ref(), ref mountNameGenerator.Ref()); res = PostMount(fs, mountName, ref fileSystem.Ref(), ref mountNameGenerator.Ref());
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName); fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
@ -343,8 +343,8 @@ public static class Host
using UniqueRef<ICommonMountNameGenerator> baseMountNameGenerator = using UniqueRef<ICommonMountNameGenerator> baseMountNameGenerator =
UniqueRef<ICommonMountNameGenerator>.Create(ref mountNameGenerator); UniqueRef<ICommonMountNameGenerator>.Create(ref mountNameGenerator);
Result rc = fs.Register(mountName, ref fileSystem, ref baseMountNameGenerator.Ref()); Result res = fs.Register(mountName, ref fileSystem, ref baseMountNameGenerator.Ref());
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -357,7 +357,7 @@ public static class Host
/// <returns>The <see cref="Result"/> of the operation.</returns> /// <returns>The <see cref="Result"/> of the operation.</returns>
public static Result MountHostRoot(this FileSystemClient fs) public static Result MountHostRoot(this FileSystemClient fs)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x30]; Span<byte> logBuffer = stackalloc byte[0x30];
using var fileSystem = new UniqueRef<IFileSystem>(); using var fileSystem = new UniqueRef<IFileSystem>();
@ -366,38 +366,38 @@ public static class Host
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = OpenHostFileSystemImpl(fs, ref fileSystem.Ref(), in sfPath, MountHostOption.None); res = OpenHostFileSystemImpl(fs, ref fileSystem.Ref(), in sfPath, MountHostOption.None);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogName).Append(HostRootFileSystemMountName).Append(LogQuote); sb.Append(LogName).Append(HostRootFileSystemMountName).Append(LogQuote);
logBuffer = sb.Buffer; logBuffer = sb.Buffer;
fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLogUnlessResultSuccess(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = OpenHostFileSystemImpl(fs, ref fileSystem.Ref(), in sfPath, MountHostOption.None); res = OpenHostFileSystemImpl(fs, ref fileSystem.Ref(), in sfPath, MountHostOption.None);
} }
// No AbortIfNeeded here // No AbortIfNeeded here
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = PostMount(fs, ref fileSystem.Ref()); res = PostMount(fs, ref fileSystem.Ref());
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = PostMount(fs, ref fileSystem.Ref()); res = PostMount(fs, ref fileSystem.Ref());
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
fs.Impl.EnableFileSystemAccessorAccessLog(new U8Span(HostRootFileSystemMountName)); fs.Impl.EnableFileSystemAccessorAccessLog(new U8Span(HostRootFileSystemMountName));
@ -412,9 +412,9 @@ public static class Host
if (!mountNameGenerator.HasValue) if (!mountNameGenerator.HasValue)
return ResultFs.AllocationMemoryFailedInHostC.Log(); return ResultFs.AllocationMemoryFailedInHostC.Log();
Result rc = fs.Register(new U8Span(HostRootFileSystemMountName), ref fileSystem, Result res = fs.Register(new U8Span(HostRootFileSystemMountName), ref fileSystem,
ref mountNameGenerator.Ref()); ref mountNameGenerator.Ref());
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -428,7 +428,7 @@ public static class Host
/// <returns>The <see cref="Result"/> of the operation.</returns> /// <returns>The <see cref="Result"/> of the operation.</returns>
public static Result MountHostRoot(this FileSystemClient fs, MountHostOption option) public static Result MountHostRoot(this FileSystemClient fs, MountHostOption option)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x60]; Span<byte> logBuffer = stackalloc byte[0x60];
using var fileSystem = new UniqueRef<IFileSystem>(); using var fileSystem = new UniqueRef<IFileSystem>();
@ -437,7 +437,7 @@ public static class Host
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = OpenHostFileSystemImpl(fs, ref fileSystem.Ref(), in sfPath, option); res = OpenHostFileSystemImpl(fs, ref fileSystem.Ref(), in sfPath, option);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var idString = new IdString(); var idString = new IdString();
@ -448,31 +448,31 @@ public static class Host
logBuffer = sb.Buffer; logBuffer = sb.Buffer;
fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLogUnlessResultSuccess(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = OpenHostFileSystemImpl(fs, ref fileSystem.Ref(), in sfPath, option); res = OpenHostFileSystemImpl(fs, ref fileSystem.Ref(), in sfPath, option);
} }
// No AbortIfNeeded here // No AbortIfNeeded here
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = PostMount(fs, ref fileSystem.Ref()); res = PostMount(fs, ref fileSystem.Ref());
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = PostMount(fs, ref fileSystem.Ref()); res = PostMount(fs, ref fileSystem.Ref());
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
fs.Impl.EnableFileSystemAccessorAccessLog(new U8Span(HostRootFileSystemMountName)); fs.Impl.EnableFileSystemAccessorAccessLog(new U8Span(HostRootFileSystemMountName));
@ -487,9 +487,9 @@ public static class Host
if (!mountNameGenerator.HasValue) if (!mountNameGenerator.HasValue)
return ResultFs.AllocationMemoryFailedInHostC.Log(); return ResultFs.AllocationMemoryFailedInHostC.Log();
Result rc = fs.Register(new U8Span(HostRootFileSystemMountName), ref fileSystem, Result res = fs.Register(new U8Span(HostRootFileSystemMountName), ref fileSystem,
ref mountNameGenerator.Ref()); ref mountNameGenerator.Ref());
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -501,7 +501,7 @@ public static class Host
/// <param name="fs">The <see cref="FileSystemClient"/> to use.</param> /// <param name="fs">The <see cref="FileSystemClient"/> to use.</param>
public static void UnmountHostRoot(this FileSystemClient fs) public static void UnmountHostRoot(this FileSystemClient fs)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x30]; Span<byte> logBuffer = stackalloc byte[0x30];
var mountName = new U8Span(HostRootFileSystemMountName); var mountName = new U8Span(HostRootFileSystemMountName);
@ -509,20 +509,20 @@ public static class Host
if (fs.Impl.IsEnabledAccessLog() && fs.Impl.IsEnabledFileSystemAccessorAccessLog(mountName)) if (fs.Impl.IsEnabledAccessLog() && fs.Impl.IsEnabledFileSystemAccessorAccessLog(mountName))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fs.Impl.Unmount(mountName); res = fs.Impl.Unmount(mountName);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogName).Append(mountName).Append((byte)'"'); sb.Append(LogName).Append(mountName).Append((byte)'"');
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = fs.Impl.Unmount(mountName); res = fs.Impl.Unmount(mountName);
} }
fs.Impl.LogResultErrorMessage(rc); fs.Impl.LogResultErrorMessage(res);
Abort.DoAbortUnless(rc.IsSuccess()); Abort.DoAbortUnless(res.IsSuccess());
} }
} }

View File

@ -19,13 +19,13 @@ public static class ImageDirectory
{ {
public static Result MountImageDirectory(this FileSystemClient fs, U8Span mountName, ImageDirectoryId directoryId) public static Result MountImageDirectory(this FileSystemClient fs, U8Span mountName, ImageDirectoryId directoryId)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x50]; Span<byte> logBuffer = stackalloc byte[0x50];
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = Mount(fs, mountName, directoryId); res = Mount(fs, mountName, directoryId);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var idString = new IdString(); var idString = new IdString();
@ -34,15 +34,15 @@ public static class ImageDirectory
sb.Append(LogName).Append(mountName).Append(LogQuote) sb.Append(LogName).Append(mountName).Append(LogQuote)
.Append(LogImageDirectoryId).Append(idString.ToString(directoryId)); .Append(LogImageDirectoryId).Append(idString.ToString(directoryId));
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = Mount(fs, mountName, directoryId); res = Mount(fs, mountName, directoryId);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName); fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
@ -51,14 +51,14 @@ public static class ImageDirectory
static Result Mount(FileSystemClient fs, U8Span mountName, ImageDirectoryId directoryId) static Result Mount(FileSystemClient fs, U8Span mountName, ImageDirectoryId directoryId)
{ {
Result rc = fs.Impl.CheckMountName(mountName); Result res = fs.Impl.CheckMountName(mountName);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var fileSystem = new SharedRef<IFileSystemSf>(); using var fileSystem = new SharedRef<IFileSystemSf>();
rc = fileSystemProxy.Get.OpenImageDirectoryFileSystem(ref fileSystem.Ref(), directoryId); res = fileSystemProxy.Get.OpenImageDirectoryFileSystem(ref fileSystem.Ref(), directoryId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
using var fileSystemAdapter = using var fileSystemAdapter =
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref())); new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref()));
@ -66,8 +66,8 @@ public static class ImageDirectory
if (!fileSystemAdapter.HasValue) if (!fileSystemAdapter.HasValue)
return ResultFs.AllocationMemoryFailedInImageDirectoryA.Log(); return ResultFs.AllocationMemoryFailedInImageDirectoryA.Log();
rc = fs.Impl.Fs.Register(mountName, ref fileSystemAdapter.Ref()); res = fs.Impl.Fs.Register(mountName, ref fileSystemAdapter.Ref());
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }

View File

@ -15,9 +15,9 @@ public static class LoaderApi
using SharedRef<IFileSystemProxyForLoader> fileSystemProxy = using SharedRef<IFileSystemProxyForLoader> fileSystemProxy =
fs.Impl.GetFileSystemProxyForLoaderServiceObject(); fs.Impl.GetFileSystemProxyForLoaderServiceObject();
Result rc = fileSystemProxy.Get.IsArchivedProgram(out isArchived, processId.Value); Result res = fileSystemProxy.Get.IsArchivedProgram(out isArchived, processId.Value);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }

View File

@ -20,13 +20,13 @@ public static class Logo
{ {
public static Result MountLogo(this FileSystemClient fs, U8Span mountName, U8Span path, ProgramId programId) public static Result MountLogo(this FileSystemClient fs, U8Span mountName, U8Span path, ProgramId programId)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x300]; Span<byte> logBuffer = stackalloc byte[0x300];
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = Mount(fs, mountName, path, programId); res = Mount(fs, mountName, path, programId);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
@ -35,15 +35,15 @@ public static class Logo
.Append(LogPath).Append(path).Append(LogQuote) .Append(LogPath).Append(path).Append(LogQuote)
.Append(LogProgramId).AppendFormat(programId.Value, 'X'); .Append(LogProgramId).AppendFormat(programId.Value, 'X');
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = Mount(fs, mountName, path, programId); res = Mount(fs, mountName, path, programId);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName); fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
@ -52,18 +52,18 @@ public static class Logo
static Result Mount(FileSystemClient fs, U8Span mountName, U8Span path, ProgramId programId) static Result Mount(FileSystemClient fs, U8Span mountName, U8Span path, ProgramId programId)
{ {
Result rc = fs.Impl.CheckMountName(mountName); Result res = fs.Impl.CheckMountName(mountName);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = PathUtility.ConvertToFspPath(out FspPath sfPath, path); res = PathUtility.ConvertToFspPath(out FspPath sfPath, path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var fileSystem = new SharedRef<IFileSystemSf>(); using var fileSystem = new SharedRef<IFileSystemSf>();
rc = fileSystemProxy.Get.OpenFileSystemWithId(ref fileSystem.Ref(), in sfPath, programId.Value, res = fileSystemProxy.Get.OpenFileSystemWithId(ref fileSystem.Ref(), in sfPath, programId.Value,
FileSystemProxyType.Logo); FileSystemProxyType.Logo);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
using var fileSystemAdapter = using var fileSystemAdapter =
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref())); new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref()));
@ -71,8 +71,8 @@ public static class Logo
if (!fileSystemAdapter.HasValue) if (!fileSystemAdapter.HasValue)
return ResultFs.AllocationMemoryFailedInLogoA.Log(); return ResultFs.AllocationMemoryFailedInLogoA.Log();
rc = fs.Impl.Fs.Register(mountName, ref fileSystemAdapter.Ref()); res = fs.Impl.Fs.Register(mountName, ref fileSystemAdapter.Ref());
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }

View File

@ -13,9 +13,9 @@ public static class MemoryReportInfoShim
{ {
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.GetAndClearMemoryReportInfo(out reportInfo); Result res = fileSystemProxy.Get.GetAndClearMemoryReportInfo(out reportInfo);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }

View File

@ -18,13 +18,13 @@ public static class Mmc
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.GetMmcSpeedMode(out long speedMode); res = deviceOperator.Get.GetMmcSpeedMode(out long speedMode);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outSpeedMode = (MmcSpeedMode)speedMode; outSpeedMode = (MmcSpeedMode)speedMode;
return Result.Success; return Result.Success;
@ -35,13 +35,13 @@ public static class Mmc
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.GetMmcCid(new OutBuffer(outCidBuffer), outCidBuffer.Length); res = deviceOperator.Get.GetMmcCid(new OutBuffer(outCidBuffer), outCidBuffer.Length);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -51,13 +51,13 @@ public static class Mmc
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.EraseMmc((uint)partition); res = deviceOperator.Get.EraseMmc((uint)partition);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -70,13 +70,13 @@ public static class Mmc
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.GetMmcPartitionSize(out outPartitionSize, (uint)partition); res = deviceOperator.Get.GetMmcPartitionSize(out outPartitionSize, (uint)partition);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -88,13 +88,13 @@ public static class Mmc
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.GetMmcPatrolCount(out outPatrolCount); res = deviceOperator.Get.GetMmcPatrolCount(out outPatrolCount);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -107,14 +107,14 @@ public static class Mmc
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.GetAndClearMmcErrorInfo(out outErrorInfo, out long logSize, new OutBuffer(logBuffer), res = deviceOperator.Get.GetAndClearMmcErrorInfo(out outErrorInfo, out long logSize, new OutBuffer(logBuffer),
logBuffer.Length); logBuffer.Length);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outLogSize = logSize; outLogSize = logSize;
@ -126,13 +126,13 @@ public static class Mmc
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.GetMmcExtendedCsd(new OutBuffer(outBuffer), outBuffer.Length); res = deviceOperator.Get.GetMmcExtendedCsd(new OutBuffer(outBuffer), outBuffer.Length);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -142,13 +142,13 @@ public static class Mmc
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.SuspendMmcPatrol(); res = deviceOperator.Get.SuspendMmcPatrol();
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -158,13 +158,13 @@ public static class Mmc
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.ResumeMmcPatrol(); res = deviceOperator.Get.ResumeMmcPatrol();
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }

View File

@ -14,9 +14,9 @@ public static class PosixTimeShim
{ {
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.SetCurrentPosixTimeWithTimeDifference(currentPosixTime.Value, Result res = fileSystemProxy.Get.SetCurrentPosixTimeWithTimeDifference(currentPosixTime.Value,
timeDifferenceSeconds); timeDifferenceSeconds);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
} }

View File

@ -27,9 +27,9 @@ public static class ProgramIndexMapInfoShim
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.RegisterProgramIndexMapInfo(InBuffer.FromSpan(mapInfo), mapInfo.Length); Result res = fileSystemProxy.Get.RegisterProgramIndexMapInfo(InBuffer.FromSpan(mapInfo), mapInfo.Length);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }

View File

@ -21,15 +21,15 @@ public static class ProgramRegistry
{ {
using SharedRef<IProgramRegistry> programRegistry = fs.Impl.GetProgramRegistryServiceObject(); using SharedRef<IProgramRegistry> programRegistry = fs.Impl.GetProgramRegistryServiceObject();
Result rc = programRegistry.Get.SetCurrentProcess(fs.Hos.Os.GetCurrentProcessId().Value); Result res = programRegistry.Get.SetCurrentProcess(fs.Hos.Os.GetCurrentProcessId().Value);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = programRegistry.Get.RegisterProgram(processId, programId, storageId, new InBuffer(accessControlData), res = programRegistry.Get.RegisterProgram(processId, programId, storageId, new InBuffer(accessControlData),
accessControlData.Length, new InBuffer(accessControlDescriptor), accessControlDescriptor.Length); accessControlData.Length, new InBuffer(accessControlDescriptor), accessControlDescriptor.Length);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }

View File

@ -16,9 +16,9 @@ public static class RightsIdShim
{ {
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.GetRightsId(out rightsId, programId, storageId); Result res = fileSystemProxy.Get.GetRightsId(out rightsId, programId, storageId);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -27,15 +27,15 @@ public static class RightsIdShim
{ {
UnsafeHelpers.SkipParamInit(out rightsId); UnsafeHelpers.SkipParamInit(out rightsId);
Result rc = PathUtility.ConvertToFspPath(out FspPath sfPath, path); Result res = PathUtility.ConvertToFspPath(out FspPath sfPath, path);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
rc = fileSystemProxy.Get.GetRightsIdByPath(out rightsId, in sfPath); res = fileSystemProxy.Get.GetRightsIdByPath(out rightsId, in sfPath);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -44,15 +44,15 @@ public static class RightsIdShim
{ {
UnsafeHelpers.SkipParamInit(out rightsId, out keyGeneration); UnsafeHelpers.SkipParamInit(out rightsId, out keyGeneration);
Result rc = PathUtility.ConvertToFspPath(out FspPath sfPath, path); Result res = PathUtility.ConvertToFspPath(out FspPath sfPath, path);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
rc = fileSystemProxy.Get.GetRightsIdAndKeyGenerationByPath(out rightsId, out keyGeneration, in sfPath); res = fileSystemProxy.Get.GetRightsIdAndKeyGenerationByPath(out rightsId, out keyGeneration, in sfPath);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -61,9 +61,9 @@ public static class RightsIdShim
{ {
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.RegisterExternalKey(in rightsId, in key); Result res = fileSystemProxy.Get.RegisterExternalKey(in rightsId, in key);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -72,9 +72,9 @@ public static class RightsIdShim
{ {
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.UnregisterExternalKey(in rightsId); Result res = fileSystemProxy.Get.UnregisterExternalKey(in rightsId);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -83,9 +83,9 @@ public static class RightsIdShim
{ {
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.UnregisterAllExternalKey(); Result res = fileSystemProxy.Get.UnregisterAllExternalKey();
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }

View File

@ -30,9 +30,9 @@ public static class SaveData
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var fileSystem = new SharedRef<IFileSystemSf>(); using var fileSystem = new SharedRef<IFileSystemSf>();
Result rc = fileSystemProxy.Get.OpenSaveDataInternalStorageFileSystem(ref fileSystem.Ref(), spaceId, Result res = fileSystemProxy.Get.OpenSaveDataInternalStorageFileSystem(ref fileSystem.Ref(), spaceId,
saveDataId); saveDataId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
using var fileSystemAdapter = using var fileSystemAdapter =
new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref())); new UniqueRef<IFileSystem>(new FileSystemServiceObjectAdapter(ref fileSystem.Ref()));
@ -46,30 +46,30 @@ public static class SaveData
long saveDataJournalSize) long saveDataJournalSize)
{ {
// Find the save data for the current program. // Find the save data for the current program.
Result rc = SaveDataFilter.Make(out SaveDataFilter filter, InvalidProgramId.Value, SaveDataType.Account, userId, Result res = SaveDataFilter.Make(out SaveDataFilter filter, InvalidProgramId.Value, SaveDataType.Account, userId,
InvalidSystemSaveDataId, index: 0, SaveDataRank.Primary); InvalidSystemSaveDataId, index: 0, SaveDataRank.Primary);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = fs.Impl.FindSaveDataWithFilter(out SaveDataInfo info, SaveDataSpaceId.User, in filter); res = fs.Impl.FindSaveDataWithFilter(out SaveDataInfo info, SaveDataSpaceId.User, in filter);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
SaveDataSpaceId spaceId = info.SpaceId; SaveDataSpaceId spaceId = info.SpaceId;
ulong saveDataId = info.SaveDataId; ulong saveDataId = info.SaveDataId;
// Get the current save data's sizes. // Get the current save data's sizes.
rc = fs.Impl.GetSaveDataAvailableSize(out long availableSize, spaceId, saveDataId); res = fs.Impl.GetSaveDataAvailableSize(out long availableSize, spaceId, saveDataId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = fs.Impl.GetSaveDataJournalSize(out long journalSize, spaceId, saveDataId); res = fs.Impl.GetSaveDataJournalSize(out long journalSize, spaceId, saveDataId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
// Extend the save data if it's not large enough. // Extend the save data if it's not large enough.
if (availableSize < saveDataSize || journalSize < saveDataJournalSize) if (availableSize < saveDataSize || journalSize < saveDataJournalSize)
{ {
long newSaveDataSize = Math.Max(saveDataSize, availableSize); long newSaveDataSize = Math.Max(saveDataSize, availableSize);
long newJournalSize = Math.Max(saveDataJournalSize, journalSize); long newJournalSize = Math.Max(saveDataJournalSize, journalSize);
rc = fs.Impl.ExtendSaveData(spaceId, saveDataId, newSaveDataSize, newJournalSize); res = fs.Impl.ExtendSaveData(spaceId, saveDataId, newSaveDataSize, newJournalSize);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
} }
return Result.Success; return Result.Success;
@ -78,26 +78,26 @@ public static class SaveData
private static Result MountSaveDataImpl(this FileSystemClientImpl fs, U8Span mountName, SaveDataSpaceId spaceId, private static Result MountSaveDataImpl(this FileSystemClientImpl fs, U8Span mountName, SaveDataSpaceId spaceId,
ProgramId programId, UserId userId, SaveDataType type, bool openReadOnly, ushort index) ProgramId programId, UserId userId, SaveDataType type, bool openReadOnly, ushort index)
{ {
Result rc = fs.CheckMountName(mountName); Result res = fs.CheckMountName(mountName);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.GetFileSystemProxyServiceObject();
rc = SaveDataAttribute.Make(out SaveDataAttribute attribute, programId, type, userId, InvalidSystemSaveDataId, res = SaveDataAttribute.Make(out SaveDataAttribute attribute, programId, type, userId, InvalidSystemSaveDataId,
index); index);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var fileSystem = new SharedRef<IFileSystemSf>(); using var fileSystem = new SharedRef<IFileSystemSf>();
if (openReadOnly) if (openReadOnly)
{ {
rc = fileSystemProxy.Get.OpenReadOnlySaveDataFileSystem(ref fileSystem.Ref(), spaceId, in attribute); res = fileSystemProxy.Get.OpenReadOnlySaveDataFileSystem(ref fileSystem.Ref(), spaceId, in attribute);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
else else
{ {
rc = fileSystemProxy.Get.OpenSaveDataFileSystem(ref fileSystem.Ref(), spaceId, in attribute); res = fileSystemProxy.Get.OpenSaveDataFileSystem(ref fileSystem.Ref(), spaceId, in attribute);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
// Note: Nintendo does pass in the same object both as a unique_ptr and as a raw pointer. // Note: Nintendo does pass in the same object both as a unique_ptr and as a raw pointer.
@ -110,9 +110,9 @@ public static class SaveData
using var mountNameGenerator = new UniqueRef<ICommonMountNameGenerator>(); using var mountNameGenerator = new UniqueRef<ICommonMountNameGenerator>();
rc = fs.Fs.Register(mountName, fileSystemAdapterRaw, ref fileSystemAdapter.Ref(), ref mountNameGenerator.Ref(), res = fs.Fs.Register(mountName, fileSystemAdapterRaw, ref fileSystemAdapter.Ref(), ref mountNameGenerator.Ref(),
false, null, true); false, null, true);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -131,13 +131,13 @@ public static class SaveData
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.GetFileSystemProxyServiceObject();
Result rc = SaveDataAttribute.Make(out SaveDataAttribute attribute, InvalidProgramId, SaveDataType.Account, Result res = SaveDataAttribute.Make(out SaveDataAttribute attribute, InvalidProgramId, SaveDataType.Account,
userId, InvalidSystemSaveDataId); userId, InvalidSystemSaveDataId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = SaveDataCreationInfo.Make(out SaveDataCreationInfo creationInfo, saveDataSize, saveDataJournalSize, res = SaveDataCreationInfo.Make(out SaveDataCreationInfo creationInfo, saveDataSize, saveDataJournalSize,
ownerId: 0, SaveDataFlags.None, SaveDataSpaceId.User); ownerId: 0, SaveDataFlags.None, SaveDataSpaceId.User);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
var metaInfo = new SaveDataMetaInfo var metaInfo = new SaveDataMetaInfo
{ {
@ -145,22 +145,22 @@ public static class SaveData
Size = 0 Size = 0
}; };
rc = fileSystemProxy.Get.CreateSaveDataFileSystem(in attribute, in creationInfo, in metaInfo); res = fileSystemProxy.Get.CreateSaveDataFileSystem(in attribute, in creationInfo, in metaInfo);
if (rc.IsFailure()) if (res.IsFailure())
{ {
// Ensure the save is large enough if it already exists // Ensure the save is large enough if it already exists
if (ResultFs.PathAlreadyExists.Includes(rc)) if (ResultFs.PathAlreadyExists.Includes(res))
{ {
if (extendIfNeeded) if (extendIfNeeded)
{ {
rc = ExtendSaveDataIfNeeded(fs.Fs, userId, saveDataSize, saveDataJournalSize); res = ExtendSaveDataIfNeeded(fs.Fs, userId, saveDataSize, saveDataJournalSize);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
} }
} }
else else
{ {
return rc.Miss(); return res.Miss();
} }
} }
@ -175,28 +175,28 @@ public static class SaveData
public static Result MountSaveData(this FileSystemClient fs, U8Span mountName, UserId userId) public static Result MountSaveData(this FileSystemClient fs, U8Span mountName, UserId userId)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x60]; Span<byte> logBuffer = stackalloc byte[0x60];
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = MountSaveDataImpl(fs.Impl, mountName, InvalidUserId); res = MountSaveDataImpl(fs.Impl, mountName, InvalidUserId);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogName).Append(mountName).Append(LogQuote) sb.Append(LogName).Append(mountName).Append(LogQuote)
.Append(LogUserId).AppendFormat(userId.Id.High, 'X', 16).AppendFormat(userId.Id.Low, 'X', 16); .Append(LogUserId).AppendFormat(userId.Id.High, 'X', 16).AppendFormat(userId.Id.Low, 'X', 16);
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = MountSaveDataImpl(fs.Impl, mountName, InvalidUserId); res = MountSaveDataImpl(fs.Impl, mountName, InvalidUserId);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName); fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
@ -207,13 +207,13 @@ public static class SaveData
public static Result MountSaveData(this FileSystemClient fs, U8Span mountName, Ncm.ApplicationId applicationId, public static Result MountSaveData(this FileSystemClient fs, U8Span mountName, Ncm.ApplicationId applicationId,
UserId userId) UserId userId)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x90]; Span<byte> logBuffer = stackalloc byte[0x90];
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.User, applicationId, userId, res = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.User, applicationId, userId,
SaveDataType.Account, openReadOnly: false, index: 0); SaveDataType.Account, openReadOnly: false, index: 0);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
@ -222,16 +222,16 @@ public static class SaveData
.Append(LogApplicationId).AppendFormat(applicationId.Value, 'X') .Append(LogApplicationId).AppendFormat(applicationId.Value, 'X')
.Append(LogUserId).AppendFormat(userId.Id.High, 'X', 16).AppendFormat(userId.Id.Low, 'X', 16); .Append(LogUserId).AppendFormat(userId.Id.High, 'X', 16).AppendFormat(userId.Id.Low, 'X', 16);
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.User, applicationId, userId, res = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.User, applicationId, userId,
SaveDataType.Account, openReadOnly: false, index: 0); SaveDataType.Account, openReadOnly: false, index: 0);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName); fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
@ -242,13 +242,13 @@ public static class SaveData
public static Result MountSaveDataReadOnly(this FileSystemClient fs, U8Span mountName, public static Result MountSaveDataReadOnly(this FileSystemClient fs, U8Span mountName,
Ncm.ApplicationId applicationId, UserId userId) Ncm.ApplicationId applicationId, UserId userId)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x90]; Span<byte> logBuffer = stackalloc byte[0x90];
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.User, applicationId, userId, res = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.User, applicationId, userId,
SaveDataType.Account, openReadOnly: true, index: 0); SaveDataType.Account, openReadOnly: true, index: 0);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
@ -257,16 +257,16 @@ public static class SaveData
.Append(LogApplicationId).AppendFormat(applicationId.Value, 'X') .Append(LogApplicationId).AppendFormat(applicationId.Value, 'X')
.Append(LogUserId).AppendFormat(userId.Id.High, 'X', 16).AppendFormat(userId.Id.Low, 'X', 16); .Append(LogUserId).AppendFormat(userId.Id.High, 'X', 16).AppendFormat(userId.Id.Low, 'X', 16);
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.User, applicationId, userId, res = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.User, applicationId, userId,
SaveDataType.Account, openReadOnly: true, index: 0); SaveDataType.Account, openReadOnly: true, index: 0);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName); fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
@ -292,53 +292,53 @@ public static class SaveData
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.GetFileSystemProxyServiceObject();
Result rc = SaveDataAttribute.Make(out SaveDataAttribute attribute, applicationId, type, userId, Result res = SaveDataAttribute.Make(out SaveDataAttribute attribute, applicationId, type, userId,
InvalidSystemSaveDataId); InvalidSystemSaveDataId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
using var fileSystem = new SharedRef<IFileSystemSf>(); using var fileSystem = new SharedRef<IFileSystemSf>();
rc = fileSystemProxy.Get.OpenSaveDataFileSystem(ref fileSystem.Ref(), SaveDataSpaceId.User, in attribute); res = fileSystemProxy.Get.OpenSaveDataFileSystem(ref fileSystem.Ref(), SaveDataSpaceId.User, in attribute);
if (rc.IsSuccess() || ResultFs.TargetLocked.Includes(rc) || ResultFs.SaveDataExtending.Includes(rc)) if (res.IsSuccess() || ResultFs.TargetLocked.Includes(res) || ResultFs.SaveDataExtending.Includes(res))
{ {
exists = true; exists = true;
return Result.Success; return Result.Success;
} }
if (ResultFs.TargetNotFound.Includes(rc)) if (ResultFs.TargetNotFound.Includes(res))
{ {
exists = false; exists = false;
return Result.Success; return Result.Success;
} }
return rc.Miss(); return res.Miss();
} }
public static Result MountTemporaryStorage(this FileSystemClient fs, U8Span mountName) public static Result MountTemporaryStorage(this FileSystemClient fs, U8Span mountName)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x30]; Span<byte> logBuffer = stackalloc byte[0x30];
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.Temporary, InvalidProgramId, InvalidUserId, res = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.Temporary, InvalidProgramId, InvalidUserId,
SaveDataType.Temporary, openReadOnly: false, index: 0); SaveDataType.Temporary, openReadOnly: false, index: 0);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogName).Append(mountName).Append(LogQuote); sb.Append(LogName).Append(mountName).Append(LogQuote);
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.Temporary, InvalidProgramId, InvalidUserId, res = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.Temporary, InvalidProgramId, InvalidUserId,
SaveDataType.Temporary, openReadOnly: false, index: 0); SaveDataType.Temporary, openReadOnly: false, index: 0);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName); fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
@ -348,29 +348,29 @@ public static class SaveData
public static Result MountCacheStorage(this FileSystemClient fs, U8Span mountName) public static Result MountCacheStorage(this FileSystemClient fs, U8Span mountName)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x30]; Span<byte> logBuffer = stackalloc byte[0x30];
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.User, InvalidProgramId, res = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.User, InvalidProgramId,
InvalidUserId, SaveDataType.Cache, openReadOnly: false, index: 0); InvalidUserId, SaveDataType.Cache, openReadOnly: false, index: 0);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogName).Append(mountName).Append(LogQuote); sb.Append(LogName).Append(mountName).Append(LogQuote);
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.User, InvalidProgramId, res = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.User, InvalidProgramId,
InvalidUserId, SaveDataType.Cache, openReadOnly: false, index: 0); InvalidUserId, SaveDataType.Cache, openReadOnly: false, index: 0);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName); fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
@ -380,14 +380,14 @@ public static class SaveData
public static Result MountCacheStorage(this FileSystemClient fs, U8Span mountName, int index) public static Result MountCacheStorage(this FileSystemClient fs, U8Span mountName, int index)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x40]; Span<byte> logBuffer = stackalloc byte[0x40];
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.User, InvalidProgramId, res = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.User, InvalidProgramId,
InvalidUserId, SaveDataType.Cache, openReadOnly: false, (ushort)index); InvalidUserId, SaveDataType.Cache, openReadOnly: false, (ushort)index);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
@ -395,16 +395,16 @@ public static class SaveData
sb.Append(LogName).Append(mountName).Append(LogQuote) sb.Append(LogName).Append(mountName).Append(LogQuote)
.Append(LogIndex).AppendFormat(index); .Append(LogIndex).AppendFormat(index);
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.User, InvalidProgramId, res = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.User, InvalidProgramId,
InvalidUserId, SaveDataType.Cache, openReadOnly: false, (ushort)index); InvalidUserId, SaveDataType.Cache, openReadOnly: false, (ushort)index);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName); fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
@ -414,13 +414,13 @@ public static class SaveData
public static Result MountCacheStorage(this FileSystemClient fs, U8Span mountName, Ncm.ApplicationId applicationId) public static Result MountCacheStorage(this FileSystemClient fs, U8Span mountName, Ncm.ApplicationId applicationId)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x50]; Span<byte> logBuffer = stackalloc byte[0x50];
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.User, applicationId, res = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.User, applicationId,
InvalidUserId, SaveDataType.Cache, openReadOnly: false, index: 0); InvalidUserId, SaveDataType.Cache, openReadOnly: false, index: 0);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
@ -428,16 +428,16 @@ public static class SaveData
sb.Append(LogName).Append(mountName).Append(LogQuote) sb.Append(LogName).Append(mountName).Append(LogQuote)
.Append(LogApplicationId).AppendFormat(applicationId.Value, 'X'); .Append(LogApplicationId).AppendFormat(applicationId.Value, 'X');
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.User, applicationId, res = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.User, applicationId,
InvalidUserId, SaveDataType.Cache, openReadOnly: false, index: 0); InvalidUserId, SaveDataType.Cache, openReadOnly: false, index: 0);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName); fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
@ -448,13 +448,13 @@ public static class SaveData
public static Result MountCacheStorage(this FileSystemClient fs, U8Span mountName, Ncm.ApplicationId applicationId, public static Result MountCacheStorage(this FileSystemClient fs, U8Span mountName, Ncm.ApplicationId applicationId,
int index) int index)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x60]; Span<byte> logBuffer = stackalloc byte[0x60];
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.User, applicationId, res = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.User, applicationId,
InvalidUserId, SaveDataType.Cache, openReadOnly: false, (ushort)index); InvalidUserId, SaveDataType.Cache, openReadOnly: false, (ushort)index);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
@ -463,16 +463,16 @@ public static class SaveData
.Append(LogApplicationId).AppendFormat(applicationId.Value, 'X') .Append(LogApplicationId).AppendFormat(applicationId.Value, 'X')
.Append(LogIndex).AppendFormat(index); .Append(LogIndex).AppendFormat(index);
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.User, applicationId, res = MountSaveDataImpl(fs.Impl, mountName, SaveDataSpaceId.User, applicationId,
InvalidUserId, SaveDataType.Cache, openReadOnly: false, (ushort)index); InvalidUserId, SaveDataType.Cache, openReadOnly: false, (ushort)index);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName); fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
@ -483,9 +483,9 @@ public static class SaveData
public static Result OpenSaveDataInternalStorageFileSystem(this FileSystemClient fs, public static Result OpenSaveDataInternalStorageFileSystem(this FileSystemClient fs,
ref UniqueRef<IFileSystem> outFileSystem, SaveDataSpaceId spaceId, ulong saveDataId) ref UniqueRef<IFileSystem> outFileSystem, SaveDataSpaceId spaceId, ulong saveDataId)
{ {
Result rc = OpenSaveDataInternalStorageFileSystemImpl(fs, ref outFileSystem, spaceId, saveDataId); Result res = OpenSaveDataInternalStorageFileSystemImpl(fs, ref outFileSystem, spaceId, saveDataId);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -493,21 +493,21 @@ public static class SaveData
public static Result MountSaveDataInternalStorage(this FileSystemClient fs, U8Span mountName, public static Result MountSaveDataInternalStorage(this FileSystemClient fs, U8Span mountName,
SaveDataSpaceId spaceId, ulong saveDataId) SaveDataSpaceId spaceId, ulong saveDataId)
{ {
Result rc = Operate(fs, mountName, spaceId, saveDataId); Result res = Operate(fs, mountName, spaceId, saveDataId);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
static Result Operate(FileSystemClient fs, U8Span mountName, SaveDataSpaceId spaceId, ulong saveDataId) static Result Operate(FileSystemClient fs, U8Span mountName, SaveDataSpaceId spaceId, ulong saveDataId)
{ {
Result rc = fs.Impl.CheckMountName(mountName); Result res = fs.Impl.CheckMountName(mountName);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
using var fileSystem = new UniqueRef<IFileSystem>(); using var fileSystem = new UniqueRef<IFileSystem>();
rc = OpenSaveDataInternalStorageFileSystemImpl(fs, ref fileSystem.Ref(), spaceId, saveDataId); res = OpenSaveDataInternalStorageFileSystemImpl(fs, ref fileSystem.Ref(), spaceId, saveDataId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return fs.Register(mountName, ref fileSystem.Ref()); return fs.Register(mountName, ref fileSystem.Ref());
} }

View File

@ -23,36 +23,36 @@ public static class SaveDataForDebug
public static void SetSaveDataRootPath(this FileSystemClient fs, U8Span path) public static void SetSaveDataRootPath(this FileSystemClient fs, U8Span path)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x300]; Span<byte> logBuffer = stackalloc byte[0x300];
if (fs.Impl.IsEnabledAccessLog() && fs.Impl.IsEnabledHandleAccessLog(null)) if (fs.Impl.IsEnabledAccessLog() && fs.Impl.IsEnabledHandleAccessLog(null))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = SetRootPath(fs, path); res = SetRootPath(fs, path);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogPath).Append(path).Append(LogQuote); sb.Append(LogPath).Append(path).Append(LogQuote);
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = SetRootPath(fs, path); res = SetRootPath(fs, path);
} }
fs.Impl.LogResultErrorMessage(rc); fs.Impl.LogResultErrorMessage(res);
Abort.DoAbortUnlessSuccess(rc); Abort.DoAbortUnlessSuccess(res);
static Result SetRootPath(FileSystemClient fs, U8Span path) static Result SetRootPath(FileSystemClient fs, U8Span path)
{ {
Result rc = PathUtility.ConvertToFspPath(out FspPath sfPath, path); Result res = PathUtility.ConvertToFspPath(out FspPath sfPath, path);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
rc = fileSystemProxy.Get.SetSaveDataRootPath(in sfPath); res = fileSystemProxy.Get.SetSaveDataRootPath(in sfPath);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -60,25 +60,25 @@ public static class SaveDataForDebug
public static void UnsetSaveDataRootPath(this FileSystemClient fs) public static void UnsetSaveDataRootPath(this FileSystemClient fs)
{ {
Result rc; Result res;
if (fs.Impl.IsEnabledAccessLog() && fs.Impl.IsEnabledHandleAccessLog(null)) if (fs.Impl.IsEnabledAccessLog() && fs.Impl.IsEnabledHandleAccessLog(null))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
rc = fileSystemProxy.Get.UnsetSaveDataRootPath(); res = fileSystemProxy.Get.UnsetSaveDataRootPath();
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
fs.Impl.OutputAccessLog(rc, start, end, null, U8Span.Empty); fs.Impl.OutputAccessLog(res, start, end, null, U8Span.Empty);
} }
else else
{ {
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
rc = fileSystemProxy.Get.UnsetSaveDataRootPath(); res = fileSystemProxy.Get.UnsetSaveDataRootPath();
} }
fs.Impl.LogResultErrorMessage(rc); fs.Impl.LogResultErrorMessage(res);
Abort.DoAbortUnlessSuccess(rc); Abort.DoAbortUnlessSuccess(res);
} }
/// <summary> /// <summary>
@ -96,27 +96,27 @@ public static class SaveDataForDebug
/// <see cref="ResultFs.PermissionDenied"/>: Insufficient permissions.</returns> /// <see cref="ResultFs.PermissionDenied"/>: Insufficient permissions.</returns>
public static Result EnsureSaveDataForDebug(this FileSystemClient fs, long saveDataSize, long saveDataJournalSize) public static Result EnsureSaveDataForDebug(this FileSystemClient fs, long saveDataSize, long saveDataJournalSize)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x60]; Span<byte> logBuffer = stackalloc byte[0x60];
if (fs.Impl.IsEnabledAccessLog() && fs.Impl.IsEnabledHandleAccessLog(null)) if (fs.Impl.IsEnabledAccessLog() && fs.Impl.IsEnabledHandleAccessLog(null))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = Ensure(fs, saveDataSize, saveDataJournalSize); res = Ensure(fs, saveDataSize, saveDataJournalSize);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogSaveDataSize).AppendFormat(saveDataSize, 'd') sb.Append(LogSaveDataSize).AppendFormat(saveDataSize, 'd')
.Append(LogSaveDataJournalSize).AppendFormat(saveDataJournalSize, 'd'); .Append(LogSaveDataJournalSize).AppendFormat(saveDataJournalSize, 'd');
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = Ensure(fs, saveDataSize, saveDataJournalSize); res = Ensure(fs, saveDataSize, saveDataJournalSize);
} }
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
@ -124,9 +124,9 @@ public static class SaveDataForDebug
{ {
UserId userIdForDebug = InvalidUserId; UserId userIdForDebug = InvalidUserId;
Result rc = fs.Impl.EnsureSaveDataImpl(userIdForDebug, saveDataSize, saveDataJournalSize, Result res = fs.Impl.EnsureSaveDataImpl(userIdForDebug, saveDataSize, saveDataJournalSize,
extendIfNeeded: true); extendIfNeeded: true);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -146,26 +146,26 @@ public static class SaveDataForDebug
/// <see cref="ResultFs.PermissionDenied"/>: Insufficient permissions.</returns> /// <see cref="ResultFs.PermissionDenied"/>: Insufficient permissions.</returns>
public static Result MountSaveDataForDebug(this FileSystemClient fs, U8Span mountName) public static Result MountSaveDataForDebug(this FileSystemClient fs, U8Span mountName)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x30]; Span<byte> logBuffer = stackalloc byte[0x30];
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = Mount(fs, mountName); res = Mount(fs, mountName);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogName).Append(mountName).Append(LogQuote); sb.Append(LogName).Append(mountName).Append(LogQuote);
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = Mount(fs, mountName); res = Mount(fs, mountName);
} }
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName); fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
@ -176,12 +176,12 @@ public static class SaveDataForDebug
{ {
UserId userIdForDebug = InvalidUserId; UserId userIdForDebug = InvalidUserId;
Result rc = fs.Impl.EnsureSaveDataImpl(userIdForDebug, SaveDataSizeForDebug, SaveDataJournalSizeForDebug, Result res = fs.Impl.EnsureSaveDataImpl(userIdForDebug, SaveDataSizeForDebug, SaveDataJournalSizeForDebug,
extendIfNeeded: false); extendIfNeeded: false);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = fs.Impl.MountSaveDataImpl(mountName, userIdForDebug); res = fs.Impl.MountSaveDataImpl(mountName, userIdForDebug);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }

File diff suppressed because it is too large Load Diff

View File

@ -33,25 +33,25 @@ public class SaveDataChunkIterator : ISaveDataChunkIterator
public ushort GetId() public ushort GetId()
{ {
Result rc = _baseInterface.Get.GetId(out uint id); Result res = _baseInterface.Get.GetId(out uint id);
_fsClient.Impl.LogResultErrorMessage(rc); _fsClient.Impl.LogResultErrorMessage(res);
Abort.DoAbortUnless(rc.IsSuccess()); Abort.DoAbortUnless(res.IsSuccess());
return (ushort)id; return (ushort)id;
} }
public void Next() public void Next()
{ {
Result rc = _baseInterface.Get.Next(); Result res = _baseInterface.Get.Next();
_fsClient.Impl.LogResultErrorMessage(rc); _fsClient.Impl.LogResultErrorMessage(res);
Abort.DoAbortUnless(rc.IsSuccess()); Abort.DoAbortUnless(res.IsSuccess());
} }
public bool IsEnd() public bool IsEnd()
{ {
Result rc = _baseInterface.Get.IsEnd(out bool isEnd); Result res = _baseInterface.Get.IsEnd(out bool isEnd);
_fsClient.Impl.LogResultErrorMessage(rc); _fsClient.Impl.LogResultErrorMessage(res);
Abort.DoAbortUnless(rc.IsSuccess()); Abort.DoAbortUnless(res.IsSuccess());
return isEnd; return isEnd;
} }
@ -84,11 +84,11 @@ public class SaveDataChunkExporter : ISaveDataChunkExporter
{ {
UnsafeHelpers.SkipParamInit(out outPulledSize); UnsafeHelpers.SkipParamInit(out outPulledSize);
Result rc = _baseInterface.Get.Pull(out ulong pulledSize, new OutBuffer(destination), Result res = _baseInterface.Get.Pull(out ulong pulledSize, new OutBuffer(destination),
(ulong)destination.Length); (ulong)destination.Length);
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outPulledSize = pulledSize; outPulledSize = pulledSize;
return Result.Success; return Result.Success;
@ -96,9 +96,9 @@ public class SaveDataChunkExporter : ISaveDataChunkExporter
public long GetRestRawDataSize() public long GetRestRawDataSize()
{ {
Result rc = _baseInterface.Get.GetRestRawDataSize(out long restSize); Result res = _baseInterface.Get.GetRestRawDataSize(out long restSize);
_fsClient.Impl.LogResultErrorMessage(rc); _fsClient.Impl.LogResultErrorMessage(res);
Abort.DoAbortUnless(rc.IsSuccess()); Abort.DoAbortUnless(res.IsSuccess());
return restSize; return restSize;
} }
@ -129,9 +129,9 @@ public class SaveDataChunkImporter : ISaveDataChunkImporter
public Result Push(ReadOnlySpan<byte> source) public Result Push(ReadOnlySpan<byte> source)
{ {
Result rc = _baseInterface.Get.Push(new InBuffer(source), (ulong)source.Length); Result res = _baseInterface.Get.Push(new InBuffer(source), (ulong)source.Length);
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -163,9 +163,9 @@ public class SaveDataExporterVersion2 : ISaveDataDivisionExporter
public Result SetDivisionCount(int divisionCount) public Result SetDivisionCount(int divisionCount)
{ {
Result rc = _baseInterface.Get.SetDivisionCount(divisionCount); Result res = _baseInterface.Get.SetDivisionCount(divisionCount);
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -174,9 +174,9 @@ public class SaveDataExporterVersion2 : ISaveDataDivisionExporter
{ {
using var iteratorObject = new SharedRef<FsSrv.Sf.ISaveDataChunkIterator>(); using var iteratorObject = new SharedRef<FsSrv.Sf.ISaveDataChunkIterator>();
Result rc = _baseInterface.Get.OpenSaveDataDiffChunkIterator(ref iteratorObject.Ref()); Result res = _baseInterface.Get.OpenSaveDataDiffChunkIterator(ref iteratorObject.Ref());
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outIterator.Reset(new SaveDataChunkIterator(_fsClient, ref iteratorObject.Ref())); outIterator.Reset(new SaveDataChunkIterator(_fsClient, ref iteratorObject.Ref()));
return Result.Success; return Result.Success;
@ -186,9 +186,9 @@ public class SaveDataExporterVersion2 : ISaveDataDivisionExporter
{ {
using var exporterObject = new SharedRef<FsSrv.Sf.ISaveDataChunkExporter>(); using var exporterObject = new SharedRef<FsSrv.Sf.ISaveDataChunkExporter>();
Result rc = _baseInterface.Get.OpenSaveDataChunkExporter(ref exporterObject.Ref(), chunkId); Result res = _baseInterface.Get.OpenSaveDataChunkExporter(ref exporterObject.Ref(), chunkId);
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outExporter.Reset(new SaveDataChunkExporter(_fsClient, ref exporterObject.Ref())); outExporter.Reset(new SaveDataChunkExporter(_fsClient, ref exporterObject.Ref()));
return Result.Success; return Result.Success;
@ -198,9 +198,9 @@ public class SaveDataExporterVersion2 : ISaveDataDivisionExporter
{ {
UnsafeHelpers.SkipParamInit(out outKeySeed); UnsafeHelpers.SkipParamInit(out outKeySeed);
Result rc = _baseInterface.Get.GetKeySeed(out KeySeed keySeed); Result res = _baseInterface.Get.GetKeySeed(out KeySeed keySeed);
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outKeySeed = keySeed; outKeySeed = keySeed;
return Result.Success; return Result.Success;
@ -210,9 +210,9 @@ public class SaveDataExporterVersion2 : ISaveDataDivisionExporter
{ {
UnsafeHelpers.SkipParamInit(out outInitialDataMac); UnsafeHelpers.SkipParamInit(out outInitialDataMac);
Result rc = _baseInterface.Get.GetInitialDataMac(out InitialDataMac initialDataMac); Result res = _baseInterface.Get.GetInitialDataMac(out InitialDataMac initialDataMac);
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outInitialDataMac = initialDataMac; outInitialDataMac = initialDataMac;
return Result.Success; return Result.Success;
@ -222,9 +222,9 @@ public class SaveDataExporterVersion2 : ISaveDataDivisionExporter
{ {
UnsafeHelpers.SkipParamInit(out outKeyGeneration); UnsafeHelpers.SkipParamInit(out outKeyGeneration);
Result rc = _baseInterface.Get.GetInitialDataMacKeyGeneration(out int initialDataMacKeyGeneration); Result res = _baseInterface.Get.GetInitialDataMacKeyGeneration(out int initialDataMacKeyGeneration);
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outKeyGeneration = initialDataMacKeyGeneration; outKeyGeneration = initialDataMacKeyGeneration;
return Result.Success; return Result.Success;
@ -232,18 +232,18 @@ public class SaveDataExporterVersion2 : ISaveDataDivisionExporter
public Result FinalizeExport() public Result FinalizeExport()
{ {
Result rc = _baseInterface.Get.FinalizeExport(); Result res = _baseInterface.Get.FinalizeExport();
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
public Result CancelExport() public Result CancelExport()
{ {
Result rc = _baseInterface.Get.CancelExport(); Result res = _baseInterface.Get.CancelExport();
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -252,9 +252,9 @@ public class SaveDataExporterVersion2 : ISaveDataDivisionExporter
{ {
UnsafeHelpers.SkipParamInit(out outContext); UnsafeHelpers.SkipParamInit(out outContext);
Result rc = _baseInterface.Get.SuspendExport(OutBuffer.FromStruct(ref outContext)); Result res = _baseInterface.Get.SuspendExport(OutBuffer.FromStruct(ref outContext));
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -263,9 +263,9 @@ public class SaveDataExporterVersion2 : ISaveDataDivisionExporter
{ {
UnsafeHelpers.SkipParamInit(out outInitialDataAad); UnsafeHelpers.SkipParamInit(out outInitialDataAad);
Result rc = _baseInterface.Get.GetImportInitialDataAad(out InitialDataAad initialDataAad); Result res = _baseInterface.Get.GetImportInitialDataAad(out InitialDataAad initialDataAad);
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outInitialDataAad = initialDataAad; outInitialDataAad = initialDataAad;
return Result.Success; return Result.Success;
@ -273,9 +273,9 @@ public class SaveDataExporterVersion2 : ISaveDataDivisionExporter
public Result SetExportInitialDataAad(in InitialDataAad initialDataAad) public Result SetExportInitialDataAad(in InitialDataAad initialDataAad)
{ {
Result rc = _baseInterface.Get.SetExportInitialDataAad(in initialDataAad); Result res = _baseInterface.Get.SetExportInitialDataAad(in initialDataAad);
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -285,9 +285,9 @@ public class SaveDataExporterVersion2 : ISaveDataDivisionExporter
UnsafeHelpers.SkipParamInit(out outCommitId); UnsafeHelpers.SkipParamInit(out outCommitId);
Unsafe.SkipInit(out SaveDataExtraData extraData); Unsafe.SkipInit(out SaveDataExtraData extraData);
Result rc = _baseInterface.Get.ReadSaveDataExtraData(OutBuffer.FromStruct(ref extraData)); Result res = _baseInterface.Get.ReadSaveDataExtraData(OutBuffer.FromStruct(ref extraData));
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outCommitId = extraData.CommitId; outCommitId = extraData.CommitId;
return Result.Success; return Result.Success;
@ -298,9 +298,9 @@ public class SaveDataExporterVersion2 : ISaveDataDivisionExporter
UnsafeHelpers.SkipParamInit(out outTimeStamp); UnsafeHelpers.SkipParamInit(out outTimeStamp);
Unsafe.SkipInit(out SaveDataExtraData extraData); Unsafe.SkipInit(out SaveDataExtraData extraData);
Result rc = _baseInterface.Get.ReadSaveDataExtraData(OutBuffer.FromStruct(ref extraData)); Result res = _baseInterface.Get.ReadSaveDataExtraData(OutBuffer.FromStruct(ref extraData));
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outTimeStamp = new PosixTime(extraData.TimeStamp); outTimeStamp = new PosixTime(extraData.TimeStamp);
return Result.Success; return Result.Success;
@ -308,9 +308,9 @@ public class SaveDataExporterVersion2 : ISaveDataDivisionExporter
public Result GetReportInfo(out ExportReportInfo outReportInfo) public Result GetReportInfo(out ExportReportInfo outReportInfo)
{ {
Result rc = _baseInterface.Get.GetReportInfo(out outReportInfo); Result res = _baseInterface.Get.GetReportInfo(out outReportInfo);
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -342,36 +342,36 @@ public class SaveDataImporterVersion2 : ISaveDataDivisionImporter
public Result InitializeImport(out long remaining, long sizeToProcess) public Result InitializeImport(out long remaining, long sizeToProcess)
{ {
Result rc = _baseInterface.Get.InitializeImport(out remaining, sizeToProcess); Result res = _baseInterface.Get.InitializeImport(out remaining, sizeToProcess);
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
public Result FinalizeImport() public Result FinalizeImport()
{ {
Result rc = _baseInterface.Get.FinalizeImport(); Result res = _baseInterface.Get.FinalizeImport();
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
public Result FinalizeImportWithoutSwap() public Result FinalizeImportWithoutSwap()
{ {
Result rc = _baseInterface.Get.FinalizeImportWithoutSwap(); Result res = _baseInterface.Get.FinalizeImportWithoutSwap();
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
public Result CancelImport() public Result CancelImport()
{ {
Result rc = _baseInterface.Get.CancelImport(); Result res = _baseInterface.Get.CancelImport();
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -380,18 +380,18 @@ public class SaveDataImporterVersion2 : ISaveDataDivisionImporter
{ {
UnsafeHelpers.SkipParamInit(out outContext); UnsafeHelpers.SkipParamInit(out outContext);
Result rc = _baseInterface.Get.GetImportContext(OutBuffer.FromStruct(ref outContext)); Result res = _baseInterface.Get.GetImportContext(OutBuffer.FromStruct(ref outContext));
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
public Result SuspendImport() public Result SuspendImport()
{ {
Result rc = _baseInterface.Get.SuspendImport(); Result res = _baseInterface.Get.SuspendImport();
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -400,9 +400,9 @@ public class SaveDataImporterVersion2 : ISaveDataDivisionImporter
{ {
using var iteratorObject = new SharedRef<FsSrv.Sf.ISaveDataChunkIterator>(); using var iteratorObject = new SharedRef<FsSrv.Sf.ISaveDataChunkIterator>();
Result rc = _baseInterface.Get.OpenSaveDataDiffChunkIterator(ref iteratorObject.Ref()); Result res = _baseInterface.Get.OpenSaveDataDiffChunkIterator(ref iteratorObject.Ref());
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outIterator.Reset(new SaveDataChunkIterator(_fsClient, ref iteratorObject.Ref())); outIterator.Reset(new SaveDataChunkIterator(_fsClient, ref iteratorObject.Ref()));
return Result.Success; return Result.Success;
@ -412,9 +412,9 @@ public class SaveDataImporterVersion2 : ISaveDataDivisionImporter
{ {
using var importerObject = new SharedRef<FsSrv.Sf.ISaveDataChunkImporter>(); using var importerObject = new SharedRef<FsSrv.Sf.ISaveDataChunkImporter>();
Result rc = _baseInterface.Get.OpenSaveDataChunkImporter(ref importerObject.Ref(), chunkId); Result res = _baseInterface.Get.OpenSaveDataChunkImporter(ref importerObject.Ref(), chunkId);
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outImporter.Reset(new SaveDataChunkImporter(_fsClient, ref importerObject.Ref())); outImporter.Reset(new SaveDataChunkImporter(_fsClient, ref importerObject.Ref()));
return Result.Success; return Result.Success;
@ -424,9 +424,9 @@ public class SaveDataImporterVersion2 : ISaveDataDivisionImporter
{ {
UnsafeHelpers.SkipParamInit(out outInitialDataAad); UnsafeHelpers.SkipParamInit(out outInitialDataAad);
Result rc = _baseInterface.Get.GetImportInitialDataAad(out InitialDataAad initialDataAad); Result res = _baseInterface.Get.GetImportInitialDataAad(out InitialDataAad initialDataAad);
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outInitialDataAad = initialDataAad; outInitialDataAad = initialDataAad;
return Result.Success; return Result.Success;
@ -437,9 +437,9 @@ public class SaveDataImporterVersion2 : ISaveDataDivisionImporter
UnsafeHelpers.SkipParamInit(out outCommitId); UnsafeHelpers.SkipParamInit(out outCommitId);
Unsafe.SkipInit(out SaveDataExtraData extraData); Unsafe.SkipInit(out SaveDataExtraData extraData);
Result rc = _baseInterface.Get.ReadSaveDataExtraData(OutBuffer.FromStruct(ref extraData)); Result res = _baseInterface.Get.ReadSaveDataExtraData(OutBuffer.FromStruct(ref extraData));
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outCommitId = extraData.CommitId; outCommitId = extraData.CommitId;
return Result.Success; return Result.Success;
@ -450,9 +450,9 @@ public class SaveDataImporterVersion2 : ISaveDataDivisionImporter
UnsafeHelpers.SkipParamInit(out outTimeStamp); UnsafeHelpers.SkipParamInit(out outTimeStamp);
Unsafe.SkipInit(out SaveDataExtraData extraData); Unsafe.SkipInit(out SaveDataExtraData extraData);
Result rc = _baseInterface.Get.ReadSaveDataExtraData(OutBuffer.FromStruct(ref extraData)); Result res = _baseInterface.Get.ReadSaveDataExtraData(OutBuffer.FromStruct(ref extraData));
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outTimeStamp = new PosixTime(extraData.TimeStamp); outTimeStamp = new PosixTime(extraData.TimeStamp);
return Result.Success; return Result.Success;
@ -460,9 +460,9 @@ public class SaveDataImporterVersion2 : ISaveDataDivisionImporter
public Result GetReportInfo(out ImportReportInfo outReportInfo) public Result GetReportInfo(out ImportReportInfo outReportInfo)
{ {
Result rc = _baseInterface.Get.GetReportInfo(out outReportInfo); Result res = _baseInterface.Get.GetReportInfo(out outReportInfo);
_fsClient.Impl.AbortIfNeeded(rc); _fsClient.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }

View File

@ -45,9 +45,9 @@ namespace LibHac.Fs
{ {
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.OpenSaveDataTransferManagerVersion2(ref _baseInterface); Result res = fileSystemProxy.Get.OpenSaveDataTransferManagerVersion2(ref _baseInterface);
fs.Impl.LogResultErrorMessage(rc); fs.Impl.LogResultErrorMessage(res);
Abort.DoAbortUnless(rc.IsSuccess()); Abort.DoAbortUnless(res.IsSuccess());
_fsClient = fs; _fsClient = fs;
} }
@ -61,18 +61,18 @@ namespace LibHac.Fs
{ {
UnsafeHelpers.SkipParamInit(out outChallenge); UnsafeHelpers.SkipParamInit(out outChallenge);
Result rc = _baseInterface.Get.GetChallenge(OutBuffer.FromStruct(ref outChallenge)); Result res = _baseInterface.Get.GetChallenge(OutBuffer.FromStruct(ref outChallenge));
_fsClient.Impl.LogResultErrorMessage(rc); _fsClient.Impl.LogResultErrorMessage(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
public Result SetKeySeedPackage(in KeySeedPackage keySeedPackage) public Result SetKeySeedPackage(in KeySeedPackage keySeedPackage)
{ {
Result rc = _baseInterface.Get.SetKeySeedPackage(InBuffer.FromStruct(in keySeedPackage)); Result res = _baseInterface.Get.SetKeySeedPackage(InBuffer.FromStruct(in keySeedPackage));
_fsClient.Impl.LogResultErrorMessage(rc); _fsClient.Impl.LogResultErrorMessage(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -82,9 +82,9 @@ namespace LibHac.Fs
{ {
using var exporterInterface = new SharedRef<FsSrv.Sf.ISaveDataDivisionExporter>(); using var exporterInterface = new SharedRef<FsSrv.Sf.ISaveDataDivisionExporter>();
Result rc = _baseInterface.Get.OpenSaveDataExporter(ref exporterInterface.Ref(), spaceId, saveDataId); Result res = _baseInterface.Get.OpenSaveDataExporter(ref exporterInterface.Ref(), spaceId, saveDataId);
_fsClient.Impl.LogResultErrorMessage(rc); _fsClient.Impl.LogResultErrorMessage(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outExporter.Reset(new SaveDataExporterVersion2(_fsClient, ref exporterInterface.Ref())); outExporter.Reset(new SaveDataExporterVersion2(_fsClient, ref exporterInterface.Ref()));
return Result.Success; return Result.Success;
@ -95,11 +95,11 @@ namespace LibHac.Fs
{ {
using var exporterInterface = new SharedRef<FsSrv.Sf.ISaveDataDivisionExporter>(); using var exporterInterface = new SharedRef<FsSrv.Sf.ISaveDataDivisionExporter>();
Result rc = _baseInterface.Get.OpenSaveDataExporterForDiffExport(ref exporterInterface.Ref(), Result res = _baseInterface.Get.OpenSaveDataExporterForDiffExport(ref exporterInterface.Ref(),
InBuffer.FromStruct(in initialData), spaceId, saveDataId); InBuffer.FromStruct(in initialData), spaceId, saveDataId);
_fsClient.Impl.LogResultErrorMessage(rc); _fsClient.Impl.LogResultErrorMessage(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outExporter.Reset(new SaveDataExporterVersion2(_fsClient, ref exporterInterface.Ref())); outExporter.Reset(new SaveDataExporterVersion2(_fsClient, ref exporterInterface.Ref()));
return Result.Success; return Result.Success;
@ -110,11 +110,11 @@ namespace LibHac.Fs
{ {
using var exporterInterface = new SharedRef<FsSrv.Sf.ISaveDataDivisionExporter>(); using var exporterInterface = new SharedRef<FsSrv.Sf.ISaveDataDivisionExporter>();
Result rc = _baseInterface.Get.OpenSaveDataExporterByContext(ref exporterInterface.Ref(), Result res = _baseInterface.Get.OpenSaveDataExporterByContext(ref exporterInterface.Ref(),
InBuffer.FromStruct(in exportContext)); InBuffer.FromStruct(in exportContext));
_fsClient.Impl.LogResultErrorMessage(rc); _fsClient.Impl.LogResultErrorMessage(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outExporter.Reset(new SaveDataExporterVersion2(_fsClient, ref exporterInterface.Ref())); outExporter.Reset(new SaveDataExporterVersion2(_fsClient, ref exporterInterface.Ref()));
return Result.Success; return Result.Success;
@ -125,11 +125,11 @@ namespace LibHac.Fs
{ {
using var importerInterface = new SharedRef<FsSrv.Sf.ISaveDataDivisionImporter>(); using var importerInterface = new SharedRef<FsSrv.Sf.ISaveDataDivisionImporter>();
Result rc = _baseInterface.Get.OpenSaveDataImporterDeprecated(ref importerInterface.Ref(), Result res = _baseInterface.Get.OpenSaveDataImporterDeprecated(ref importerInterface.Ref(),
InBuffer.FromStruct(in initialData), in userId, spaceId); InBuffer.FromStruct(in initialData), in userId, spaceId);
_fsClient.Impl.LogResultErrorMessage(rc); _fsClient.Impl.LogResultErrorMessage(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outImporter.Reset(new SaveDataImporterVersion2(_fsClient, ref importerInterface.Ref())); outImporter.Reset(new SaveDataImporterVersion2(_fsClient, ref importerInterface.Ref()));
return Result.Success; return Result.Success;
@ -140,11 +140,11 @@ namespace LibHac.Fs
{ {
using var importerInterface = new SharedRef<FsSrv.Sf.ISaveDataDivisionImporter>(); using var importerInterface = new SharedRef<FsSrv.Sf.ISaveDataDivisionImporter>();
Result rc = _baseInterface.Get.OpenSaveDataImporterForDiffImport(ref importerInterface.Ref(), Result res = _baseInterface.Get.OpenSaveDataImporterForDiffImport(ref importerInterface.Ref(),
InBuffer.FromStruct(in initialData), spaceId, saveDataId); InBuffer.FromStruct(in initialData), spaceId, saveDataId);
_fsClient.Impl.LogResultErrorMessage(rc); _fsClient.Impl.LogResultErrorMessage(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outImporter.Reset(new SaveDataImporterVersion2(_fsClient, ref importerInterface.Ref())); outImporter.Reset(new SaveDataImporterVersion2(_fsClient, ref importerInterface.Ref()));
return Result.Success; return Result.Success;
@ -155,11 +155,11 @@ namespace LibHac.Fs
{ {
using var importerInterface = new SharedRef<FsSrv.Sf.ISaveDataDivisionImporter>(); using var importerInterface = new SharedRef<FsSrv.Sf.ISaveDataDivisionImporter>();
Result rc = _baseInterface.Get.OpenSaveDataImporterForDuplicateDiffImport(ref importerInterface.Ref(), Result res = _baseInterface.Get.OpenSaveDataImporterForDuplicateDiffImport(ref importerInterface.Ref(),
InBuffer.FromStruct(in initialData), spaceId, saveDataId); InBuffer.FromStruct(in initialData), spaceId, saveDataId);
_fsClient.Impl.LogResultErrorMessage(rc); _fsClient.Impl.LogResultErrorMessage(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outImporter.Reset(new SaveDataImporterVersion2(_fsClient, ref importerInterface.Ref())); outImporter.Reset(new SaveDataImporterVersion2(_fsClient, ref importerInterface.Ref()));
return Result.Success; return Result.Success;
@ -170,11 +170,11 @@ namespace LibHac.Fs
{ {
using var importerInterface = new SharedRef<FsSrv.Sf.ISaveDataDivisionImporter>(); using var importerInterface = new SharedRef<FsSrv.Sf.ISaveDataDivisionImporter>();
Result rc = _baseInterface.Get.OpenSaveDataImporter(ref importerInterface.Ref(), Result res = _baseInterface.Get.OpenSaveDataImporter(ref importerInterface.Ref(),
InBuffer.FromStruct(in initialData), in userId, spaceId, useSwap); InBuffer.FromStruct(in initialData), in userId, spaceId, useSwap);
_fsClient.Impl.LogResultErrorMessage(rc); _fsClient.Impl.LogResultErrorMessage(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outImporter.Reset(new SaveDataImporterVersion2(_fsClient, ref importerInterface.Ref())); outImporter.Reset(new SaveDataImporterVersion2(_fsClient, ref importerInterface.Ref()));
return Result.Success; return Result.Success;
@ -191,11 +191,11 @@ namespace LibHac.Fs
{ {
using var importerInterface = new SharedRef<FsSrv.Sf.ISaveDataDivisionImporter>(); using var importerInterface = new SharedRef<FsSrv.Sf.ISaveDataDivisionImporter>();
Result rc = _baseInterface.Get.OpenSaveDataImporterByContext(ref importerInterface.Ref(), Result res = _baseInterface.Get.OpenSaveDataImporterByContext(ref importerInterface.Ref(),
InBuffer.FromStruct(in importContext)); InBuffer.FromStruct(in importContext));
_fsClient.Impl.LogResultErrorMessage(rc); _fsClient.Impl.LogResultErrorMessage(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outImporter.Reset(new SaveDataImporterVersion2(_fsClient, ref importerInterface.Ref())); outImporter.Reset(new SaveDataImporterVersion2(_fsClient, ref importerInterface.Ref()));
return Result.Success; return Result.Success;
@ -203,18 +203,18 @@ namespace LibHac.Fs
public static SaveDataTag MakeUserAccountSaveDataTag(Ncm.ApplicationId applicationId, in UserId userId) public static SaveDataTag MakeUserAccountSaveDataTag(Ncm.ApplicationId applicationId, in UserId userId)
{ {
Result rc = SaveDataAttribute.Make(out SaveDataAttribute attribute, applicationId, SaveDataType.Account, Result res = SaveDataAttribute.Make(out SaveDataAttribute attribute, applicationId, SaveDataType.Account,
userId, InvalidSystemSaveDataId, index: 0, SaveDataRank.Primary); userId, InvalidSystemSaveDataId, index: 0, SaveDataRank.Primary);
Abort.DoAbortUnless(rc.IsSuccess()); Abort.DoAbortUnless(res.IsSuccess());
return Unsafe.As<SaveDataAttribute, SaveDataTag>(ref attribute); return Unsafe.As<SaveDataAttribute, SaveDataTag>(ref attribute);
} }
public static SaveDataTag MakeDeviceSaveDataTag(Ncm.ApplicationId applicationId) public static SaveDataTag MakeDeviceSaveDataTag(Ncm.ApplicationId applicationId)
{ {
Result rc = SaveDataAttribute.Make(out SaveDataAttribute attribute, applicationId, SaveDataType.Device, Result res = SaveDataAttribute.Make(out SaveDataAttribute attribute, applicationId, SaveDataType.Device,
InvalidUserId, InvalidSystemSaveDataId, index: 0, SaveDataRank.Primary); InvalidUserId, InvalidSystemSaveDataId, index: 0, SaveDataRank.Primary);
Abort.DoAbortUnless(rc.IsSuccess()); Abort.DoAbortUnless(res.IsSuccess());
return Unsafe.As<SaveDataAttribute, SaveDataTag>(ref attribute); return Unsafe.As<SaveDataAttribute, SaveDataTag>(ref attribute);
} }
@ -224,20 +224,20 @@ namespace LibHac.Fs
ref readonly SaveDataAttribute attribute = ref readonly SaveDataAttribute attribute =
ref Unsafe.As<SaveDataTag, SaveDataAttribute>(ref Unsafe.AsRef(in tag)); ref Unsafe.As<SaveDataTag, SaveDataAttribute>(ref Unsafe.AsRef(in tag));
Result rc = _baseInterface.Get.CancelSuspendingImportByAttribute(in attribute); Result res = _baseInterface.Get.CancelSuspendingImportByAttribute(in attribute);
_fsClient.Impl.LogResultErrorMessage(rc); _fsClient.Impl.LogResultErrorMessage(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
public Result CancelSuspendingImport(Ncm.ApplicationId applicationId, in UserId userId) public Result CancelSuspendingImport(Ncm.ApplicationId applicationId, in UserId userId)
{ {
Result rc = _baseInterface.Get.CancelSuspendingImport(applicationId, in userId); Result res = _baseInterface.Get.CancelSuspendingImport(applicationId, in userId);
_fsClient.Impl.LogResultErrorMessage(rc); _fsClient.Impl.LogResultErrorMessage(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -249,10 +249,10 @@ namespace LibHac.Fs
ref readonly SaveDataAttribute attribute = ref readonly SaveDataAttribute attribute =
ref Unsafe.As<SaveDataTag, SaveDataAttribute>(ref Unsafe.AsRef(in tag)); ref Unsafe.As<SaveDataTag, SaveDataAttribute>(ref Unsafe.AsRef(in tag));
Result rc = _baseInterface.Get.SwapSecondary(in attribute, doSwap, commitId); Result res = _baseInterface.Get.SwapSecondary(in attribute, doSwap, commitId);
_fsClient.Impl.LogResultErrorMessage(rc); _fsClient.Impl.LogResultErrorMessage(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -294,8 +294,8 @@ namespace LibHac.Fs.Shim
using var prohibiter = new SharedRef<ISaveDataTransferProhibiter>(); using var prohibiter = new SharedRef<ISaveDataTransferProhibiter>();
// Todo: Uncomment once opening transfer prohibiters is implemented // Todo: Uncomment once opening transfer prohibiters is implemented
// Result rc = fileSystemProxy.Get.OpenSaveDataTransferProhibiter(ref prohibiter.Ref(), applicationId); // Result res = fileSystemProxy.Get.OpenSaveDataTransferProhibiter(ref prohibiter.Ref(), applicationId);
// if (rc.IsFailure()) return rc.Miss(); // if (res.IsFailure()) return res.Miss();
outProhibiter.Reset(new SaveDataTransferProhibiterForCloudBackUp(ref prohibiter.Ref())); outProhibiter.Reset(new SaveDataTransferProhibiterForCloudBackUp(ref prohibiter.Ref()));
@ -305,9 +305,9 @@ namespace LibHac.Fs.Shim
public static Result OpenSaveDataTransferProhibiterForCloudBackUp(this FileSystemClient fs, public static Result OpenSaveDataTransferProhibiterForCloudBackUp(this FileSystemClient fs,
ref UniqueRef<SaveDataTransferProhibiterForCloudBackUp> outProhibiter, Ncm.ApplicationId applicationId) ref UniqueRef<SaveDataTransferProhibiterForCloudBackUp> outProhibiter, Ncm.ApplicationId applicationId)
{ {
Result rc = fs.Impl.OpenSaveDataTransferProhibiterForCloudBackUp(ref outProhibiter, applicationId); Result res = fs.Impl.OpenSaveDataTransferProhibiterForCloudBackUp(ref outProhibiter, applicationId);
fs.Impl.LogResultErrorMessage(rc); fs.Impl.LogResultErrorMessage(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -318,11 +318,11 @@ namespace LibHac.Fs.Shim
{ {
for (int i = 0; i < applicationIds.Length; i++) for (int i = 0; i < applicationIds.Length; i++)
{ {
Result rc = fs.Impl.OpenSaveDataTransferProhibiterForCloudBackUp(ref outProhibiters[i], Result res = fs.Impl.OpenSaveDataTransferProhibiterForCloudBackUp(ref outProhibiters[i],
applicationIds[i]); applicationIds[i]);
fs.Impl.LogResultErrorMessage(rc); fs.Impl.LogResultErrorMessage(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
} }
return Result.Success; return Result.Success;
@ -335,11 +335,11 @@ namespace LibHac.Fs.Shim
ulong tempAppId = 0; ulong tempAppId = 0;
var programId = new Ncm.ProgramId(applicationId.Value + (uint)programIndex); var programId = new Ncm.ProgramId(applicationId.Value + (uint)programIndex);
Result rc = fileSystemProxy.Get.ListAccessibleSaveDataOwnerId(out outCount, Result res = fileSystemProxy.Get.ListAccessibleSaveDataOwnerId(out outCount,
OutBuffer.FromStruct(ref tempAppId), programId, startIndex: 0, bufferIdCount: 0); OutBuffer.FromStruct(ref tempAppId), programId, startIndex: 0, bufferIdCount: 0);
fs.Impl.LogResultErrorMessage(rc); fs.Impl.LogResultErrorMessage(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -351,15 +351,15 @@ namespace LibHac.Fs.Shim
using var iterator = new UniqueRef<SaveDataIterator>(); using var iterator = new UniqueRef<SaveDataIterator>();
// We want to iterate every save with a Secondary rank // We want to iterate every save with a Secondary rank
Result rc = SaveDataFilter.Make(out SaveDataFilter filter, programId: default, saveType: default, Result res = SaveDataFilter.Make(out SaveDataFilter filter, programId: default, saveType: default,
userId: default, saveDataId: default, index: default, SaveDataRank.Secondary); userId: default, saveDataId: default, index: default, SaveDataRank.Secondary);
fs.Impl.LogResultErrorMessage(rc); fs.Impl.LogResultErrorMessage(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = fs.Impl.OpenSaveDataIterator(ref iterator.Ref(), SaveDataSpaceId.User, in filter); res = fs.Impl.OpenSaveDataIterator(ref iterator.Ref(), SaveDataSpaceId.User, in filter);
fs.Impl.LogResultErrorMessage(rc); fs.Impl.LogResultErrorMessage(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
long workSize = 0; long workSize = 0;
@ -367,11 +367,11 @@ namespace LibHac.Fs.Shim
{ {
Unsafe.SkipInit(out SaveDataInfo info); Unsafe.SkipInit(out SaveDataInfo info);
rc = fs.Impl.ReadSaveDataIteratorSaveDataInfo(out long count, SpanHelpers.AsSpan(ref info), res = fs.Impl.ReadSaveDataIteratorSaveDataInfo(out long count, SpanHelpers.AsSpan(ref info),
ref iterator.Get); ref iterator.Get);
fs.Impl.LogResultErrorMessage(rc); fs.Impl.LogResultErrorMessage(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
// Break once we've iterated all saves // Break once we've iterated all saves
if (count == 0) if (count == 0)

View File

@ -35,16 +35,16 @@ public static class SdCard
for (int i = 0; i < maxRetries; i++) for (int i = 0; i < maxRetries; i++)
{ {
Result rc = fileSystemProxy.Get.OpenSdCardFileSystem(ref outFileSystem); Result res = fileSystemProxy.Get.OpenSdCardFileSystem(ref outFileSystem);
if (rc.IsSuccess()) if (res.IsSuccess())
break; break;
if (!ResultFs.StorageDeviceNotReady.Includes(rc)) if (!ResultFs.StorageDeviceNotReady.Includes(res))
return rc; return res;
if (i == maxRetries - 1) if (i == maxRetries - 1)
return rc; return res;
fs.Hos.Os.SleepThread(TimeSpan.FromMilliSeconds(retryInterval)); fs.Hos.Os.SleepThread(TimeSpan.FromMilliSeconds(retryInterval));
} }
@ -67,29 +67,29 @@ public static class SdCard
public static Result MountSdCard(this FileSystemClient fs, U8Span mountName) public static Result MountSdCard(this FileSystemClient fs, U8Span mountName)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x30]; Span<byte> logBuffer = stackalloc byte[0x30];
// Check if the mount name is valid // Check if the mount name is valid
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fs.Impl.CheckMountName(mountName); res = fs.Impl.CheckMountName(mountName);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogName).Append(mountName); sb.Append(LogName).Append(mountName);
logBuffer = sb.Buffer; logBuffer = sb.Buffer;
fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLogUnlessResultSuccess(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = fs.Impl.CheckMountName(mountName); res = fs.Impl.CheckMountName(mountName);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
// Open the SD card file system // Open the SD card file system
using var fileSystem = new SharedRef<IFileSystemSf>(); using var fileSystem = new SharedRef<IFileSystemSf>();
@ -97,34 +97,34 @@ public static class SdCard
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = OpenSdCardFileSystem(fs, ref fileSystem.Ref()); res = OpenSdCardFileSystem(fs, ref fileSystem.Ref());
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLogUnlessResultSuccess(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = OpenSdCardFileSystem(fs, ref fileSystem.Ref()); res = OpenSdCardFileSystem(fs, ref fileSystem.Ref());
} }
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
// Mount the file system // Mount the file system
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = RegisterFileSystem(fs, mountName, ref fileSystem.Ref()); res = RegisterFileSystem(fs, mountName, ref fileSystem.Ref());
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = RegisterFileSystem(fs, mountName, ref fileSystem.Ref()); res = RegisterFileSystem(fs, mountName, ref fileSystem.Ref());
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName); fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
@ -134,29 +134,29 @@ public static class SdCard
public static Result MountSdCardForDebug(this FileSystemClient fs, U8Span mountName) public static Result MountSdCardForDebug(this FileSystemClient fs, U8Span mountName)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x30]; Span<byte> logBuffer = stackalloc byte[0x30];
// Check if the mount name is valid // Check if the mount name is valid
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = fs.Impl.CheckMountName(mountName); res = fs.Impl.CheckMountName(mountName);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true); var sb = new U8StringBuilder(logBuffer, true);
sb.Append(LogName).Append(mountName); sb.Append(LogName).Append(mountName);
logBuffer = sb.Buffer; logBuffer = sb.Buffer;
fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLogUnlessResultSuccess(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = fs.Impl.CheckMountName(mountName); res = fs.Impl.CheckMountName(mountName);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
// Open the SD card file system // Open the SD card file system
using var fileSystem = new SharedRef<IFileSystemSf>(); using var fileSystem = new SharedRef<IFileSystemSf>();
@ -164,34 +164,34 @@ public static class SdCard
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = OpenSdCardFileSystem(fs, ref fileSystem.Ref()); res = OpenSdCardFileSystem(fs, ref fileSystem.Ref());
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLogUnlessResultSuccess(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = OpenSdCardFileSystem(fs, ref fileSystem.Ref()); res = OpenSdCardFileSystem(fs, ref fileSystem.Ref());
} }
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
// Mount the file system // Mount the file system
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = RegisterFileSystem(fs, mountName, ref fileSystem.Ref()); res = RegisterFileSystem(fs, mountName, ref fileSystem.Ref());
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(logBuffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(logBuffer));
} }
else else
{ {
rc = RegisterFileSystem(fs, mountName, ref fileSystem.Ref()); res = RegisterFileSystem(fs, mountName, ref fileSystem.Ref());
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.Application))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName); fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
@ -204,13 +204,13 @@ public static class SdCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.LogResultErrorMessage(rc); fs.Impl.LogResultErrorMessage(res);
Abort.DoAbortUnless(rc.IsSuccess()); Abort.DoAbortUnless(res.IsSuccess());
rc = CheckIfInserted(fs, ref deviceOperator.Ref(), out bool isInserted); res = CheckIfInserted(fs, ref deviceOperator.Ref(), out bool isInserted);
fs.Impl.LogResultErrorMessage(rc); fs.Impl.LogResultErrorMessage(res);
Abort.DoAbortUnless(rc.IsSuccess()); Abort.DoAbortUnless(res.IsSuccess());
return isInserted; return isInserted;
@ -225,16 +225,16 @@ public static class SdCard
for (int i = 0; i < maxRetries; i++) for (int i = 0; i < maxRetries; i++)
{ {
Result rc = deviceOperator.Get.IsSdCardInserted(out isInserted); Result res = deviceOperator.Get.IsSdCardInserted(out isInserted);
if (rc.IsSuccess()) if (res.IsSuccess())
break; break;
if (!ResultFs.StorageDeviceNotReady.Includes(rc)) if (!ResultFs.StorageDeviceNotReady.Includes(res))
return rc; return res;
if (i == maxRetries - 1) if (i == maxRetries - 1)
return rc; return res;
fs.Hos.Os.SleepThread(TimeSpan.FromMilliSeconds(retryInterval)); fs.Hos.Os.SleepThread(TimeSpan.FromMilliSeconds(retryInterval));
} }
@ -250,13 +250,13 @@ public static class SdCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = GetSpeedMode(fs, in deviceOperator, out long speedMode); res = GetSpeedMode(fs, in deviceOperator, out long speedMode);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outMode = (SdCardSpeedMode)speedMode; outMode = (SdCardSpeedMode)speedMode;
return Result.Success; return Result.Success;
@ -272,16 +272,16 @@ public static class SdCard
for (int i = 0; i < maxRetries; i++) for (int i = 0; i < maxRetries; i++)
{ {
Result rc = deviceOperator.Get.GetSdCardSpeedMode(out outSpeedMode); Result res = deviceOperator.Get.GetSdCardSpeedMode(out outSpeedMode);
if (rc.IsSuccess()) if (res.IsSuccess())
break; break;
if (!ResultFs.StorageDeviceNotReady.Includes(rc)) if (!ResultFs.StorageDeviceNotReady.Includes(res))
return rc; return res;
if (i == maxRetries - 1) if (i == maxRetries - 1)
return rc; return res;
fs.Hos.Os.SleepThread(TimeSpan.FromMilliSeconds(retryInterval)); fs.Hos.Os.SleepThread(TimeSpan.FromMilliSeconds(retryInterval));
} }
@ -295,13 +295,13 @@ public static class SdCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = GetCid(fs, in deviceOperator, outCidBuffer); res = GetCid(fs, in deviceOperator, outCidBuffer);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
@ -313,16 +313,16 @@ public static class SdCard
for (int i = 0; i < maxRetries; i++) for (int i = 0; i < maxRetries; i++)
{ {
Result rc = deviceOperator.Get.GetSdCardCid(new OutBuffer(outCidBuffer), outCidBuffer.Length); Result res = deviceOperator.Get.GetSdCardCid(new OutBuffer(outCidBuffer), outCidBuffer.Length);
if (rc.IsSuccess()) if (res.IsSuccess())
break; break;
if (!ResultFs.StorageDeviceNotReady.Includes(rc)) if (!ResultFs.StorageDeviceNotReady.Includes(res))
return rc; return res;
if (i == maxRetries - 1) if (i == maxRetries - 1)
return rc; return res;
fs.Hos.Os.SleepThread(TimeSpan.FromMilliSeconds(retryInterval)); fs.Hos.Os.SleepThread(TimeSpan.FromMilliSeconds(retryInterval));
} }
@ -338,13 +338,13 @@ public static class SdCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = GetUserAreaSize(fs, in deviceOperator, out outSize); res = GetUserAreaSize(fs, in deviceOperator, out outSize);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
@ -359,16 +359,16 @@ public static class SdCard
for (int i = 0; i < maxRetries; i++) for (int i = 0; i < maxRetries; i++)
{ {
Result rc = deviceOperator.Get.GetSdCardUserAreaSize(out outSize); Result res = deviceOperator.Get.GetSdCardUserAreaSize(out outSize);
if (rc.IsSuccess()) if (res.IsSuccess())
break; break;
if (!ResultFs.StorageDeviceNotReady.Includes(rc)) if (!ResultFs.StorageDeviceNotReady.Includes(res))
return rc; return res;
if (i == maxRetries - 1) if (i == maxRetries - 1)
return rc; return res;
fs.Hos.Os.SleepThread(TimeSpan.FromMilliSeconds(retryInterval)); fs.Hos.Os.SleepThread(TimeSpan.FromMilliSeconds(retryInterval));
} }
@ -384,13 +384,13 @@ public static class SdCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = GetProtectedAreaSize(fs, in deviceOperator, out outSize); res = GetProtectedAreaSize(fs, in deviceOperator, out outSize);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
@ -405,16 +405,16 @@ public static class SdCard
for (int i = 0; i < maxRetries; i++) for (int i = 0; i < maxRetries; i++)
{ {
Result rc = deviceOperator.Get.GetSdCardProtectedAreaSize(out outSize); Result res = deviceOperator.Get.GetSdCardProtectedAreaSize(out outSize);
if (rc.IsSuccess()) if (res.IsSuccess())
break; break;
if (!ResultFs.StorageDeviceNotReady.Includes(rc)) if (!ResultFs.StorageDeviceNotReady.Includes(res))
return rc; return res;
if (i == maxRetries - 1) if (i == maxRetries - 1)
return rc; return res;
fs.Hos.Os.SleepThread(TimeSpan.FromMilliSeconds(retryInterval)); fs.Hos.Os.SleepThread(TimeSpan.FromMilliSeconds(retryInterval));
} }
@ -431,13 +431,13 @@ public static class SdCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = GetErrorInfo(fs, in deviceOperator, out outErrorInfo, out long logSize, logBuffer); res = GetErrorInfo(fs, in deviceOperator, out outErrorInfo, out long logSize, logBuffer);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outLogSize = logSize; outLogSize = logSize;
return Result.Success; return Result.Success;
@ -453,17 +453,17 @@ public static class SdCard
for (int i = 0; i < maxRetries; i++) for (int i = 0; i < maxRetries; i++)
{ {
Result rc = deviceOperator.Get.GetAndClearSdCardErrorInfo(out outErrorInfo, out outLogSize, Result res = deviceOperator.Get.GetAndClearSdCardErrorInfo(out outErrorInfo, out outLogSize,
new OutBuffer(logBuffer), logBuffer.Length); new OutBuffer(logBuffer), logBuffer.Length);
if (rc.IsSuccess()) if (res.IsSuccess())
break; break;
if (!ResultFs.StorageDeviceNotReady.Includes(rc)) if (!ResultFs.StorageDeviceNotReady.Includes(res))
return rc; return res;
if (i == maxRetries - 1) if (i == maxRetries - 1)
return rc; return res;
fs.Hos.Os.SleepThread(TimeSpan.FromMilliSeconds(retryInterval)); fs.Hos.Os.SleepThread(TimeSpan.FromMilliSeconds(retryInterval));
} }
@ -476,9 +476,9 @@ public static class SdCard
{ {
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
Result rc = Format(fs, in fileSystemProxy); Result res = Format(fs, in fileSystemProxy);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
@ -490,16 +490,16 @@ public static class SdCard
for (int i = 0; i < maxRetries; i++) for (int i = 0; i < maxRetries; i++)
{ {
Result rc = fileSystemProxy.Get.FormatSdCardFileSystem(); Result res = fileSystemProxy.Get.FormatSdCardFileSystem();
if (rc.IsSuccess()) if (res.IsSuccess())
break; break;
if (!ResultFs.StorageDeviceNotReady.Includes(rc)) if (!ResultFs.StorageDeviceNotReady.Includes(res))
return rc; return res;
if (i == maxRetries - 1) if (i == maxRetries - 1)
return rc; return res;
fs.Hos.Os.SleepThread(TimeSpan.FromMilliSeconds(retryInterval)); fs.Hos.Os.SleepThread(TimeSpan.FromMilliSeconds(retryInterval));
} }
@ -512,9 +512,9 @@ public static class SdCard
{ {
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.FormatSdCardDryRun(); Result res = fileSystemProxy.Get.FormatSdCardDryRun();
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -523,9 +523,9 @@ public static class SdCard
{ {
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.IsExFatSupported(out bool isSupported); Result res = fileSystemProxy.Get.IsExFatSupported(out bool isSupported);
fs.Impl.LogResultErrorMessage(rc); fs.Impl.LogResultErrorMessage(res);
Abort.DoAbortUnless(rc.IsSuccess()); Abort.DoAbortUnless(res.IsSuccess());
return isSupported; return isSupported;
} }
@ -534,25 +534,25 @@ public static class SdCard
{ {
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.SetSdCardEncryptionSeed(in seed); Result res = fileSystemProxy.Get.SetSdCardEncryptionSeed(in seed);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
return rc; return res;
} }
public static void SetSdCardAccessibility(this FileSystemClient fs, bool isAccessible) public static void SetSdCardAccessibility(this FileSystemClient fs, bool isAccessible)
{ {
Result rc = fs.Impl.SetSdCardAccessibility(isAccessible); Result res = fs.Impl.SetSdCardAccessibility(isAccessible);
fs.Impl.LogResultErrorMessage(rc); fs.Impl.LogResultErrorMessage(res);
Abort.DoAbortUnless(rc.IsSuccess()); Abort.DoAbortUnless(res.IsSuccess());
} }
public static bool IsSdCardAccessible(this FileSystemClient fs) public static bool IsSdCardAccessible(this FileSystemClient fs)
{ {
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.IsSdCardAccessible(out bool isAccessible); Result res = fileSystemProxy.Get.IsSdCardAccessible(out bool isAccessible);
fs.Impl.LogResultErrorMessage(rc); fs.Impl.LogResultErrorMessage(res);
Abort.DoAbortUnless(rc.IsSuccess()); Abort.DoAbortUnless(res.IsSuccess());
return isAccessible; return isAccessible;
} }
@ -569,9 +569,9 @@ public static class SdCard
{ {
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.SimulateDeviceDetectionEvent(SdmmcPort.SdCard, mode, signalEvent); Result res = fileSystemProxy.Get.SimulateDeviceDetectionEvent(SdmmcPort.SdCard, mode, signalEvent);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -580,10 +580,10 @@ public static class SdCard
SimulatingDeviceTargetOperation simulatedOperationType, SimulatingDeviceTargetOperation simulatedOperationType,
SimulatingDeviceAccessFailureEventType simulatedFailureType) SimulatingDeviceAccessFailureEventType simulatedFailureType)
{ {
Result rc = SetSdCardSimulationEvent(fs, simulatedOperationType, simulatedFailureType, Result.Success, Result res = SetSdCardSimulationEvent(fs, simulatedOperationType, simulatedFailureType, Result.Success,
autoClearEvent: false); autoClearEvent: false);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -592,10 +592,10 @@ public static class SdCard
SimulatingDeviceTargetOperation simulatedOperationType, SimulatingDeviceTargetOperation simulatedOperationType,
SimulatingDeviceAccessFailureEventType simulatedFailureType, bool autoClearEvent) SimulatingDeviceAccessFailureEventType simulatedFailureType, bool autoClearEvent)
{ {
Result rc = SetSdCardSimulationEvent(fs, simulatedOperationType, simulatedFailureType, Result.Success, Result res = SetSdCardSimulationEvent(fs, simulatedOperationType, simulatedFailureType, Result.Success,
autoClearEvent); autoClearEvent);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -603,10 +603,10 @@ public static class SdCard
public static Result SetSdCardSimulationEvent(this FileSystemClient fs, public static Result SetSdCardSimulationEvent(this FileSystemClient fs,
SimulatingDeviceTargetOperation simulatedOperationType, Result failureResult, bool autoClearEvent) SimulatingDeviceTargetOperation simulatedOperationType, Result failureResult, bool autoClearEvent)
{ {
Result rc = SetSdCardSimulationEvent(fs, simulatedOperationType, Result res = SetSdCardSimulationEvent(fs, simulatedOperationType,
SimulatingDeviceAccessFailureEventType.AccessFailure, failureResult, autoClearEvent); SimulatingDeviceAccessFailureEventType.AccessFailure, failureResult, autoClearEvent);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -616,13 +616,13 @@ public static class SdCard
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.ClearDeviceSimulationEvent((uint)SdmmcPort.SdCard); res = deviceOperator.Get.ClearDeviceSimulationEvent((uint)SdmmcPort.SdCard);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -631,8 +631,8 @@ public static class SdCard
{ {
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.GetFileSystemProxyServiceObject();
Result rc = fileSystemProxy.Get.SetSdCardAccessibility(isAccessible); Result res = fileSystemProxy.Get.SetSdCardAccessibility(isAccessible);
fs.AbortIfNeeded(rc); fs.AbortIfNeeded(res);
return rc; return res;
} }
} }

View File

@ -17,12 +17,12 @@ public static class SdmmcControl
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.GetSdmmcConnectionStatus(out int speedMode, out int busWidth, (int)port); res = deviceOperator.Get.GetSdmmcConnectionStatus(out int speedMode, out int busWidth, (int)port);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outSpeedMode = (SdmmcSpeedMode)speedMode; outSpeedMode = (SdmmcSpeedMode)speedMode;
outBusWidth = (SdmmcBusWidth)busWidth; outBusWidth = (SdmmcBusWidth)busWidth;
@ -35,13 +35,13 @@ public static class SdmmcControl
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.SuspendSdmmcControl(); res = deviceOperator.Get.SuspendSdmmcControl();
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -51,13 +51,13 @@ public static class SdmmcControl
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.ResumeSdmmcControl(); res = deviceOperator.Get.ResumeSdmmcControl();
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }

View File

@ -14,35 +14,35 @@ public static class SignedSystemPartition
{ {
public static bool IsValidSignedSystemPartitionOnSdCard(this FileSystemClient fs, U8Span path) public static bool IsValidSignedSystemPartitionOnSdCard(this FileSystemClient fs, U8Span path)
{ {
Result rc = fs.Impl.FindFileSystem(out FileSystemAccessor fileSystem, out U8Span _, path); Result res = fs.Impl.FindFileSystem(out FileSystemAccessor fileSystem, out U8Span _, path);
fs.Impl.LogResultErrorMessage(rc); fs.Impl.LogResultErrorMessage(res);
Abort.DoAbortUnlessSuccess(rc); Abort.DoAbortUnlessSuccess(res);
bool isValid = false; bool isValid = false;
rc = Operate(ref isValid, fileSystem); res = Operate(ref isValid, fileSystem);
fs.Impl.LogResultErrorMessage(rc); fs.Impl.LogResultErrorMessage(res);
Abort.DoAbortUnlessSuccess(rc); Abort.DoAbortUnlessSuccess(res);
return isValid; return isValid;
static Result Operate(ref bool isValid, FileSystemAccessor fileSystem) static Result Operate(ref bool isValid, FileSystemAccessor fileSystem)
{ {
Result rc = fileSystem.QueryEntry(SpanHelpers.AsByteSpan(ref isValid), ReadOnlySpan<byte>.Empty, Result res = fileSystem.QueryEntry(SpanHelpers.AsByteSpan(ref isValid), ReadOnlySpan<byte>.Empty,
QueryId.IsSignedSystemPartition, new U8Span(new[] { (byte)'/' })); QueryId.IsSignedSystemPartition, new U8Span(new[] { (byte)'/' }));
if (rc.IsFailure()) if (res.IsFailure())
{ {
// Any IFileSystems other than a signed system partition IFileSystem should // Any IFileSystems other than a signed system partition IFileSystem should
// return an "UnsupportedOperation" result // return an "UnsupportedOperation" result
if (ResultFs.UnsupportedOperation.Includes(rc)) if (ResultFs.UnsupportedOperation.Includes(res))
{ {
rc.Catch(); res.Catch();
isValid = false; isValid = false;
} }
else else
{ {
return rc.Miss(); return res.Miss();
} }
} }

View File

@ -21,13 +21,13 @@ namespace LibHac.Fs.Shim
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.SetSpeedEmulationMode((int)mode); res = deviceOperator.Get.SetSpeedEmulationMode((int)mode);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -39,13 +39,13 @@ namespace LibHac.Fs.Shim
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
using var deviceOperator = new SharedRef<IDeviceOperator>(); using var deviceOperator = new SharedRef<IDeviceOperator>();
Result rc = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref()); Result res = fileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = deviceOperator.Get.GetSpeedEmulationMode(out int mode); res = deviceOperator.Get.GetSpeedEmulationMode(out int mode);
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outMode = (SpeedEmulationMode)mode; outMode = (SpeedEmulationMode)mode;

View File

@ -40,13 +40,13 @@ public static class SystemSaveData
public static Result MountSystemSaveData(this FileSystemClient fs, U8Span mountName, public static Result MountSystemSaveData(this FileSystemClient fs, U8Span mountName,
SaveDataSpaceId spaceId, ulong saveDataId, UserId userId) SaveDataSpaceId spaceId, ulong saveDataId, UserId userId)
{ {
Result rc; Result res;
Span<byte> logBuffer = stackalloc byte[0x90]; Span<byte> logBuffer = stackalloc byte[0x90];
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
{ {
Tick start = fs.Hos.Os.GetSystemTick(); Tick start = fs.Hos.Os.GetSystemTick();
rc = Mount(fs, mountName, spaceId, saveDataId, userId); res = Mount(fs, mountName, spaceId, saveDataId, userId);
Tick end = fs.Hos.Os.GetSystemTick(); Tick end = fs.Hos.Os.GetSystemTick();
var idString = new IdString(); var idString = new IdString();
@ -56,37 +56,37 @@ public static class SystemSaveData
.Append(LogSaveDataId).AppendFormat(saveDataId, 'X') .Append(LogSaveDataId).AppendFormat(saveDataId, 'X')
.Append(LogUserId).AppendFormat(userId.Id.High, 'X', 16).AppendFormat(userId.Id.Low, 'X', 16); .Append(LogUserId).AppendFormat(userId.Id.High, 'X', 16).AppendFormat(userId.Id.Low, 'X', 16);
fs.Impl.OutputAccessLog(rc, start, end, null, new U8Span(sb.Buffer)); fs.Impl.OutputAccessLog(res, start, end, null, new U8Span(sb.Buffer));
} }
else else
{ {
rc = Mount(fs, mountName, spaceId, saveDataId, userId); res = Mount(fs, mountName, spaceId, saveDataId, userId);
} }
fs.Impl.AbortIfNeeded(rc); fs.Impl.AbortIfNeeded(res);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName); fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
return rc; return res;
static Result Mount(FileSystemClient fs, U8Span mountName, SaveDataSpaceId spaceId, ulong saveDataId, static Result Mount(FileSystemClient fs, U8Span mountName, SaveDataSpaceId spaceId, ulong saveDataId,
UserId userId) UserId userId)
{ {
Result rc = fs.Impl.CheckMountName(mountName); Result res = fs.Impl.CheckMountName(mountName);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
rc = SaveDataAttribute.Make(out SaveDataAttribute attribute, InvalidProgramId, res = SaveDataAttribute.Make(out SaveDataAttribute attribute, InvalidProgramId,
SaveDataType.System, userId, saveDataId); SaveDataType.System, userId, saveDataId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var fileSystem = new SharedRef<IFileSystemSf>(); using var fileSystem = new SharedRef<IFileSystemSf>();
rc = fileSystemProxy.Get.OpenSaveDataFileSystemBySystemSaveDataId(ref fileSystem.Ref(), spaceId, in attribute); res = fileSystemProxy.Get.OpenSaveDataFileSystemBySystemSaveDataId(ref fileSystem.Ref(), spaceId, in attribute);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
var fileSystemAdapterRaw = new FileSystemServiceObjectAdapter(ref fileSystem.Ref()); var fileSystemAdapterRaw = new FileSystemServiceObjectAdapter(ref fileSystem.Ref());
using var fileSystemAdapter = new UniqueRef<IFileSystem>(fileSystemAdapterRaw); using var fileSystemAdapter = new UniqueRef<IFileSystem>(fileSystemAdapterRaw);

View File

@ -159,11 +159,11 @@ public class SubStorage : IStorage
if (!IsValid()) return ResultFs.NotInitialized.Log(); if (!IsValid()) return ResultFs.NotInitialized.Log();
if (destination.Length == 0) return Result.Success; if (destination.Length == 0) return Result.Success;
Result rc = CheckAccessRange(offset, destination.Length, _size); Result res = CheckAccessRange(offset, destination.Length, _size);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = BaseStorage.Read(_offset + offset, destination); res = BaseStorage.Read(_offset + offset, destination);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -173,11 +173,11 @@ public class SubStorage : IStorage
if (!IsValid()) return ResultFs.NotInitialized.Log(); if (!IsValid()) return ResultFs.NotInitialized.Log();
if (source.Length == 0) return Result.Success; if (source.Length == 0) return Result.Success;
Result rc = CheckAccessRange(offset, source.Length, _size); Result res = CheckAccessRange(offset, source.Length, _size);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = BaseStorage.Write(_offset + offset, source); res = BaseStorage.Write(_offset + offset, source);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -186,8 +186,8 @@ public class SubStorage : IStorage
{ {
if (!IsValid()) return ResultFs.NotInitialized.Log(); if (!IsValid()) return ResultFs.NotInitialized.Log();
Result rc = BaseStorage.Flush(); Result res = BaseStorage.Flush();
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -197,11 +197,11 @@ public class SubStorage : IStorage
if (!IsValid()) return ResultFs.NotInitialized.Log(); if (!IsValid()) return ResultFs.NotInitialized.Log();
if (!_isResizable) return ResultFs.UnsupportedSetSizeForNotResizableSubStorage.Log(); if (!_isResizable) return ResultFs.UnsupportedSetSizeForNotResizableSubStorage.Log();
Result rc = CheckOffsetAndSize(_offset, size); Result res = CheckOffsetAndSize(_offset, size);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = BaseStorage.GetSize(out long currentSize); res = BaseStorage.GetSize(out long currentSize);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (currentSize != _offset + _size) if (currentSize != _offset + _size)
{ {
@ -209,8 +209,8 @@ public class SubStorage : IStorage
return ResultFs.UnsupportedSetSizeForResizableSubStorage.Log(); return ResultFs.UnsupportedSetSizeForResizableSubStorage.Log();
} }
rc = BaseStorage.SetSize(_offset + size); res = BaseStorage.SetSize(_offset + size);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
_size = size; _size = size;
@ -235,8 +235,8 @@ public class SubStorage : IStorage
{ {
if (size == 0) return Result.Success; if (size == 0) return Result.Success;
Result rc = CheckOffsetAndSize(_offset, size); Result res = CheckOffsetAndSize(_offset, size);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
} }
return BaseStorage.OperateRange(outBuffer, operationId, _offset + offset, size, inBuffer); return BaseStorage.OperateRange(outBuffer, operationId, _offset + offset, size, inBuffer);

View File

@ -31,16 +31,16 @@ public static class Utility
for (int i = 0; i < maxTryCount; i++) for (int i = 0; i < maxTryCount; i++)
{ {
Result rc = listGetter(); Result res = listGetter();
if (rc.IsSuccess()) if (res.IsSuccess())
return rc; return res;
// Try again if any save data were added or removed while getting the list // Try again if any save data were added or removed while getting the list
if (!ResultFs.InvalidHandle.Includes(rc)) if (!ResultFs.InvalidHandle.Includes(res))
return rc.Miss(); return res.Miss();
lastResult = rc; lastResult = res;
hos.Os.SleepThread(TimeSpan.FromMilliSeconds(sleepTime)); hos.Os.SleepThread(TimeSpan.FromMilliSeconds(sleepTime));
sleepTime *= sleepTimeMultiplier; sleepTime *= sleepTimeMultiplier;
} }

View File

@ -112,11 +112,11 @@ public struct ValueSubStorage : IDisposable
if (!IsValid()) return ResultFs.NotInitialized.Log(); if (!IsValid()) return ResultFs.NotInitialized.Log();
if (destination.Length == 0) return Result.Success; if (destination.Length == 0) return Result.Success;
Result rc = IStorage.CheckAccessRange(offset, destination.Length, _size); Result res = IStorage.CheckAccessRange(offset, destination.Length, _size);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = _baseStorage.Read(_offset + offset, destination); res = _baseStorage.Read(_offset + offset, destination);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -126,11 +126,11 @@ public struct ValueSubStorage : IDisposable
if (!IsValid()) return ResultFs.NotInitialized.Log(); if (!IsValid()) return ResultFs.NotInitialized.Log();
if (source.Length == 0) return Result.Success; if (source.Length == 0) return Result.Success;
Result rc = IStorage.CheckAccessRange(offset, source.Length, _size); Result res = IStorage.CheckAccessRange(offset, source.Length, _size);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = _baseStorage.Write(_offset + offset, source); res = _baseStorage.Write(_offset + offset, source);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -139,8 +139,8 @@ public struct ValueSubStorage : IDisposable
{ {
if (!IsValid()) return ResultFs.NotInitialized.Log(); if (!IsValid()) return ResultFs.NotInitialized.Log();
Result rc = _baseStorage.Flush(); Result res = _baseStorage.Flush();
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -150,11 +150,11 @@ public struct ValueSubStorage : IDisposable
if (!IsValid()) return ResultFs.NotInitialized.Log(); if (!IsValid()) return ResultFs.NotInitialized.Log();
if (!_isResizable) return ResultFs.UnsupportedSetSizeForNotResizableSubStorage.Log(); if (!_isResizable) return ResultFs.UnsupportedSetSizeForNotResizableSubStorage.Log();
Result rc = IStorage.CheckOffsetAndSize(_offset, size); Result res = IStorage.CheckOffsetAndSize(_offset, size);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _baseStorage.GetSize(out long currentSize); res = _baseStorage.GetSize(out long currentSize);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (currentSize != _offset + _size) if (currentSize != _offset + _size)
{ {
@ -162,8 +162,8 @@ public struct ValueSubStorage : IDisposable
return ResultFs.UnsupportedSetSizeForResizableSubStorage.Log(); return ResultFs.UnsupportedSetSizeForResizableSubStorage.Log();
} }
rc = _baseStorage.SetSize(_offset + size); res = _baseStorage.SetSize(_offset + size);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
_size = size; _size = size;
@ -193,8 +193,8 @@ public struct ValueSubStorage : IDisposable
{ {
if (size == 0) return Result.Success; if (size == 0) return Result.Success;
Result rc = IStorage.CheckOffsetAndSize(_offset, size); Result res = IStorage.CheckOffsetAndSize(_offset, size);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
} }
return _baseStorage.OperateRange(outBuffer, operationId, _offset + offset, size, inBuffer); return _baseStorage.OperateRange(outBuffer, operationId, _offset + offset, size, inBuffer);

View File

@ -25,16 +25,16 @@ public readonly struct AccessFailureManagementService
public Result OpenAccessFailureDetectionEventNotifier(ref SharedRef<IEventNotifier> outNotifier, public Result OpenAccessFailureDetectionEventNotifier(ref SharedRef<IEventNotifier> outNotifier,
ulong processId, bool notifyOnDeepRetry) ulong processId, bool notifyOnDeepRetry)
{ {
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!programInfo.AccessControl.CanCall(OperationType.OpenAccessFailureDetectionEventNotifier)) if (!programInfo.AccessControl.CanCall(OperationType.OpenAccessFailureDetectionEventNotifier))
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
using var notifier = new UniqueRef<IEventNotifier>(); using var notifier = new UniqueRef<IEventNotifier>();
rc = _serviceImpl.CreateNotifier(ref notifier.Ref(), processId, notifyOnDeepRetry); res = _serviceImpl.CreateNotifier(ref notifier.Ref(), processId, notifyOnDeepRetry);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
outNotifier.Set(ref notifier.Ref()); outNotifier.Set(ref notifier.Ref());
return Result.Success; return Result.Success;
@ -44,8 +44,8 @@ public readonly struct AccessFailureManagementService
{ {
UnsafeHelpers.SkipParamInit(out eventHandle); UnsafeHelpers.SkipParamInit(out eventHandle);
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!programInfo.AccessControl.CanCall(OperationType.GetAccessFailureDetectionEvent)) if (!programInfo.AccessControl.CanCall(OperationType.GetAccessFailureDetectionEvent))
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
@ -60,8 +60,8 @@ public readonly struct AccessFailureManagementService
{ {
UnsafeHelpers.SkipParamInit(out isDetected); UnsafeHelpers.SkipParamInit(out isDetected);
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!programInfo.AccessControl.CanCall(OperationType.IsAccessFailureDetected)) if (!programInfo.AccessControl.CanCall(OperationType.IsAccessFailureDetected))
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
@ -72,8 +72,8 @@ public readonly struct AccessFailureManagementService
public Result ResolveAccessFailure(ulong processId) public Result ResolveAccessFailure(ulong processId)
{ {
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!programInfo.AccessControl.CanCall(OperationType.ResolveAccessFailure)) if (!programInfo.AccessControl.CanCall(OperationType.ResolveAccessFailure))
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
@ -87,8 +87,8 @@ public readonly struct AccessFailureManagementService
public Result AbandonAccessFailure(ulong processId) public Result AbandonAccessFailure(ulong processId)
{ {
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!programInfo.AccessControl.CanCall(OperationType.AbandonAccessFailure)) if (!programInfo.AccessControl.CanCall(OperationType.AbandonAccessFailure))
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();

View File

@ -18,8 +18,8 @@ internal readonly struct AccessLogService
public Result SetAccessLogMode(GlobalAccessLogMode mode) public Result SetAccessLogMode(GlobalAccessLogMode mode)
{ {
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!programInfo.AccessControl.CanCall(OperationType.SetGlobalAccessLogMode)) if (!programInfo.AccessControl.CanCall(OperationType.SetGlobalAccessLogMode))
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
@ -36,8 +36,8 @@ internal readonly struct AccessLogService
public Result OutputAccessLogToSdCard(InBuffer textBuffer) public Result OutputAccessLogToSdCard(InBuffer textBuffer)
{ {
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return _serviceImpl.OutputAccessLogToSdCard(textBuffer.Buffer, programInfo.ProgramIdValue, _processId); return _serviceImpl.OutputAccessLogToSdCard(textBuffer.Buffer, programInfo.ProgramIdValue, _processId);
} }

View File

@ -35,8 +35,8 @@ public readonly struct BaseFileSystemService
private Result CheckCapabilityById(BaseFileSystemId id, ulong processId) private Result CheckCapabilityById(BaseFileSystemId id, ulong processId)
{ {
Result rc = GetProgramInfo(out ProgramInfo programInfo, processId); Result res = GetProgramInfo(out ProgramInfo programInfo, processId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (id == BaseFileSystemId.TemporaryDirectory) if (id == BaseFileSystemId.TemporaryDirectory)
{ {
@ -60,13 +60,13 @@ public readonly struct BaseFileSystemService
public Result OpenBaseFileSystem(ref SharedRef<IFileSystemSf> outFileSystem, BaseFileSystemId fileSystemId) public Result OpenBaseFileSystem(ref SharedRef<IFileSystemSf> outFileSystem, BaseFileSystemId fileSystemId)
{ {
Result rc = CheckCapabilityById(fileSystemId, _processId); Result res = CheckCapabilityById(fileSystemId, _processId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Open the file system // Open the file system
using var fileSystem = new SharedRef<IFileSystem>(); using var fileSystem = new SharedRef<IFileSystem>();
rc = _serviceImpl.OpenBaseFileSystem(ref fileSystem.Ref(), fileSystemId); res = _serviceImpl.OpenBaseFileSystem(ref fileSystem.Ref(), fileSystemId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Create an SF adapter for the file system // Create an SF adapter for the file system
using SharedRef<IFileSystemSf> fileSystemAdapter = using SharedRef<IFileSystemSf> fileSystemAdapter =
@ -79,8 +79,8 @@ public readonly struct BaseFileSystemService
public Result FormatBaseFileSystem(BaseFileSystemId fileSystemId) public Result FormatBaseFileSystem(BaseFileSystemId fileSystemId)
{ {
Result rc = CheckCapabilityById(fileSystemId, _processId); Result res = CheckCapabilityById(fileSystemId, _processId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return _serviceImpl.FormatBaseFileSystem(fileSystemId); return _serviceImpl.FormatBaseFileSystem(fileSystemId);
} }
@ -88,8 +88,8 @@ public readonly struct BaseFileSystemService
public Result OpenBisFileSystem(ref SharedRef<IFileSystemSf> outFileSystem, in FspPath rootPath, public Result OpenBisFileSystem(ref SharedRef<IFileSystemSf> outFileSystem, in FspPath rootPath,
BisPartitionId partitionId) BisPartitionId partitionId)
{ {
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Get the permissions the caller needs // Get the permissions the caller needs
AccessibilityType requiredAccess = partitionId switch AccessibilityType requiredAccess = partitionId switch
@ -117,23 +117,23 @@ public readonly struct BaseFileSystemService
// Normalize the path // Normalize the path
using var pathNormalized = new Path(); using var pathNormalized = new Path();
rc = pathNormalized.Initialize(rootPath.Str); res = pathNormalized.Initialize(rootPath.Str);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
var pathFlags = new PathFlags(); var pathFlags = new PathFlags();
pathFlags.AllowEmptyPath(); pathFlags.AllowEmptyPath();
rc = pathNormalized.Normalize(pathFlags); res = pathNormalized.Normalize(pathFlags);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Open the file system // Open the file system
using var fileSystem = new SharedRef<IFileSystem>(); using var fileSystem = new SharedRef<IFileSystem>();
rc = _serviceImpl.OpenBisFileSystem(ref fileSystem.Ref(), partitionId, false); res = _serviceImpl.OpenBisFileSystem(ref fileSystem.Ref(), partitionId, false);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var subDirFileSystem = new SharedRef<IFileSystem>(); using var subDirFileSystem = new SharedRef<IFileSystem>();
rc = Utility.CreateSubDirectoryFileSystem(ref subDirFileSystem.Ref(), ref fileSystem.Ref(), res = Utility.CreateSubDirectoryFileSystem(ref subDirFileSystem.Ref(), ref fileSystem.Ref(),
in pathNormalized); in pathNormalized);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Add all the file system wrappers // Add all the file system wrappers
using var typeSetFileSystem = using var typeSetFileSystem =
@ -162,8 +162,8 @@ public readonly struct BaseFileSystemService
return ResultFs.InvalidSize.Log(); return ResultFs.InvalidSize.Log();
// Caller must have the FillBis permission // Caller must have the FillBis permission
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!programInfo.AccessControl.CanCall(OperationType.FillBis)) if (!programInfo.AccessControl.CanCall(OperationType.FillBis))
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
@ -174,8 +174,8 @@ public readonly struct BaseFileSystemService
public Result DeleteAllPaddingFiles() public Result DeleteAllPaddingFiles()
{ {
// Caller must have the FillBis permission // Caller must have the FillBis permission
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!programInfo.AccessControl.CanCall(OperationType.FillBis)) if (!programInfo.AccessControl.CanCall(OperationType.FillBis))
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
@ -186,16 +186,16 @@ public readonly struct BaseFileSystemService
public Result OpenGameCardFileSystem(ref SharedRef<IFileSystemSf> outFileSystem, GameCardHandle handle, public Result OpenGameCardFileSystem(ref SharedRef<IFileSystemSf> outFileSystem, GameCardHandle handle,
GameCardPartition partitionId) GameCardPartition partitionId)
{ {
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!programInfo.AccessControl.GetAccessibilityFor(AccessibilityType.MountGameCard).CanRead) if (!programInfo.AccessControl.GetAccessibilityFor(AccessibilityType.MountGameCard).CanRead)
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
using var fileSystem = new SharedRef<IFileSystem>(); using var fileSystem = new SharedRef<IFileSystem>();
rc = _serviceImpl.OpenGameCardFileSystem(ref fileSystem.Ref(), handle, partitionId); res = _serviceImpl.OpenGameCardFileSystem(ref fileSystem.Ref(), handle, partitionId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var asyncFileSystem = using var asyncFileSystem =
new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(ref fileSystem.Ref())); new SharedRef<IFileSystem>(new AsynchronousAccessFileSystem(ref fileSystem.Ref()));
@ -210,8 +210,8 @@ public readonly struct BaseFileSystemService
public Result OpenSdCardFileSystem(ref SharedRef<IFileSystemSf> outFileSystem) public Result OpenSdCardFileSystem(ref SharedRef<IFileSystemSf> outFileSystem)
{ {
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
Accessibility accessibility = programInfo.AccessControl.GetAccessibilityFor(AccessibilityType.MountSdCard); Accessibility accessibility = programInfo.AccessControl.GetAccessibilityFor(AccessibilityType.MountSdCard);
@ -222,8 +222,8 @@ public readonly struct BaseFileSystemService
using var scopedContext = new ScopedStorageLayoutTypeSetter(storageFlag); using var scopedContext = new ScopedStorageLayoutTypeSetter(storageFlag);
using var fileSystem = new SharedRef<IFileSystem>(); using var fileSystem = new SharedRef<IFileSystem>();
rc = _serviceImpl.OpenSdCardProxyFileSystem(ref fileSystem.Ref()); res = _serviceImpl.OpenSdCardProxyFileSystem(ref fileSystem.Ref());
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Add all the file system wrappers // Add all the file system wrappers
using var typeSetFileSystem = using var typeSetFileSystem =
@ -243,8 +243,8 @@ public readonly struct BaseFileSystemService
public Result FormatSdCardFileSystem() public Result FormatSdCardFileSystem()
{ {
// Caller must have the FormatSdCard permission // Caller must have the FormatSdCard permission
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!programInfo.AccessControl.CanCall(OperationType.FormatSdCard)) if (!programInfo.AccessControl.CanCall(OperationType.FormatSdCard))
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
@ -271,8 +271,8 @@ public readonly struct BaseFileSystemService
ImageDirectoryId directoryId) ImageDirectoryId directoryId)
{ {
// Caller must have the MountImageAndVideoStorage permission // Caller must have the MountImageAndVideoStorage permission
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
Accessibility accessibility = Accessibility accessibility =
programInfo.AccessControl.GetAccessibilityFor(AccessibilityType.MountImageAndVideoStorage); programInfo.AccessControl.GetAccessibilityFor(AccessibilityType.MountImageAndVideoStorage);
@ -295,8 +295,8 @@ public readonly struct BaseFileSystemService
} }
using var baseFileSystem = new SharedRef<IFileSystem>(); using var baseFileSystem = new SharedRef<IFileSystem>();
rc = _serviceImpl.OpenBaseFileSystem(ref baseFileSystem.Ref(), fileSystemId); res = _serviceImpl.OpenBaseFileSystem(ref baseFileSystem.Ref(), fileSystemId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using SharedRef<IFileSystemSf> fileSystemAdapter = using SharedRef<IFileSystemSf> fileSystemAdapter =
FileSystemInterfaceAdapter.CreateShared(ref baseFileSystem.Ref(), false); FileSystemInterfaceAdapter.CreateShared(ref baseFileSystem.Ref(), false);
@ -310,15 +310,15 @@ public readonly struct BaseFileSystemService
ulong transferMemorySize) ulong transferMemorySize)
{ {
// Caller must have the OpenBisWiper permission // Caller must have the OpenBisWiper permission
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!programInfo.AccessControl.CanCall(OperationType.OpenBisWiper)) if (!programInfo.AccessControl.CanCall(OperationType.OpenBisWiper))
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
using var bisWiper = new UniqueRef<IWiper>(); using var bisWiper = new UniqueRef<IWiper>();
rc = _serviceImpl.OpenBisWiper(ref bisWiper.Ref(), transferMemoryHandle, transferMemorySize); res = _serviceImpl.OpenBisWiper(ref bisWiper.Ref(), transferMemoryHandle, transferMemorySize);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
outBisWiper.Set(ref bisWiper.Ref()); outBisWiper.Set(ref bisWiper.Ref());

View File

@ -53,8 +53,8 @@ public class BaseFileSystemServiceImpl
public Result OpenBisFileSystem(ref SharedRef<IFileSystem> outFileSystem, BisPartitionId partitionId, public Result OpenBisFileSystem(ref SharedRef<IFileSystem> outFileSystem, BisPartitionId partitionId,
bool caseSensitive) bool caseSensitive)
{ {
Result rc = _config.BisFileSystemCreator.Create(ref outFileSystem, partitionId, caseSensitive); Result res = _config.BisFileSystemCreator.Create(ref outFileSystem, partitionId, caseSensitive);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -73,17 +73,17 @@ public class BaseFileSystemServiceImpl
GameCardPartition partitionId) GameCardPartition partitionId)
{ {
const int maxTries = 2; const int maxTries = 2;
Result rc = Result.Success; Result res = Result.Success;
for (int i = 0; i < maxTries; i++) for (int i = 0; i < maxTries; i++)
{ {
rc = _config.GameCardFileSystemCreator.Create(ref outFileSystem, handle, partitionId); res = _config.GameCardFileSystemCreator.Create(ref outFileSystem, handle, partitionId);
if (!ResultFs.DataCorrupted.Includes(rc)) if (!ResultFs.DataCorrupted.Includes(res))
break; break;
} }
return rc; return res;
} }
public Result OpenSdCardProxyFileSystem(ref SharedRef<IFileSystem> outFileSystem) public Result OpenSdCardProxyFileSystem(ref SharedRef<IFileSystem> outFileSystem)

View File

@ -64,11 +64,11 @@ public readonly struct BaseStorageService
var storageFlag = StorageLayoutType.Bis; var storageFlag = StorageLayoutType.Bis;
using var scopedLayoutType = new ScopedStorageLayoutTypeSetter(storageFlag); using var scopedLayoutType = new ScopedStorageLayoutTypeSetter(storageFlag);
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = GetAccessibilityForOpenBisPartition(out Accessibility accessibility, programInfo, id); res = GetAccessibilityForOpenBisPartition(out Accessibility accessibility, programInfo, id);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
bool canAccess = accessibility.CanRead && accessibility.CanWrite; bool canAccess = accessibility.CanRead && accessibility.CanWrite;
@ -76,8 +76,8 @@ public readonly struct BaseStorageService
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
using var storage = new SharedRef<IStorage>(); using var storage = new SharedRef<IStorage>();
rc = _serviceImpl.OpenBisStorage(ref storage.Ref(), id); res = _serviceImpl.OpenBisStorage(ref storage.Ref(), id);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var typeSetStorage = using var typeSetStorage =
new SharedRef<IStorage>(new StorageLayoutTypeSetStorage(ref storage.Ref(), storageFlag)); new SharedRef<IStorage>(new StorageLayoutTypeSetStorage(ref storage.Ref(), storageFlag));
@ -94,8 +94,8 @@ public readonly struct BaseStorageService
public Result InvalidateBisCache() public Result InvalidateBisCache()
{ {
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!programInfo.AccessControl.CanCall(OperationType.InvalidateBisCache)) if (!programInfo.AccessControl.CanCall(OperationType.InvalidateBisCache))
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
@ -106,8 +106,8 @@ public readonly struct BaseStorageService
public Result OpenGameCardStorage(ref SharedRef<IStorageSf> outStorage, GameCardHandle handle, public Result OpenGameCardStorage(ref SharedRef<IStorageSf> outStorage, GameCardHandle handle,
GameCardPartitionRaw partitionId) GameCardPartitionRaw partitionId)
{ {
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
Accessibility accessibility = Accessibility accessibility =
programInfo.AccessControl.GetAccessibilityFor(AccessibilityType.OpenGameCardStorage); programInfo.AccessControl.GetAccessibilityFor(AccessibilityType.OpenGameCardStorage);
@ -118,8 +118,8 @@ public readonly struct BaseStorageService
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
using var storage = new SharedRef<IStorage>(); using var storage = new SharedRef<IStorage>();
rc = _serviceImpl.OpenGameCardPartition(ref storage.Ref(), handle, partitionId); res = _serviceImpl.OpenGameCardPartition(ref storage.Ref(), handle, partitionId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Todo: Async storage // Todo: Async storage
@ -133,19 +133,19 @@ public readonly struct BaseStorageService
public Result OpenDeviceOperator(ref SharedRef<IDeviceOperator> outDeviceOperator) public Result OpenDeviceOperator(ref SharedRef<IDeviceOperator> outDeviceOperator)
{ {
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = _serviceImpl.OpenDeviceOperator(ref outDeviceOperator, programInfo.AccessControl); res = _serviceImpl.OpenDeviceOperator(ref outDeviceOperator, programInfo.AccessControl);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
public Result OpenSdCardDetectionEventNotifier(ref SharedRef<IEventNotifier> outEventNotifier) public Result OpenSdCardDetectionEventNotifier(ref SharedRef<IEventNotifier> outEventNotifier)
{ {
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!programInfo.AccessControl.CanCall(OperationType.OpenSdCardDetectionEventNotifier)) if (!programInfo.AccessControl.CanCall(OperationType.OpenSdCardDetectionEventNotifier))
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
@ -155,8 +155,8 @@ public readonly struct BaseStorageService
public Result OpenGameCardDetectionEventNotifier(ref SharedRef<IEventNotifier> outEventNotifier) public Result OpenGameCardDetectionEventNotifier(ref SharedRef<IEventNotifier> outEventNotifier)
{ {
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!programInfo.AccessControl.CanCall(OperationType.OpenGameCardDetectionEventNotifier)) if (!programInfo.AccessControl.CanCall(OperationType.OpenGameCardDetectionEventNotifier))
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
@ -166,8 +166,8 @@ public readonly struct BaseStorageService
public Result SimulateDeviceDetectionEvent(SdmmcPort port, SimulatingDeviceDetectionMode mode, bool signalEvent) public Result SimulateDeviceDetectionEvent(SdmmcPort port, SimulatingDeviceDetectionMode mode, bool signalEvent)
{ {
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!programInfo.AccessControl.CanCall(OperationType.SimulateDevice)) if (!programInfo.AccessControl.CanCall(OperationType.SimulateDevice))
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();

View File

@ -37,8 +37,8 @@ public struct DebugConfigurationService
public Result Register(uint key, long value) public Result Register(uint key, long value)
{ {
Result rc = GetProgramInfo(out ProgramInfo programInfo, _processId); Result res = GetProgramInfo(out ProgramInfo programInfo, _processId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
if (!programInfo.AccessControl.CanCall(OperationType.SetDebugConfiguration)) if (!programInfo.AccessControl.CanCall(OperationType.SetDebugConfiguration))
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
@ -49,8 +49,8 @@ public struct DebugConfigurationService
public Result Unregister(uint key) public Result Unregister(uint key)
{ {
Result rc = GetProgramInfo(out ProgramInfo programInfo, _processId); Result res = GetProgramInfo(out ProgramInfo programInfo, _processId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
if (!programInfo.AccessControl.CanCall(OperationType.SetDebugConfiguration)) if (!programInfo.AccessControl.CanCall(OperationType.SetDebugConfiguration))
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();

View File

@ -37,37 +37,37 @@ public class FileSystemProxyCoreImpl
if (storageId == CustomStorageId.System) if (storageId == CustomStorageId.System)
{ {
Result rc = _baseFileSystemService.OpenBisFileSystem(ref fileSystem.Ref(), BisPartitionId.User); Result res = _baseFileSystemService.OpenBisFileSystem(ref fileSystem.Ref(), BisPartitionId.User);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var path = new Path(); using var path = new Path();
rc = PathFunctions.SetUpFixedPathSingleEntry(ref path.Ref(), pathBuffer.Items, res = PathFunctions.SetUpFixedPathSingleEntry(ref path.Ref(), pathBuffer.Items,
CustomStorage.GetCustomStorageDirectoryName(CustomStorageId.System)); CustomStorage.GetCustomStorageDirectoryName(CustomStorageId.System));
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using SharedRef<IFileSystem> tempFs = SharedRef<IFileSystem>.CreateMove(ref fileSystem.Ref()); using SharedRef<IFileSystem> tempFs = SharedRef<IFileSystem>.CreateMove(ref fileSystem.Ref());
rc = Utility.WrapSubDirectory(ref fileSystem.Ref(), ref tempFs.Ref(), in path, createIfMissing: true); res = Utility.WrapSubDirectory(ref fileSystem.Ref(), ref tempFs.Ref(), in path, createIfMissing: true);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
else if (storageId == CustomStorageId.SdCard) else if (storageId == CustomStorageId.SdCard)
{ {
Result rc = _baseFileSystemService.OpenSdCardProxyFileSystem(ref fileSystem.Ref()); Result res = _baseFileSystemService.OpenSdCardProxyFileSystem(ref fileSystem.Ref());
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var path = new Path(); using var path = new Path();
rc = PathFunctions.SetUpFixedPathDoubleEntry(ref path.Ref(), pathBuffer.Items, res = PathFunctions.SetUpFixedPathDoubleEntry(ref path.Ref(), pathBuffer.Items,
CommonPaths.SdCardNintendoRootDirectoryName, CommonPaths.SdCardNintendoRootDirectoryName,
CustomStorage.GetCustomStorageDirectoryName(CustomStorageId.System)); CustomStorage.GetCustomStorageDirectoryName(CustomStorageId.System));
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using SharedRef<IFileSystem> tempFs = SharedRef<IFileSystem>.CreateMove(ref fileSystem.Ref()); using SharedRef<IFileSystem> tempFs = SharedRef<IFileSystem>.CreateMove(ref fileSystem.Ref());
rc = Utility.WrapSubDirectory(ref fileSystem.Ref(), ref tempFs.Ref(), in path, createIfMissing: true); res = Utility.WrapSubDirectory(ref fileSystem.Ref(), ref tempFs.Ref(), in path, createIfMissing: true);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
tempFs.SetByMove(ref fileSystem.Ref()); tempFs.SetByMove(ref fileSystem.Ref());
rc = _fsCreators.EncryptedFileSystemCreator.Create(ref fileSystem.Ref(), ref tempFs.Ref(), res = _fsCreators.EncryptedFileSystemCreator.Create(ref fileSystem.Ref(), ref tempFs.Ref(),
IEncryptedFileSystemCreator.KeyId.CustomStorage, in _sdEncryptionSeed); IEncryptedFileSystemCreator.KeyId.CustomStorage, in _sdEncryptionSeed);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
else else
{ {
@ -81,15 +81,15 @@ public class FileSystemProxyCoreImpl
private Result OpenHostFileSystem(ref SharedRef<IFileSystem> outFileSystem, in Path path) private Result OpenHostFileSystem(ref SharedRef<IFileSystem> outFileSystem, in Path path)
{ {
using var pathHost = new Path(); using var pathHost = new Path();
Result rc = pathHost.Initialize(in path); Result res = pathHost.Initialize(in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _fsCreators.TargetManagerFileSystemCreator.NormalizeCaseOfPath(out bool isSupported, ref pathHost.Ref()); res = _fsCreators.TargetManagerFileSystemCreator.NormalizeCaseOfPath(out bool isSupported, ref pathHost.Ref());
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _fsCreators.TargetManagerFileSystemCreator.Create(ref outFileSystem, in pathHost, isSupported, res = _fsCreators.TargetManagerFileSystemCreator.Create(ref outFileSystem, in pathHost, isSupported,
ensureRootPathExists: false, Result.Success); ensureRootPathExists: false, Result.Success);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -99,14 +99,14 @@ public class FileSystemProxyCoreImpl
{ {
if (!path.IsEmpty() && openCaseSensitive) if (!path.IsEmpty() && openCaseSensitive)
{ {
Result rc = OpenHostFileSystem(ref outFileSystem, in path); Result res = OpenHostFileSystem(ref outFileSystem, in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
else else
{ {
Result rc = _fsCreators.TargetManagerFileSystemCreator.Create(ref outFileSystem, in path, Result res = _fsCreators.TargetManagerFileSystemCreator.Create(ref outFileSystem, in path,
openCaseSensitive, ensureRootPathExists: false, Result.Success); openCaseSensitive, ensureRootPathExists: false, Result.Success);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
return Result.Success; return Result.Success;

View File

@ -156,8 +156,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result OpenFileSystemWithId(ref SharedRef<IFileSystemSf> outFileSystem, in FspPath path, public Result OpenFileSystemWithId(ref SharedRef<IFileSystemSf> outFileSystem, in FspPath path,
ulong id, FileSystemProxyType fsType) ulong id, FileSystemProxyType fsType)
{ {
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService); Result res = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return ncaFsService.OpenFileSystemWithId(ref outFileSystem, in path, id, fsType); return ncaFsService.OpenFileSystemWithId(ref outFileSystem, in path, id, fsType);
} }
@ -165,8 +165,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result OpenFileSystemWithPatch(ref SharedRef<IFileSystemSf> outFileSystem, public Result OpenFileSystemWithPatch(ref SharedRef<IFileSystemSf> outFileSystem,
ProgramId programId, FileSystemProxyType fsType) ProgramId programId, FileSystemProxyType fsType)
{ {
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService); Result res = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return ncaFsService.OpenFileSystemWithPatch(ref outFileSystem, programId, fsType); return ncaFsService.OpenFileSystemWithPatch(ref outFileSystem, programId, fsType);
} }
@ -176,8 +176,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
{ {
UnsafeHelpers.SkipParamInit(out verificationData); UnsafeHelpers.SkipParamInit(out verificationData);
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService); Result res = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return ncaFsService.OpenCodeFileSystem(ref fileSystem, out verificationData, in path, programId); return ncaFsService.OpenCodeFileSystem(ref fileSystem, out verificationData, in path, programId);
} }
@ -202,16 +202,16 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
{ {
UnsafeHelpers.SkipParamInit(out freeSpaceSize); UnsafeHelpers.SkipParamInit(out freeSpaceSize);
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.GetFreeSpaceSizeForSaveData(out freeSpaceSize, spaceId); return saveFsService.GetFreeSpaceSizeForSaveData(out freeSpaceSize, spaceId);
} }
public Result OpenDataFileSystemByCurrentProcess(ref SharedRef<IFileSystemSf> outFileSystem) public Result OpenDataFileSystemByCurrentProcess(ref SharedRef<IFileSystemSf> outFileSystem)
{ {
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService); Result res = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return ncaFsService.OpenDataFileSystemByCurrentProcess(ref outFileSystem); return ncaFsService.OpenDataFileSystemByCurrentProcess(ref outFileSystem);
} }
@ -219,16 +219,16 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result OpenDataFileSystemByProgramId(ref SharedRef<IFileSystemSf> outFileSystem, public Result OpenDataFileSystemByProgramId(ref SharedRef<IFileSystemSf> outFileSystem,
ProgramId programId) ProgramId programId)
{ {
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService); Result res = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return ncaFsService.OpenDataFileSystemByProgramId(ref outFileSystem, programId); return ncaFsService.OpenDataFileSystemByProgramId(ref outFileSystem, programId);
} }
public Result OpenDataStorageByCurrentProcess(ref SharedRef<IStorageSf> outStorage) public Result OpenDataStorageByCurrentProcess(ref SharedRef<IStorageSf> outStorage)
{ {
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService); Result res = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return ncaFsService.OpenDataStorageByCurrentProcess(ref outStorage); return ncaFsService.OpenDataStorageByCurrentProcess(ref outStorage);
} }
@ -236,8 +236,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result OpenDataStorageByProgramId(ref SharedRef<IStorageSf> outStorage, public Result OpenDataStorageByProgramId(ref SharedRef<IStorageSf> outStorage,
ProgramId programId) ProgramId programId)
{ {
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService); Result res = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return ncaFsService.OpenDataStorageByProgramId(ref outStorage, programId); return ncaFsService.OpenDataStorageByProgramId(ref outStorage, programId);
} }
@ -245,8 +245,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result OpenDataStorageByDataId(ref SharedRef<IStorageSf> outStorage, DataId dataId, public Result OpenDataStorageByDataId(ref SharedRef<IStorageSf> outStorage, DataId dataId,
StorageId storageId) StorageId storageId)
{ {
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService); Result res = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return ncaFsService.OpenDataStorageByDataId(ref outStorage, dataId, storageId); return ncaFsService.OpenDataStorageByDataId(ref outStorage, dataId, storageId);
} }
@ -254,8 +254,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result OpenDataStorageByPath(ref SharedRef<IFileSystemSf> outFileSystem, in FspPath path, public Result OpenDataStorageByPath(ref SharedRef<IFileSystemSf> outFileSystem, in FspPath path,
FileSystemProxyType fsType) FileSystemProxyType fsType)
{ {
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService); Result res = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return ncaFsService.OpenDataStorageByPath(ref outFileSystem, in path, fsType); return ncaFsService.OpenDataStorageByPath(ref outFileSystem, in path, fsType);
} }
@ -268,8 +268,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result OpenDataFileSystemWithProgramIndex(ref SharedRef<IFileSystemSf> outFileSystem, public Result OpenDataFileSystemWithProgramIndex(ref SharedRef<IFileSystemSf> outFileSystem,
byte programIndex) byte programIndex)
{ {
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService); Result res = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return ncaFsService.OpenDataFileSystemWithProgramIndex(ref outFileSystem, programIndex); return ncaFsService.OpenDataFileSystemWithProgramIndex(ref outFileSystem, programIndex);
} }
@ -277,32 +277,32 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result OpenDataStorageWithProgramIndex(ref SharedRef<IStorageSf> outStorage, public Result OpenDataStorageWithProgramIndex(ref SharedRef<IStorageSf> outStorage,
byte programIndex) byte programIndex)
{ {
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService); Result res = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return ncaFsService.OpenDataStorageWithProgramIndex(ref outStorage, programIndex); return ncaFsService.OpenDataStorageWithProgramIndex(ref outStorage, programIndex);
} }
public Result RegisterSaveDataFileSystemAtomicDeletion(InBuffer saveDataIds) public Result RegisterSaveDataFileSystemAtomicDeletion(InBuffer saveDataIds)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.RegisterSaveDataFileSystemAtomicDeletion(saveDataIds); return saveFsService.RegisterSaveDataFileSystemAtomicDeletion(saveDataIds);
} }
public Result DeleteSaveDataFileSystem(ulong saveDataId) public Result DeleteSaveDataFileSystem(ulong saveDataId)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.DeleteSaveDataFileSystem(saveDataId); return saveFsService.DeleteSaveDataFileSystem(saveDataId);
} }
public Result DeleteSaveDataFileSystemBySaveDataSpaceId(SaveDataSpaceId spaceId, ulong saveDataId) public Result DeleteSaveDataFileSystemBySaveDataSpaceId(SaveDataSpaceId spaceId, ulong saveDataId)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.DeleteSaveDataFileSystemBySaveDataSpaceId(spaceId, saveDataId); return saveFsService.DeleteSaveDataFileSystemBySaveDataSpaceId(spaceId, saveDataId);
} }
@ -310,16 +310,16 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result DeleteSaveDataFileSystemBySaveDataAttribute(SaveDataSpaceId spaceId, public Result DeleteSaveDataFileSystemBySaveDataAttribute(SaveDataSpaceId spaceId,
in SaveDataAttribute attribute) in SaveDataAttribute attribute)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.DeleteSaveDataFileSystemBySaveDataAttribute(spaceId, in attribute); return saveFsService.DeleteSaveDataFileSystemBySaveDataAttribute(spaceId, in attribute);
} }
public Result UpdateSaveDataMacForDebug(SaveDataSpaceId spaceId, ulong saveDataId) public Result UpdateSaveDataMacForDebug(SaveDataSpaceId spaceId, ulong saveDataId)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.UpdateSaveDataMacForDebug(spaceId, saveDataId); return saveFsService.UpdateSaveDataMacForDebug(spaceId, saveDataId);
} }
@ -327,8 +327,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result CreateSaveDataFileSystem(in SaveDataAttribute attribute, in SaveDataCreationInfo creationInfo, public Result CreateSaveDataFileSystem(in SaveDataAttribute attribute, in SaveDataCreationInfo creationInfo,
in SaveDataMetaInfo metaInfo) in SaveDataMetaInfo metaInfo)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.CreateSaveDataFileSystem(in attribute, in creationInfo, in metaInfo); return saveFsService.CreateSaveDataFileSystem(in attribute, in creationInfo, in metaInfo);
} }
@ -336,8 +336,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result CreateSaveDataFileSystemWithHashSalt(in SaveDataAttribute attribute, public Result CreateSaveDataFileSystemWithHashSalt(in SaveDataAttribute attribute,
in SaveDataCreationInfo creationInfo, in SaveDataMetaInfo metaInfo, in HashSalt hashSalt) in SaveDataCreationInfo creationInfo, in SaveDataMetaInfo metaInfo, in HashSalt hashSalt)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.CreateSaveDataFileSystemWithHashSalt(in attribute, in creationInfo, in metaInfo, return saveFsService.CreateSaveDataFileSystemWithHashSalt(in attribute, in creationInfo, in metaInfo,
in hashSalt); in hashSalt);
@ -346,16 +346,16 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result CreateSaveDataFileSystemBySystemSaveDataId(in SaveDataAttribute attribute, public Result CreateSaveDataFileSystemBySystemSaveDataId(in SaveDataAttribute attribute,
in SaveDataCreationInfo creationInfo) in SaveDataCreationInfo creationInfo)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.CreateSaveDataFileSystemBySystemSaveDataId(in attribute, in creationInfo); return saveFsService.CreateSaveDataFileSystemBySystemSaveDataId(in attribute, in creationInfo);
} }
public Result CreateSaveDataFileSystemWithCreationInfo2(in SaveDataCreationInfo2 creationInfo) public Result CreateSaveDataFileSystemWithCreationInfo2(in SaveDataCreationInfo2 creationInfo)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.CreateSaveDataFileSystemWithCreationInfo2(in creationInfo); return saveFsService.CreateSaveDataFileSystemWithCreationInfo2(in creationInfo);
} }
@ -363,8 +363,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result ExtendSaveDataFileSystem(SaveDataSpaceId spaceId, ulong saveDataId, long dataSize, public Result ExtendSaveDataFileSystem(SaveDataSpaceId spaceId, ulong saveDataId, long dataSize,
long journalSize) long journalSize)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.ExtendSaveDataFileSystem(spaceId, saveDataId, dataSize, journalSize); return saveFsService.ExtendSaveDataFileSystem(spaceId, saveDataId, dataSize, journalSize);
} }
@ -372,8 +372,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result OpenSaveDataFileSystem(ref SharedRef<IFileSystemSf> outFileSystem, SaveDataSpaceId spaceId, public Result OpenSaveDataFileSystem(ref SharedRef<IFileSystemSf> outFileSystem, SaveDataSpaceId spaceId,
in SaveDataAttribute attribute) in SaveDataAttribute attribute)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.OpenSaveDataFileSystem(ref outFileSystem, spaceId, in attribute); return saveFsService.OpenSaveDataFileSystem(ref outFileSystem, spaceId, in attribute);
} }
@ -381,8 +381,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result OpenReadOnlySaveDataFileSystem(ref SharedRef<IFileSystemSf> outFileSystem, public Result OpenReadOnlySaveDataFileSystem(ref SharedRef<IFileSystemSf> outFileSystem,
SaveDataSpaceId spaceId, in SaveDataAttribute attribute) SaveDataSpaceId spaceId, in SaveDataAttribute attribute)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.OpenReadOnlySaveDataFileSystem(ref outFileSystem, spaceId, in attribute); return saveFsService.OpenReadOnlySaveDataFileSystem(ref outFileSystem, spaceId, in attribute);
} }
@ -390,16 +390,16 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result OpenSaveDataFileSystemBySystemSaveDataId(ref SharedRef<IFileSystemSf> outFileSystem, public Result OpenSaveDataFileSystemBySystemSaveDataId(ref SharedRef<IFileSystemSf> outFileSystem,
SaveDataSpaceId spaceId, in SaveDataAttribute attribute) SaveDataSpaceId spaceId, in SaveDataAttribute attribute)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.OpenSaveDataFileSystemBySystemSaveDataId(ref outFileSystem, spaceId, in attribute); return saveFsService.OpenSaveDataFileSystemBySystemSaveDataId(ref outFileSystem, spaceId, in attribute);
} }
public Result ReadSaveDataFileSystemExtraData(OutBuffer extraDataBuffer, ulong saveDataId) public Result ReadSaveDataFileSystemExtraData(OutBuffer extraDataBuffer, ulong saveDataId)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.ReadSaveDataFileSystemExtraData(extraDataBuffer, saveDataId); return saveFsService.ReadSaveDataFileSystemExtraData(extraDataBuffer, saveDataId);
} }
@ -407,8 +407,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result ReadSaveDataFileSystemExtraDataBySaveDataAttribute(OutBuffer extraDataBuffer, public Result ReadSaveDataFileSystemExtraDataBySaveDataAttribute(OutBuffer extraDataBuffer,
SaveDataSpaceId spaceId, in SaveDataAttribute attribute) SaveDataSpaceId spaceId, in SaveDataAttribute attribute)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.ReadSaveDataFileSystemExtraDataBySaveDataAttribute(extraDataBuffer, spaceId, return saveFsService.ReadSaveDataFileSystemExtraDataBySaveDataAttribute(extraDataBuffer, spaceId,
in attribute); in attribute);
@ -417,8 +417,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute(OutBuffer extraDataBuffer, public Result ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute(OutBuffer extraDataBuffer,
SaveDataSpaceId spaceId, in SaveDataAttribute attribute, InBuffer maskBuffer) SaveDataSpaceId spaceId, in SaveDataAttribute attribute, InBuffer maskBuffer)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute(extraDataBuffer, spaceId, return saveFsService.ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute(extraDataBuffer, spaceId,
in attribute, maskBuffer); in attribute, maskBuffer);
@ -427,8 +427,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result ReadSaveDataFileSystemExtraDataBySaveDataSpaceId(OutBuffer extraDataBuffer, public Result ReadSaveDataFileSystemExtraDataBySaveDataSpaceId(OutBuffer extraDataBuffer,
SaveDataSpaceId spaceId, ulong saveDataId) SaveDataSpaceId spaceId, ulong saveDataId)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.ReadSaveDataFileSystemExtraDataBySaveDataSpaceId(extraDataBuffer, spaceId, saveDataId); return saveFsService.ReadSaveDataFileSystemExtraDataBySaveDataSpaceId(extraDataBuffer, spaceId, saveDataId);
} }
@ -436,8 +436,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result WriteSaveDataFileSystemExtraData(ulong saveDataId, SaveDataSpaceId spaceId, public Result WriteSaveDataFileSystemExtraData(ulong saveDataId, SaveDataSpaceId spaceId,
InBuffer extraDataBuffer) InBuffer extraDataBuffer)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.WriteSaveDataFileSystemExtraData(saveDataId, spaceId, extraDataBuffer); return saveFsService.WriteSaveDataFileSystemExtraData(saveDataId, spaceId, extraDataBuffer);
} }
@ -445,8 +445,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result WriteSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute(in SaveDataAttribute attribute, public Result WriteSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute(in SaveDataAttribute attribute,
SaveDataSpaceId spaceId, InBuffer extraDataBuffer, InBuffer maskBuffer) SaveDataSpaceId spaceId, InBuffer extraDataBuffer, InBuffer maskBuffer)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.WriteSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute(in attribute, spaceId, return saveFsService.WriteSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute(in attribute, spaceId,
extraDataBuffer, maskBuffer); extraDataBuffer, maskBuffer);
@ -455,8 +455,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result WriteSaveDataFileSystemExtraDataWithMask(ulong saveDataId, SaveDataSpaceId spaceId, public Result WriteSaveDataFileSystemExtraDataWithMask(ulong saveDataId, SaveDataSpaceId spaceId,
InBuffer extraDataBuffer, InBuffer maskBuffer) InBuffer extraDataBuffer, InBuffer maskBuffer)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.WriteSaveDataFileSystemExtraDataWithMask(saveDataId, spaceId, extraDataBuffer, return saveFsService.WriteSaveDataFileSystemExtraDataWithMask(saveDataId, spaceId, extraDataBuffer,
maskBuffer); maskBuffer);
@ -502,8 +502,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result OpenHostFileSystemWithOption(ref SharedRef<IFileSystemSf> outFileSystem, public Result OpenHostFileSystemWithOption(ref SharedRef<IFileSystemSf> outFileSystem,
in FspPath path, MountHostOption option) in FspPath path, MountHostOption option)
{ {
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
Accessibility accessibility = programInfo.AccessControl.GetAccessibilityFor(AccessibilityType.MountHost); Accessibility accessibility = programInfo.AccessControl.GetAccessibilityFor(AccessibilityType.MountHost);
@ -515,13 +515,13 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
if (path.Str.At(0) == DirectorySeparator && path.Str.At(1) != DirectorySeparator) if (path.Str.At(0) == DirectorySeparator && path.Str.At(1) != DirectorySeparator)
{ {
rc = pathNormalized.Initialize(path.Str.Slice(1)); res = pathNormalized.Initialize(path.Str.Slice(1));
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
else else
{ {
rc = pathNormalized.InitializeWithReplaceUnc(path.Str); res = pathNormalized.InitializeWithReplaceUnc(path.Str);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
var flags = new PathFlags(); var flags = new PathFlags();
@ -529,13 +529,13 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
flags.AllowRelativePath(); flags.AllowRelativePath();
flags.AllowEmptyPath(); flags.AllowEmptyPath();
rc = pathNormalized.Normalize(flags); res = pathNormalized.Normalize(flags);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
bool isCaseSensitive = option.Flags.HasFlag(MountHostOptionFlag.PseudoCaseSensitive); bool isCaseSensitive = option.Flags.HasFlag(MountHostOptionFlag.PseudoCaseSensitive);
rc = _fsProxyCore.OpenHostFileSystem(ref hostFileSystem.Ref(), in pathNormalized, isCaseSensitive); res = _fsProxyCore.OpenHostFileSystem(ref hostFileSystem.Ref(), in pathNormalized, isCaseSensitive);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
var adapterFlags = new PathFlags(); var adapterFlags = new PathFlags();
if (path.Str.At(0) == NullTerminator) if (path.Str.At(0) == NullTerminator)
@ -597,24 +597,24 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result OpenSystemDataUpdateEventNotifier(ref SharedRef<IEventNotifier> outEventNotifier) public Result OpenSystemDataUpdateEventNotifier(ref SharedRef<IEventNotifier> outEventNotifier)
{ {
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService); Result res = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return ncaFsService.OpenSystemDataUpdateEventNotifier(ref outEventNotifier); return ncaFsService.OpenSystemDataUpdateEventNotifier(ref outEventNotifier);
} }
public Result NotifySystemDataUpdateEvent() public Result NotifySystemDataUpdateEvent()
{ {
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService); Result res = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return ncaFsService.NotifySystemDataUpdateEvent(); return ncaFsService.NotifySystemDataUpdateEvent();
} }
public Result OpenSaveDataInfoReader(ref SharedRef<ISaveDataInfoReader> outInfoReader) public Result OpenSaveDataInfoReader(ref SharedRef<ISaveDataInfoReader> outInfoReader)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.OpenSaveDataInfoReader(ref outInfoReader); return saveFsService.OpenSaveDataInfoReader(ref outInfoReader);
} }
@ -622,8 +622,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result OpenSaveDataInfoReaderBySaveDataSpaceId( public Result OpenSaveDataInfoReaderBySaveDataSpaceId(
ref SharedRef<ISaveDataInfoReader> outInfoReader, SaveDataSpaceId spaceId) ref SharedRef<ISaveDataInfoReader> outInfoReader, SaveDataSpaceId spaceId)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.OpenSaveDataInfoReaderBySaveDataSpaceId(ref outInfoReader, spaceId); return saveFsService.OpenSaveDataInfoReaderBySaveDataSpaceId(ref outInfoReader, spaceId);
} }
@ -631,8 +631,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result OpenSaveDataInfoReaderWithFilter(ref SharedRef<ISaveDataInfoReader> outInfoReader, public Result OpenSaveDataInfoReaderWithFilter(ref SharedRef<ISaveDataInfoReader> outInfoReader,
SaveDataSpaceId spaceId, in SaveDataFilter filter) SaveDataSpaceId spaceId, in SaveDataFilter filter)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.OpenSaveDataInfoReaderWithFilter(ref outInfoReader, spaceId, in filter); return saveFsService.OpenSaveDataInfoReaderWithFilter(ref outInfoReader, spaceId, in filter);
} }
@ -642,8 +642,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
{ {
UnsafeHelpers.SkipParamInit(out count); UnsafeHelpers.SkipParamInit(out count);
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.FindSaveDataWithFilter(out count, saveDataInfoBuffer, spaceId, in filter); return saveFsService.FindSaveDataWithFilter(out count, saveDataInfoBuffer, spaceId, in filter);
} }
@ -651,8 +651,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result OpenSaveDataInternalStorageFileSystem(ref SharedRef<IFileSystemSf> outFileSystem, public Result OpenSaveDataInternalStorageFileSystem(ref SharedRef<IFileSystemSf> outFileSystem,
SaveDataSpaceId spaceId, ulong saveDataId) SaveDataSpaceId spaceId, ulong saveDataId)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.OpenSaveDataInternalStorageFileSystem(ref outFileSystem, spaceId, saveDataId); return saveFsService.OpenSaveDataInternalStorageFileSystem(ref outFileSystem, spaceId, saveDataId);
} }
@ -661,8 +661,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
{ {
UnsafeHelpers.SkipParamInit(out size); UnsafeHelpers.SkipParamInit(out size);
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.QuerySaveDataInternalStorageTotalSize(out size, spaceId, saveDataId); return saveFsService.QuerySaveDataInternalStorageTotalSize(out size, spaceId, saveDataId);
} }
@ -671,16 +671,16 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
{ {
UnsafeHelpers.SkipParamInit(out commitId); UnsafeHelpers.SkipParamInit(out commitId);
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.GetSaveDataCommitId(out commitId, spaceId, saveDataId); return saveFsService.GetSaveDataCommitId(out commitId, spaceId, saveDataId);
} }
public Result OpenSaveDataInfoReaderOnlyCacheStorage(ref SharedRef<ISaveDataInfoReader> outInfoReader) public Result OpenSaveDataInfoReaderOnlyCacheStorage(ref SharedRef<ISaveDataInfoReader> outInfoReader)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.OpenSaveDataInfoReaderOnlyCacheStorage(ref outInfoReader); return saveFsService.OpenSaveDataInfoReaderOnlyCacheStorage(ref outInfoReader);
} }
@ -688,16 +688,16 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result OpenSaveDataMetaFile(ref SharedRef<IFileSf> outFile, SaveDataSpaceId spaceId, public Result OpenSaveDataMetaFile(ref SharedRef<IFileSf> outFile, SaveDataSpaceId spaceId,
in SaveDataAttribute attribute, SaveDataMetaType type) in SaveDataAttribute attribute, SaveDataMetaType type)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.OpenSaveDataMetaFile(ref outFile, spaceId, in attribute, type); return saveFsService.OpenSaveDataMetaFile(ref outFile, spaceId, in attribute, type);
} }
public Result DeleteCacheStorage(ushort index) public Result DeleteCacheStorage(ushort index)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.DeleteCacheStorage(index); return saveFsService.DeleteCacheStorage(index);
} }
@ -706,16 +706,16 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
{ {
UnsafeHelpers.SkipParamInit(out dataSize, out journalSize); UnsafeHelpers.SkipParamInit(out dataSize, out journalSize);
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.GetCacheStorageSize(out dataSize, out journalSize, index); return saveFsService.GetCacheStorageSize(out dataSize, out journalSize, index);
} }
public Result OpenSaveDataTransferManager(ref SharedRef<ISaveDataTransferManager> outTransferManager) public Result OpenSaveDataTransferManager(ref SharedRef<ISaveDataTransferManager> outTransferManager)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.OpenSaveDataTransferManager(ref outTransferManager); return saveFsService.OpenSaveDataTransferManager(ref outTransferManager);
} }
@ -723,8 +723,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result OpenSaveDataTransferManagerVersion2( public Result OpenSaveDataTransferManagerVersion2(
ref SharedRef<ISaveDataTransferManagerWithDivision> outTransferManager) ref SharedRef<ISaveDataTransferManagerWithDivision> outTransferManager)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.OpenSaveDataTransferManagerVersion2(ref outTransferManager); return saveFsService.OpenSaveDataTransferManagerVersion2(ref outTransferManager);
} }
@ -732,8 +732,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result OpenSaveDataTransferManagerForSaveDataRepair( public Result OpenSaveDataTransferManagerForSaveDataRepair(
ref SharedRef<ISaveDataTransferManagerForSaveDataRepair> outTransferManager) ref SharedRef<ISaveDataTransferManagerForSaveDataRepair> outTransferManager)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.OpenSaveDataTransferManagerForSaveDataRepair(ref outTransferManager); return saveFsService.OpenSaveDataTransferManagerForSaveDataRepair(ref outTransferManager);
} }
@ -741,8 +741,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result OpenSaveDataTransferManagerForRepair( public Result OpenSaveDataTransferManagerForRepair(
ref SharedRef<ISaveDataTransferManagerForRepair> outTransferManager) ref SharedRef<ISaveDataTransferManagerForRepair> outTransferManager)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.OpenSaveDataTransferManagerForRepair(ref outTransferManager); return saveFsService.OpenSaveDataTransferManagerForRepair(ref outTransferManager);
} }
@ -750,8 +750,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result OpenSaveDataTransferProhibiter(ref SharedRef<ISaveDataTransferProhibiter> outProhibiter, public Result OpenSaveDataTransferProhibiter(ref SharedRef<ISaveDataTransferProhibiter> outProhibiter,
Ncm.ApplicationId applicationId) Ncm.ApplicationId applicationId)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.OpenSaveDataTransferProhibiter(ref outProhibiter, applicationId); return saveFsService.OpenSaveDataTransferProhibiter(ref outProhibiter, applicationId);
} }
@ -761,8 +761,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
{ {
UnsafeHelpers.SkipParamInit(out readCount); UnsafeHelpers.SkipParamInit(out readCount);
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.ListAccessibleSaveDataOwnerId(out readCount, idBuffer, programId, startIndex, return saveFsService.ListAccessibleSaveDataOwnerId(out readCount, idBuffer, programId, startIndex,
bufferIdCount); bufferIdCount);
@ -771,8 +771,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result OpenSaveDataMover(ref SharedRef<ISaveDataMover> outSaveDataMover, SaveDataSpaceId sourceSpaceId, public Result OpenSaveDataMover(ref SharedRef<ISaveDataMover> outSaveDataMover, SaveDataSpaceId sourceSpaceId,
SaveDataSpaceId destinationSpaceId, NativeHandle workBufferHandle, ulong workBufferSize) SaveDataSpaceId destinationSpaceId, NativeHandle workBufferHandle, ulong workBufferSize)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.OpenSaveDataMover(ref outSaveDataMover, sourceSpaceId, destinationSpaceId, return saveFsService.OpenSaveDataMover(ref outSaveDataMover, sourceSpaceId, destinationSpaceId,
workBufferHandle, workBufferSize); workBufferHandle, workBufferSize);
@ -785,16 +785,16 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result SetSaveDataRootPath(in FspPath path) public Result SetSaveDataRootPath(in FspPath path)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.SetSaveDataRootPath(in path); return saveFsService.SetSaveDataRootPath(in path);
} }
public Result UnsetSaveDataRootPath() public Result UnsetSaveDataRootPath()
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.UnsetSaveDataRootPath(); return saveFsService.UnsetSaveDataRootPath();
} }
@ -802,8 +802,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result OpenContentStorageFileSystem(ref SharedRef<IFileSystemSf> outFileSystem, public Result OpenContentStorageFileSystem(ref SharedRef<IFileSystemSf> outFileSystem,
ContentStorageId storageId) ContentStorageId storageId)
{ {
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService); Result res = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return ncaFsService.OpenContentStorageFileSystem(ref outFileSystem, storageId); return ncaFsService.OpenContentStorageFileSystem(ref outFileSystem, storageId);
} }
@ -814,8 +814,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
var storageFlag = StorageLayoutType.NonGameCard; var storageFlag = StorageLayoutType.NonGameCard;
using var scopedContext = new ScopedStorageLayoutTypeSetter(storageFlag); using var scopedContext = new ScopedStorageLayoutTypeSetter(storageFlag);
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
Accessibility accessibility = Accessibility accessibility =
programInfo.AccessControl.GetAccessibilityFor(AccessibilityType.MountCloudBackupWorkStorage); programInfo.AccessControl.GetAccessibilityFor(AccessibilityType.MountCloudBackupWorkStorage);
@ -824,8 +824,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
using var fileSystem = new SharedRef<IFileSystem>(); using var fileSystem = new SharedRef<IFileSystem>();
rc = _fsProxyCore.OpenCloudBackupWorkStorageFileSystem(ref fileSystem.Ref(), storageId); res = _fsProxyCore.OpenCloudBackupWorkStorageFileSystem(ref fileSystem.Ref(), storageId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Add all the wrappers for the file system // Add all the wrappers for the file system
using var typeSetFileSystem = using var typeSetFileSystem =
@ -847,8 +847,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
var storageFlag = StorageLayoutType.NonGameCard; var storageFlag = StorageLayoutType.NonGameCard;
using var scopedContext = new ScopedStorageLayoutTypeSetter(storageFlag); using var scopedContext = new ScopedStorageLayoutTypeSetter(storageFlag);
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
AccessibilityType accessType = storageId > CustomStorageId.SdCard AccessibilityType accessType = storageId > CustomStorageId.SdCard
? AccessibilityType.NotMount ? AccessibilityType.NotMount
@ -860,8 +860,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
using var fileSystem = new SharedRef<IFileSystem>(); using var fileSystem = new SharedRef<IFileSystem>();
rc = _fsProxyCore.OpenCustomStorageFileSystem(ref fileSystem.Ref(), storageId); res = _fsProxyCore.OpenCustomStorageFileSystem(ref fileSystem.Ref(), storageId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Add all the file system wrappers // Add all the file system wrappers
using var typeSetFileSystem = using var typeSetFileSystem =
@ -888,8 +888,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
{ {
UnsafeHelpers.SkipParamInit(out isArchived); UnsafeHelpers.SkipParamInit(out isArchived);
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService); Result res = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return ncaFsService.IsArchivedProgram(out isArchived, processId); return ncaFsService.IsArchivedProgram(out isArchived, processId);
} }
@ -898,8 +898,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
{ {
UnsafeHelpers.SkipParamInit(out totalSize); UnsafeHelpers.SkipParamInit(out totalSize);
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.QuerySaveDataTotalSize(out totalSize, dataSize, journalSize); return saveFsService.QuerySaveDataTotalSize(out totalSize, dataSize, journalSize);
} }
@ -913,8 +913,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
{ {
UnsafeHelpers.SkipParamInit(out rightsId); UnsafeHelpers.SkipParamInit(out rightsId);
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService); Result res = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return ncaFsService.GetRightsId(out rightsId, programId, storageId); return ncaFsService.GetRightsId(out rightsId, programId, storageId);
} }
@ -928,55 +928,55 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
{ {
UnsafeHelpers.SkipParamInit(out rightsId, out keyGeneration); UnsafeHelpers.SkipParamInit(out rightsId, out keyGeneration);
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService); Result res = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return ncaFsService.GetRightsIdAndKeyGenerationByPath(out rightsId, out keyGeneration, in path); return ncaFsService.GetRightsIdAndKeyGenerationByPath(out rightsId, out keyGeneration, in path);
} }
public Result RegisterExternalKey(in RightsId rightsId, in AccessKey externalKey) public Result RegisterExternalKey(in RightsId rightsId, in AccessKey externalKey)
{ {
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService); Result res = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return ncaFsService.RegisterExternalKey(in rightsId, in externalKey); return ncaFsService.RegisterExternalKey(in rightsId, in externalKey);
} }
public Result UnregisterExternalKey(in RightsId rightsId) public Result UnregisterExternalKey(in RightsId rightsId)
{ {
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService); Result res = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return ncaFsService.UnregisterExternalKey(in rightsId); return ncaFsService.UnregisterExternalKey(in rightsId);
} }
public Result UnregisterAllExternalKey() public Result UnregisterAllExternalKey()
{ {
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService); Result res = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return ncaFsService.UnregisterAllExternalKey(); return ncaFsService.UnregisterAllExternalKey();
} }
public Result SetSdCardEncryptionSeed(in EncryptionSeed seed) public Result SetSdCardEncryptionSeed(in EncryptionSeed seed)
{ {
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!programInfo.AccessControl.CanCall(OperationType.SetEncryptionSeed)) if (!programInfo.AccessControl.CanCall(OperationType.SetEncryptionSeed))
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
rc = _fsProxyCore.SetSdCardEncryptionSeed(in seed); res = _fsProxyCore.SetSdCardEncryptionSeed(in seed);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = saveFsService.SetSdCardEncryptionSeed(in seed); res = saveFsService.SetSdCardEncryptionSeed(in seed);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService); res = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return ncaFsService.SetSdCardEncryptionSeed(in seed); return ncaFsService.SetSdCardEncryptionSeed(in seed);
} }
@ -1000,8 +1000,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result VerifySaveDataFileSystemBySaveDataSpaceId(SaveDataSpaceId spaceId, ulong saveDataId, public Result VerifySaveDataFileSystemBySaveDataSpaceId(SaveDataSpaceId spaceId, ulong saveDataId,
OutBuffer readBuffer) OutBuffer readBuffer)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.VerifySaveDataFileSystemBySaveDataSpaceId(spaceId, saveDataId, readBuffer); return saveFsService.VerifySaveDataFileSystemBySaveDataSpaceId(spaceId, saveDataId, readBuffer);
} }
@ -1013,8 +1013,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result CorruptSaveDataFileSystemByOffset(SaveDataSpaceId spaceId, ulong saveDataId, long offset) public Result CorruptSaveDataFileSystemByOffset(SaveDataSpaceId spaceId, ulong saveDataId, long offset)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.CorruptSaveDataFileSystemByOffset(spaceId, saveDataId, offset); return saveFsService.CorruptSaveDataFileSystemByOffset(spaceId, saveDataId, offset);
} }
@ -1022,8 +1022,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result CorruptSaveDataFileSystemBySaveDataSpaceId(SaveDataSpaceId spaceId, ulong saveDataId) public Result CorruptSaveDataFileSystemBySaveDataSpaceId(SaveDataSpaceId spaceId, ulong saveDataId)
{ {
// Corrupt both of the save data headers // Corrupt both of the save data headers
Result rc = CorruptSaveDataFileSystemByOffset(spaceId, saveDataId, 0); Result res = CorruptSaveDataFileSystemByOffset(spaceId, saveDataId, 0);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return CorruptSaveDataFileSystemByOffset(spaceId, saveDataId, 0x4000); return CorruptSaveDataFileSystemByOffset(spaceId, saveDataId, 0x4000);
} }
@ -1085,16 +1085,16 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result RegisterUpdatePartition() public Result RegisterUpdatePartition()
{ {
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService); Result res = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return ncaFsService.RegisterUpdatePartition(); return ncaFsService.RegisterUpdatePartition();
} }
public Result OpenRegisteredUpdatePartition(ref SharedRef<IFileSystemSf> outFileSystem) public Result OpenRegisteredUpdatePartition(ref SharedRef<IFileSystemSf> outFileSystem)
{ {
Result rc = GetNcaFileSystemService(out NcaFileSystemService ncaFsService); Result res = GetNcaFileSystemService(out NcaFileSystemService ncaFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return ncaFsService.OpenRegisteredUpdatePartition(ref outFileSystem); return ncaFsService.OpenRegisteredUpdatePartition(ref outFileSystem);
} }
@ -1111,16 +1111,16 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result OverrideSaveDataTransferTokenSignVerificationKey(InBuffer key) public Result OverrideSaveDataTransferTokenSignVerificationKey(InBuffer key)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.OverrideSaveDataTransferTokenSignVerificationKey(key); return saveFsService.OverrideSaveDataTransferTokenSignVerificationKey(key);
} }
public Result SetSdCardAccessibility(bool isAccessible) public Result SetSdCardAccessibility(bool isAccessible)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.SetSdCardAccessibility(isAccessible); return saveFsService.SetSdCardAccessibility(isAccessible);
} }
@ -1129,8 +1129,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
{ {
UnsafeHelpers.SkipParamInit(out isAccessible); UnsafeHelpers.SkipParamInit(out isAccessible);
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.IsSdCardAccessible(out isAccessible); return saveFsService.IsSdCardAccessible(out isAccessible);
} }
@ -1164,8 +1164,8 @@ public class FileSystemProxyImpl : IFileSystemProxy, IFileSystemProxyForLoader
public Result OpenMultiCommitManager(ref SharedRef<IMultiCommitManager> outCommitManager) public Result OpenMultiCommitManager(ref SharedRef<IMultiCommitManager> outCommitManager)
{ {
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService); Result res = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return saveFsService.OpenMultiCommitManager(ref outCommitManager); return saveFsService.OpenMultiCommitManager(ref outCommitManager);
} }

View File

@ -75,17 +75,17 @@ public class EmulatedBisFileSystemCreator : IBuiltInStorageFileSystemCreator
} }
using var bisRootPath = new Path(); using var bisRootPath = new Path();
Result rc = bisRootPath.Initialize(GetPartitionPath(partitionId).ToU8String()); Result res = bisRootPath.Initialize(GetPartitionPath(partitionId).ToU8String());
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
var pathFlags = new PathFlags(); var pathFlags = new PathFlags();
pathFlags.AllowEmptyPath(); pathFlags.AllowEmptyPath();
rc = bisRootPath.Normalize(pathFlags); res = bisRootPath.Normalize(pathFlags);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var partitionFileSystem = new SharedRef<IFileSystem>(); using var partitionFileSystem = new SharedRef<IFileSystem>();
rc = Utility.WrapSubDirectory(ref partitionFileSystem.Ref(), ref rootFileSystem.Ref(), in bisRootPath, true); res = Utility.WrapSubDirectory(ref partitionFileSystem.Ref(), ref rootFileSystem.Ref(), in bisRootPath, true);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
outFileSystem.SetByMove(ref partitionFileSystem.Ref()); outFileSystem.SetByMove(ref partitionFileSystem.Ref());
return Result.Success; return Result.Success;

View File

@ -22,8 +22,8 @@ public class EmulatedGameCardFsCreator : IGameCardFileSystemCreator
{ {
// Use the old xci code temporarily // Use the old xci code temporarily
Result rc = _gameCard.GetXci(out Xci xci, handle); Result res = _gameCard.GetXci(out Xci xci, handle);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!xci.HasPartition((XciPartitionType)partitionType)) if (!xci.HasPartition((XciPartitionType)partitionType))
{ {

View File

@ -22,8 +22,8 @@ public class EmulatedGameCardStorageCreator : IGameCardStorageCreator
using var baseStorage = new SharedRef<IStorage>(new ReadOnlyGameCardStorage(GameCard, handle)); using var baseStorage = new SharedRef<IStorage>(new ReadOnlyGameCardStorage(GameCard, handle));
Result rc = GameCard.GetCardInfo(out GameCardInfo cardInfo, handle); Result res = GameCard.GetCardInfo(out GameCardInfo cardInfo, handle);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
outStorage.Reset(new SubStorage(in baseStorage, 0, cardInfo.SecureAreaOffset)); outStorage.Reset(new SubStorage(in baseStorage, 0, cardInfo.SecureAreaOffset));
return Result.Success; return Result.Success;
@ -39,17 +39,17 @@ public class EmulatedGameCardStorageCreator : IGameCardStorageCreator
Span<byte> deviceId = stackalloc byte[0x10]; Span<byte> deviceId = stackalloc byte[0x10];
Span<byte> imageHash = stackalloc byte[0x20]; Span<byte> imageHash = stackalloc byte[0x20];
Result rc = GameCard.GetGameCardDeviceId(deviceId); Result res = GameCard.GetGameCardDeviceId(deviceId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = GameCard.GetGameCardImageHash(imageHash); res = GameCard.GetGameCardImageHash(imageHash);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var baseStorage = using var baseStorage =
new SharedRef<IStorage>(new ReadOnlyGameCardStorage(GameCard, handle, deviceId, imageHash)); new SharedRef<IStorage>(new ReadOnlyGameCardStorage(GameCard, handle, deviceId, imageHash));
rc = GameCard.GetCardInfo(out GameCardInfo cardInfo, handle); res = GameCard.GetCardInfo(out GameCardInfo cardInfo, handle);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
outStorage.Reset(new SubStorage(in baseStorage, cardInfo.SecureAreaOffset, cardInfo.SecureAreaSize)); outStorage.Reset(new SubStorage(in baseStorage, cardInfo.SecureAreaOffset, cardInfo.SecureAreaSize));
return Result.Success; return Result.Success;
@ -113,8 +113,8 @@ public class EmulatedGameCardStorageCreator : IGameCardStorageCreator
{ {
UnsafeHelpers.SkipParamInit(out size); UnsafeHelpers.SkipParamInit(out size);
Result rc = GameCard.GetCardInfo(out GameCardInfo info, Handle); Result res = GameCard.GetCardInfo(out GameCardInfo info, Handle);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
size = info.Size; size = info.Size;
return Result.Success; return Result.Success;

View File

@ -58,19 +58,19 @@ public class EmulatedSdCardFileSystemCreator : ISdCardProxyFileSystemCreator, ID
string path = _path ?? DefaultPath; string path = _path ?? DefaultPath;
using var sdCardPath = new Path(); using var sdCardPath = new Path();
Result rc = sdCardPath.Initialize(StringUtils.StringToUtf8(path)); Result res = sdCardPath.Initialize(StringUtils.StringToUtf8(path));
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
var pathFlags = new PathFlags(); var pathFlags = new PathFlags();
pathFlags.AllowEmptyPath(); pathFlags.AllowEmptyPath();
rc = sdCardPath.Normalize(pathFlags); res = sdCardPath.Normalize(pathFlags);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Todo: Add ProxyFileSystem? // Todo: Add ProxyFileSystem?
using SharedRef<IFileSystem> fileSystem = SharedRef<IFileSystem>.CreateCopy(in _rootFileSystem); using SharedRef<IFileSystem> fileSystem = SharedRef<IFileSystem>.CreateCopy(in _rootFileSystem);
rc = Utility.WrapSubDirectory(ref _sdCardFileSystem, ref fileSystem.Ref(), in sdCardPath, true); res = Utility.WrapSubDirectory(ref _sdCardFileSystem, ref fileSystem.Ref(), in sdCardPath, true);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
outFileSystem.SetByCopy(in _sdCardFileSystem); outFileSystem.SetByCopy(in _sdCardFileSystem);

View File

@ -13,8 +13,8 @@ public class PartitionFileSystemCreator : IPartitionFileSystemCreator
using var partitionFs = using var partitionFs =
new SharedRef<PartitionFileSystemCore<StandardEntry>>(new PartitionFileSystemCore<StandardEntry>()); new SharedRef<PartitionFileSystemCore<StandardEntry>>(new PartitionFileSystemCore<StandardEntry>());
Result rc = partitionFs.Get.Initialize(ref baseStorage); Result res = partitionFs.Get.Initialize(ref baseStorage);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outFileSystem.SetByMove(ref partitionFs.Ref()); outFileSystem.SetByMove(ref partitionFs.Ref());
return Result.Success; return Result.Success;

View File

@ -48,14 +48,14 @@ public class SaveDataFileSystemCreator : ISaveDataFileSystemCreator
Unsafe.SkipInit(out Array18<byte> saveImageNameBuffer); Unsafe.SkipInit(out Array18<byte> saveImageNameBuffer);
using var saveImageName = new Path(); using var saveImageName = new Path();
Result rc = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer.Items, saveDataId); Result res = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer.Items, saveDataId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = baseFileSystem.Get.GetEntryType(out DirectoryEntryType type, in saveImageName); res = baseFileSystem.Get.GetEntryType(out DirectoryEntryType type, in saveImageName);
if (rc.IsFailure()) if (res.IsFailure())
{ {
return ResultFs.PathNotFound.Includes(rc) ? ResultFs.TargetNotFound.LogConverted(rc) : rc.Miss(); return ResultFs.PathNotFound.Includes(res) ? ResultFs.TargetNotFound.LogConverted(res) : res.Miss();
} }
using var saveDataFs = new SharedRef<ISaveDataFileSystem>(); using var saveDataFs = new SharedRef<ISaveDataFileSystem>();
@ -74,8 +74,8 @@ public class SaveDataFileSystemCreator : ISaveDataFileSystemCreator
if (!baseFs.HasValue) if (!baseFs.HasValue)
return ResultFs.AllocationMemoryFailedInSaveDataFileSystemCreatorA.Log(); return ResultFs.AllocationMemoryFailedInSaveDataFileSystemCreatorA.Log();
rc = baseFs.Get.Initialize(in saveImageName); res = baseFs.Get.Initialize(in saveImageName);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
// Create and initialize the directory save data FS // Create and initialize the directory save data FS
using UniqueRef<IFileSystem> tempFs = UniqueRef<IFileSystem>.Create(ref baseFs.Ref()); using UniqueRef<IFileSystem> tempFs = UniqueRef<IFileSystem>.Create(ref baseFs.Ref());
@ -85,9 +85,9 @@ public class SaveDataFileSystemCreator : ISaveDataFileSystemCreator
if (!saveDirFs.HasValue) if (!saveDirFs.HasValue)
return ResultFs.AllocationMemoryFailedInSaveDataFileSystemCreatorB.Log(); return ResultFs.AllocationMemoryFailedInSaveDataFileSystemCreatorB.Log();
rc = saveDirFs.Get.Initialize(isJournalingSupported, isMultiCommitSupported, !openReadOnly, res = saveDirFs.Get.Initialize(isJournalingSupported, isMultiCommitSupported, !openReadOnly,
timeStampGetter, _randomGenerator); timeStampGetter, _randomGenerator);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
saveDataFs.SetByMove(ref saveDirFs.Ref()); saveDataFs.SetByMove(ref saveDirFs.Ref());
} }
@ -98,9 +98,9 @@ public class SaveDataFileSystemCreator : ISaveDataFileSystemCreator
Optional<OpenType> openType = Optional<OpenType> openType =
openShared ? new Optional<OpenType>(OpenType.Normal) : new Optional<OpenType>(); openShared ? new Optional<OpenType>(OpenType.Normal) : new Optional<OpenType>();
rc = _fsServer.OpenSaveDataStorage(ref fileStorage.Ref(), ref baseFileSystem, spaceId, saveDataId, res = _fsServer.OpenSaveDataStorage(ref fileStorage.Ref(), ref baseFileSystem, spaceId, saveDataId,
OpenMode.ReadWrite, openType); OpenMode.ReadWrite, openType);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@ -85,8 +85,8 @@ public class SaveDataResultConvertFileSystem : IResultConvertFileSystem<ISaveDat
protected override Result DoOpenFile(ref UniqueRef<IFile> outFile, in Path path, OpenMode mode) protected override Result DoOpenFile(ref UniqueRef<IFile> outFile, in Path path, OpenMode mode)
{ {
using var file = new UniqueRef<IFile>(); using var file = new UniqueRef<IFile>();
Result rc = ConvertResult(GetFileSystem().OpenFile(ref file.Ref(), in path, mode)); Result res = ConvertResult(GetFileSystem().OpenFile(ref file.Ref(), in path, mode));
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
using UniqueRef<SaveDataResultConvertFile> resultConvertFile = using UniqueRef<SaveDataResultConvertFile> resultConvertFile =
new(new SaveDataResultConvertFile(ref file.Ref(), _isReconstructible)); new(new SaveDataResultConvertFile(ref file.Ref(), _isReconstructible));
@ -99,8 +99,8 @@ public class SaveDataResultConvertFileSystem : IResultConvertFileSystem<ISaveDat
OpenDirectoryMode mode) OpenDirectoryMode mode)
{ {
using var directory = new UniqueRef<IDirectory>(); using var directory = new UniqueRef<IDirectory>();
Result rc = ConvertResult(GetFileSystem().OpenDirectory(ref directory.Ref(), in path, mode)); Result res = ConvertResult(GetFileSystem().OpenDirectory(ref directory.Ref(), in path, mode));
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
using UniqueRef<SaveDataResultConvertDirectory> resultConvertDirectory = using UniqueRef<SaveDataResultConvertDirectory> resultConvertDirectory =
new(new SaveDataResultConvertDirectory(ref directory.Ref(), _isReconstructible)); new(new SaveDataResultConvertDirectory(ref directory.Ref(), _isReconstructible));

View File

@ -28,18 +28,18 @@ public class StorageOnNcaCreator : IStorageOnNcaCreator
{ {
UnsafeHelpers.SkipParamInit(out fsHeader); UnsafeHelpers.SkipParamInit(out fsHeader);
Result rc = OpenStorage(out IStorage storageTemp, nca, fsIndex); Result res = OpenStorage(out IStorage storageTemp, nca, fsIndex);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (isCodeFs) if (isCodeFs)
{ {
using (var codeFs = new PartitionFileSystemCore<StandardEntry>()) using (var codeFs = new PartitionFileSystemCore<StandardEntry>())
{ {
rc = codeFs.Initialize(storageTemp); res = codeFs.Initialize(storageTemp);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = VerifyAcidSignature(codeFs, nca); res = VerifyAcidSignature(codeFs, nca);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
} }

View File

@ -12,8 +12,8 @@ public class SubDirectoryFileSystemCreator : ISubDirectoryFileSystemCreator
{ {
using var directory = new UniqueRef<IDirectory>(); using var directory = new UniqueRef<IDirectory>();
Result rc = baseFileSystem.Get.OpenDirectory(ref directory.Ref(), in path, OpenDirectoryMode.Directory); Result res = baseFileSystem.Get.OpenDirectory(ref directory.Ref(), in path, OpenDirectoryMode.Directory);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
directory.Reset(); directory.Reset();
@ -22,8 +22,8 @@ public class SubDirectoryFileSystemCreator : ISubDirectoryFileSystemCreator
if (!subFs.HasValue) if (!subFs.HasValue)
return ResultFs.AllocationMemoryFailedInSubDirectoryFileSystemCreatorA.Log(); return ResultFs.AllocationMemoryFailedInSubDirectoryFileSystemCreatorA.Log();
rc = subFs.Get.Initialize(in path); res = subFs.Get.Initialize(in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
outSubDirFileSystem.SetByMove(ref subFs.Ref()); outSubDirFileSystem.SetByMove(ref subFs.Ref());
return Result.Success; return Result.Success;

View File

@ -30,8 +30,8 @@ internal class DeviceEventSimulationStorage : IStorage
{ {
Assert.SdkNotNull(_deviceEventSimulator); Assert.SdkNotNull(_deviceEventSimulator);
Result rc = _deviceEventSimulator.CheckSimulatedAccessFailureEvent(SimulatingDeviceTargetOperation.Read); Result res = _deviceEventSimulator.CheckSimulatedAccessFailureEvent(SimulatingDeviceTargetOperation.Read);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return _baseStorage.Get.Read(offset, destination); return _baseStorage.Get.Read(offset, destination);
} }
@ -40,8 +40,8 @@ internal class DeviceEventSimulationStorage : IStorage
{ {
Assert.SdkNotNull(_deviceEventSimulator); Assert.SdkNotNull(_deviceEventSimulator);
Result rc = _deviceEventSimulator.CheckSimulatedAccessFailureEvent(SimulatingDeviceTargetOperation.Write); Result res = _deviceEventSimulator.CheckSimulatedAccessFailureEvent(SimulatingDeviceTargetOperation.Write);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return _baseStorage.Get.Write(offset, source); return _baseStorage.Get.Write(offset, source);
} }

View File

@ -68,8 +68,8 @@ public class DeviceOperator : IDeviceOperator
{ {
UnsafeHelpers.SkipParamInit(out outSpeedMode); UnsafeHelpers.SkipParamInit(out outSpeedMode);
Result rc = _fsServer.Storage.GetSdCardSpeedMode(out SdCardSpeedMode speedMode); Result res = _fsServer.Storage.GetSdCardSpeedMode(out SdCardSpeedMode speedMode);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outSpeedMode = (long)speedMode; outSpeedMode = (long)speedMode;
return Result.Success; return Result.Success;
@ -79,8 +79,8 @@ public class DeviceOperator : IDeviceOperator
{ {
UnsafeHelpers.SkipParamInit(out outSize); UnsafeHelpers.SkipParamInit(out outSize);
Result rc = _fsServer.Storage.GetSdCardUserAreaSize(out long size); Result res = _fsServer.Storage.GetSdCardUserAreaSize(out long size);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outSize = size; outSize = size;
return Result.Success; return Result.Success;
@ -90,8 +90,8 @@ public class DeviceOperator : IDeviceOperator
{ {
UnsafeHelpers.SkipParamInit(out outSize); UnsafeHelpers.SkipParamInit(out outSize);
Result rc = _fsServer.Storage.GetSdCardProtectedAreaSize(out long size); Result res = _fsServer.Storage.GetSdCardProtectedAreaSize(out long size);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outSize = size; outSize = size;
return Result.Success; return Result.Success;
@ -105,9 +105,9 @@ public class DeviceOperator : IDeviceOperator
if (logBuffer.Size < logBufferSize) if (logBuffer.Size < logBufferSize)
return ResultFs.InvalidSize.Log(); return ResultFs.InvalidSize.Log();
Result rc = _fsServer.Storage.GetAndClearSdCardErrorInfo(out StorageErrorInfo storageErrorInfo, Result res = _fsServer.Storage.GetAndClearSdCardErrorInfo(out StorageErrorInfo storageErrorInfo,
out long logSize, GetSpan(logBuffer, logBufferSize)); out long logSize, GetSpan(logBuffer, logBufferSize));
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outStorageErrorInfo = storageErrorInfo; outStorageErrorInfo = storageErrorInfo;
outLogSize = logSize; outLogSize = logSize;
@ -126,8 +126,8 @@ public class DeviceOperator : IDeviceOperator
{ {
UnsafeHelpers.SkipParamInit(out outSpeedMode); UnsafeHelpers.SkipParamInit(out outSpeedMode);
Result rc = _fsServer.Storage.GetMmcSpeedMode(out MmcSpeedMode speedMode); Result res = _fsServer.Storage.GetMmcSpeedMode(out MmcSpeedMode speedMode);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outSpeedMode = (long)speedMode; outSpeedMode = (long)speedMode;
return Result.Success; return Result.Success;
@ -145,8 +145,8 @@ public class DeviceOperator : IDeviceOperator
{ {
UnsafeHelpers.SkipParamInit(out outSize); UnsafeHelpers.SkipParamInit(out outSize);
Result rc = _fsServer.Storage.GetMmcPartitionSize(out long mmcPartitionSize, (MmcPartition)partitionId); Result res = _fsServer.Storage.GetMmcPartitionSize(out long mmcPartitionSize, (MmcPartition)partitionId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outSize = mmcPartitionSize; outSize = mmcPartitionSize;
return Result.Success; return Result.Success;
@ -156,8 +156,8 @@ public class DeviceOperator : IDeviceOperator
{ {
UnsafeHelpers.SkipParamInit(out outCount); UnsafeHelpers.SkipParamInit(out outCount);
Result rc = _fsServer.Storage.GetMmcPatrolCount(out uint mmcPatrolCount); Result res = _fsServer.Storage.GetMmcPatrolCount(out uint mmcPatrolCount);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outCount = mmcPatrolCount; outCount = mmcPatrolCount;
return Result.Success; return Result.Success;
@ -171,9 +171,9 @@ public class DeviceOperator : IDeviceOperator
if (logBuffer.Size < logBufferSize) if (logBuffer.Size < logBufferSize)
return ResultFs.InvalidSize.Log(); return ResultFs.InvalidSize.Log();
Result rc = _fsServer.Storage.GetAndClearMmcErrorInfo(out StorageErrorInfo storageErrorInfo, out long logSize, Result res = _fsServer.Storage.GetAndClearMmcErrorInfo(out StorageErrorInfo storageErrorInfo, out long logSize,
GetSpan(logBuffer, logBufferSize)); GetSpan(logBuffer, logBufferSize));
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outStorageErrorInfo = storageErrorInfo; outStorageErrorInfo = storageErrorInfo;
outLogSize = logSize; outLogSize = logSize;
@ -208,8 +208,8 @@ public class DeviceOperator : IDeviceOperator
{ {
UnsafeHelpers.SkipParamInit(out outIsInserted); UnsafeHelpers.SkipParamInit(out outIsInserted);
Result rc = _fsServer.Storage.IsGameCardInserted(out bool isInserted); Result res = _fsServer.Storage.IsGameCardInserted(out bool isInserted);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outIsInserted = isInserted; outIsInserted = isInserted;
return Result.Success; return Result.Success;
@ -229,15 +229,15 @@ public class DeviceOperator : IDeviceOperator
{ {
UnsafeHelpers.SkipParamInit(out outHandle); UnsafeHelpers.SkipParamInit(out outHandle);
Result rc = _fsServer.Storage.GetInitializationResult(); Result res = _fsServer.Storage.GetInitializationResult();
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
_fsServer.Storage.IsGameCardInserted(out bool isInserted).IgnoreResult(); _fsServer.Storage.IsGameCardInserted(out bool isInserted).IgnoreResult();
if (!isInserted) if (!isInserted)
return ResultFs.GameCardFsGetHandleFailure.Log(); return ResultFs.GameCardFsGetHandleFailure.Log();
rc = _fsServer.Storage.GetGameCardHandle(out GameCardHandle handle); res = _fsServer.Storage.GetGameCardHandle(out GameCardHandle handle);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outHandle = handle; outHandle = handle;
return Result.Success; return Result.Success;
@ -247,8 +247,8 @@ public class DeviceOperator : IDeviceOperator
{ {
UnsafeHelpers.SkipParamInit(out outCupVersion, out outCupId); UnsafeHelpers.SkipParamInit(out outCupVersion, out outCupId);
Result rc = _fsServer.Storage.GetGameCardStatus(out GameCardStatus gameCardStatus, handle); Result res = _fsServer.Storage.GetGameCardStatus(out GameCardStatus gameCardStatus, handle);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outCupVersion = gameCardStatus.UpdatePartitionVersion; outCupVersion = gameCardStatus.UpdatePartitionVersion;
outCupId = gameCardStatus.UpdatePartitionId; outCupId = gameCardStatus.UpdatePartitionId;
@ -269,8 +269,8 @@ public class DeviceOperator : IDeviceOperator
{ {
UnsafeHelpers.SkipParamInit(out outAttribute); UnsafeHelpers.SkipParamInit(out outAttribute);
Result rc = _fsServer.Storage.GetGameCardStatus(out GameCardStatus gameCardStatus, handle); Result res = _fsServer.Storage.GetGameCardStatus(out GameCardStatus gameCardStatus, handle);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outAttribute = gameCardStatus.GameCardAttribute; outAttribute = gameCardStatus.GameCardAttribute;
return Result.Success; return Result.Success;
@ -280,8 +280,8 @@ public class DeviceOperator : IDeviceOperator
{ {
UnsafeHelpers.SkipParamInit(out outCompatibilityType); UnsafeHelpers.SkipParamInit(out outCompatibilityType);
Result rc = _fsServer.Storage.GetGameCardStatus(out GameCardStatus gameCardStatus, handle); Result res = _fsServer.Storage.GetGameCardStatus(out GameCardStatus gameCardStatus, handle);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outCompatibilityType = gameCardStatus.CompatibilityType; outCompatibilityType = gameCardStatus.CompatibilityType;
return Result.Success; return Result.Success;
@ -323,9 +323,9 @@ public class DeviceOperator : IDeviceOperator
if (rmaInfoBufferSize != Unsafe.SizeOf<RmaInformation>()) if (rmaInfoBufferSize != Unsafe.SizeOf<RmaInformation>())
return ResultFs.InvalidArgument.Log(); return ResultFs.InvalidArgument.Log();
Result rc = _fsServer.Storage.GetGameCardAsicInfo(out RmaInformation rmaInfo, Result res = _fsServer.Storage.GetGameCardAsicInfo(out RmaInformation rmaInfo,
GetSpan(asicFirmwareBuffer, asicFirmwareBufferSize)); GetSpan(asicFirmwareBuffer, asicFirmwareBufferSize));
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
SpanHelpers.AsReadOnlyByteSpan(in rmaInfo).CopyTo(outRmaInfoBuffer.Buffer); SpanHelpers.AsReadOnlyByteSpan(in rmaInfo).CopyTo(outRmaInfoBuffer.Buffer);
return Result.Success; return Result.Success;
@ -339,8 +339,8 @@ public class DeviceOperator : IDeviceOperator
if (outBufferSize != Unsafe.SizeOf<GameCardIdSet>()) if (outBufferSize != Unsafe.SizeOf<GameCardIdSet>())
return ResultFs.InvalidArgument.Log(); return ResultFs.InvalidArgument.Log();
Result rc = _fsServer.Storage.GetGameCardIdSet(out GameCardIdSet gcIdSet); Result res = _fsServer.Storage.GetGameCardIdSet(out GameCardIdSet gcIdSet);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
SpanHelpers.AsReadOnlyByteSpan(in gcIdSet).CopyTo(outBuffer.Buffer); SpanHelpers.AsReadOnlyByteSpan(in gcIdSet).CopyTo(outBuffer.Buffer);
return Result.Success; return Result.Success;
@ -436,8 +436,8 @@ public class DeviceOperator : IDeviceOperator
{ {
UnsafeHelpers.SkipParamInit(out outErrorInfo); UnsafeHelpers.SkipParamInit(out outErrorInfo);
Result rc = _fsServer.Storage.GetGameCardErrorInfo(out GameCardErrorInfo gameCardErrorInfo); Result res = _fsServer.Storage.GetGameCardErrorInfo(out GameCardErrorInfo gameCardErrorInfo);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outErrorInfo = gameCardErrorInfo; outErrorInfo = gameCardErrorInfo;
return Result.Success; return Result.Success;
@ -447,8 +447,8 @@ public class DeviceOperator : IDeviceOperator
{ {
UnsafeHelpers.SkipParamInit(out outErrorInfo); UnsafeHelpers.SkipParamInit(out outErrorInfo);
Result rc = _fsServer.Storage.GetGameCardErrorReportInfo(out GameCardErrorReportInfo gameCardErrorReportInfo); Result res = _fsServer.Storage.GetGameCardErrorReportInfo(out GameCardErrorReportInfo gameCardErrorReportInfo);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
outErrorInfo = gameCardErrorReportInfo; outErrorInfo = gameCardErrorReportInfo;
return Result.Success; return Result.Success;
@ -479,13 +479,13 @@ public class DeviceOperator : IDeviceOperator
public Result SuspendSdmmcControl() public Result SuspendSdmmcControl()
{ {
Result rc = _fsServer.Storage.SuspendSdCardControl(); Result res = _fsServer.Storage.SuspendSdCardControl();
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
// Missing: Detach SD card device buffer // Missing: Detach SD card device buffer
rc = _fsServer.Storage.SuspendMmcControl(); res = _fsServer.Storage.SuspendMmcControl();
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
// Missing: Detach MMC device buffer // Missing: Detach MMC device buffer
@ -496,13 +496,13 @@ public class DeviceOperator : IDeviceOperator
{ {
// Missing: Attach MMC device buffer // Missing: Attach MMC device buffer
Result rc = _fsServer.Storage.ResumeMmcControl(); Result res = _fsServer.Storage.ResumeMmcControl();
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
// Missing: Attach SD card device buffer // Missing: Attach SD card device buffer
rc = _fsServer.Storage.ResumeSdCardControl(); res = _fsServer.Storage.ResumeSdCardControl();
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -514,8 +514,8 @@ public class DeviceOperator : IDeviceOperator
if ((uint)port > (uint)Port.GcAsic0) if ((uint)port > (uint)Port.GcAsic0)
return ResultFs.InvalidArgument.Log(); return ResultFs.InvalidArgument.Log();
Result rc = SdmmcSrv.Common.CheckConnection(out SpeedMode speedMode, out BusWidth busWidth, (Port)port); Result res = SdmmcSrv.Common.CheckConnection(out SpeedMode speedMode, out BusWidth busWidth, (Port)port);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
SdmmcSpeedMode sdmmcSpeedMode = speedMode switch SdmmcSpeedMode sdmmcSpeedMode = speedMode switch
{ {

View File

@ -55,19 +55,19 @@ public class FileInterfaceAdapter : IFileSf
if (destination.Size < (int)size) if (destination.Size < (int)size)
return ResultFs.InvalidSize.Log(); return ResultFs.InvalidSize.Log();
Result rc = Result.Success; Result res = Result.Success;
long readSize = 0; long readSize = 0;
for (int tryNum = 0; tryNum < maxTryCount; tryNum++) for (int tryNum = 0; tryNum < maxTryCount; tryNum++)
{ {
rc = _baseFile.Get.Read(out readSize, offset, destination.Buffer.Slice(0, (int)size), option); res = _baseFile.Get.Read(out readSize, offset, destination.Buffer.Slice(0, (int)size), option);
// Retry on ResultDataCorrupted // Retry on ResultDataCorrupted
if (!ResultFs.DataCorrupted.Includes(rc)) if (!ResultFs.DataCorrupted.Includes(res))
break; break;
} }
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
bytesRead = readSize; bytesRead = readSize;
return Result.Success; return Result.Success;
@ -108,19 +108,19 @@ public class FileInterfaceAdapter : IFileSf
const int maxTryCount = 2; const int maxTryCount = 2;
UnsafeHelpers.SkipParamInit(out size); UnsafeHelpers.SkipParamInit(out size);
Result rc = Result.Success; Result res = Result.Success;
long tmpSize = 0; long tmpSize = 0;
for (int tryNum = 0; tryNum < maxTryCount; tryNum++) for (int tryNum = 0; tryNum < maxTryCount; tryNum++)
{ {
rc = _baseFile.Get.GetSize(out tmpSize); res = _baseFile.Get.GetSize(out tmpSize);
// Retry on ResultDataCorrupted // Retry on ResultDataCorrupted
if (!ResultFs.DataCorrupted.Includes(rc)) if (!ResultFs.DataCorrupted.Includes(res))
break; break;
} }
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
size = tmpSize; size = tmpSize;
return Result.Success; return Result.Success;
@ -135,17 +135,17 @@ public class FileInterfaceAdapter : IFileSf
{ {
Unsafe.SkipInit(out QueryRangeInfo info); Unsafe.SkipInit(out QueryRangeInfo info);
Result rc = _baseFile.Get.OperateRange(SpanHelpers.AsByteSpan(ref info), OperationId.QueryRange, offset, Result res = _baseFile.Get.OperateRange(SpanHelpers.AsByteSpan(ref info), OperationId.QueryRange, offset,
size, ReadOnlySpan<byte>.Empty); size, ReadOnlySpan<byte>.Empty);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rangeInfo.Merge(in info); rangeInfo.Merge(in info);
} }
else if (operationId == (int)OperationId.InvalidateCache) else if (operationId == (int)OperationId.InvalidateCache)
{ {
Result rc = _baseFile.Get.OperateRange(Span<byte>.Empty, OperationId.InvalidateCache, offset, size, Result res = _baseFile.Get.OperateRange(Span<byte>.Empty, OperationId.InvalidateCache, offset, size,
ReadOnlySpan<byte>.Empty); ReadOnlySpan<byte>.Empty);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
return Result.Success; return Result.Success;
@ -168,11 +168,11 @@ public class FileInterfaceAdapter : IFileSf
return Result.Success; return Result.Success;
} }
Result rc = PermissionCheck((OperationId)operationId, this); Result res = PermissionCheck((OperationId)operationId, this);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _baseFile.Get.OperateRange(outBuffer.Buffer, (OperationId)operationId, offset, size, inBuffer.Buffer); res = _baseFile.Get.OperateRange(outBuffer.Buffer, (OperationId)operationId, offset, size, inBuffer.Buffer);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -207,19 +207,19 @@ public class DirectoryInterfaceAdapter : IDirectorySf
Span<DirectoryEntry> entries = MemoryMarshal.Cast<byte, DirectoryEntry>(entryBuffer.Buffer); Span<DirectoryEntry> entries = MemoryMarshal.Cast<byte, DirectoryEntry>(entryBuffer.Buffer);
Result rc = Result.Success; Result res = Result.Success;
long numRead = 0; long numRead = 0;
for (int tryNum = 0; tryNum < maxTryCount; tryNum++) for (int tryNum = 0; tryNum < maxTryCount; tryNum++)
{ {
rc = _baseDirectory.Get.Read(out numRead, entries); res = _baseDirectory.Get.Read(out numRead, entries);
// Retry on ResultDataCorrupted // Retry on ResultDataCorrupted
if (!ResultFs.DataCorrupted.Includes(rc)) if (!ResultFs.DataCorrupted.Includes(res))
break; break;
} }
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
entriesRead = numRead; entriesRead = numRead;
return Result.Success; return Result.Success;
@ -229,8 +229,8 @@ public class DirectoryInterfaceAdapter : IDirectorySf
{ {
UnsafeHelpers.SkipParamInit(out entryCount); UnsafeHelpers.SkipParamInit(out entryCount);
Result rc = _baseDirectory.Get.GetEntryCount(out long count); Result res = _baseDirectory.Get.GetEntryCount(out long count);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
entryCount = count; entryCount = count;
return Result.Success; return Result.Success;
@ -297,21 +297,21 @@ public class FileSystemInterfaceAdapter : IFileSystemSf
private Result SetUpPath(ref Path fsPath, in PathSf sfPath) private Result SetUpPath(ref Path fsPath, in PathSf sfPath)
{ {
Result rc; Result res;
if (_pathFlags.IsWindowsPathAllowed()) if (_pathFlags.IsWindowsPathAllowed())
{ {
rc = fsPath.InitializeWithReplaceUnc(sfPath.Str); res = fsPath.InitializeWithReplaceUnc(sfPath.Str);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
else else
{ {
rc = fsPath.Initialize(sfPath.Str); res = fsPath.Initialize(sfPath.Str);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
rc = fsPath.Normalize(_pathFlags); res = fsPath.Normalize(_pathFlags);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -322,11 +322,11 @@ public class FileSystemInterfaceAdapter : IFileSystemSf
return ResultFs.InvalidSize.Log(); return ResultFs.InvalidSize.Log();
using var pathNormalized = new Path(); using var pathNormalized = new Path();
Result rc = SetUpPath(ref pathNormalized.Ref(), in path); Result res = SetUpPath(ref pathNormalized.Ref(), in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _baseFileSystem.Get.CreateFile(in pathNormalized, size, (CreateFileOptions)option); res = _baseFileSystem.Get.CreateFile(in pathNormalized, size, (CreateFileOptions)option);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -334,11 +334,11 @@ public class FileSystemInterfaceAdapter : IFileSystemSf
public Result DeleteFile(in PathSf path) public Result DeleteFile(in PathSf path)
{ {
using var pathNormalized = new Path(); using var pathNormalized = new Path();
Result rc = SetUpPath(ref pathNormalized.Ref(), in path); Result res = SetUpPath(ref pathNormalized.Ref(), in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _baseFileSystem.Get.DeleteFile(in pathNormalized); res = _baseFileSystem.Get.DeleteFile(in pathNormalized);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -346,14 +346,14 @@ public class FileSystemInterfaceAdapter : IFileSystemSf
public Result CreateDirectory(in PathSf path) public Result CreateDirectory(in PathSf path)
{ {
using var pathNormalized = new Path(); using var pathNormalized = new Path();
Result rc = SetUpPath(ref pathNormalized.Ref(), in path); Result res = SetUpPath(ref pathNormalized.Ref(), in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (pathNormalized == RootDir) if (pathNormalized == RootDir)
return ResultFs.PathAlreadyExists.Log(); return ResultFs.PathAlreadyExists.Log();
rc = _baseFileSystem.Get.CreateDirectory(in pathNormalized); res = _baseFileSystem.Get.CreateDirectory(in pathNormalized);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -361,14 +361,14 @@ public class FileSystemInterfaceAdapter : IFileSystemSf
public Result DeleteDirectory(in PathSf path) public Result DeleteDirectory(in PathSf path)
{ {
using var pathNormalized = new Path(); using var pathNormalized = new Path();
Result rc = SetUpPath(ref pathNormalized.Ref(), in path); Result res = SetUpPath(ref pathNormalized.Ref(), in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (pathNormalized == RootDir) if (pathNormalized == RootDir)
return ResultFs.DirectoryUndeletable.Log(); return ResultFs.DirectoryUndeletable.Log();
rc = _baseFileSystem.Get.DeleteDirectory(in pathNormalized); res = _baseFileSystem.Get.DeleteDirectory(in pathNormalized);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -376,14 +376,14 @@ public class FileSystemInterfaceAdapter : IFileSystemSf
public Result DeleteDirectoryRecursively(in PathSf path) public Result DeleteDirectoryRecursively(in PathSf path)
{ {
using var pathNormalized = new Path(); using var pathNormalized = new Path();
Result rc = SetUpPath(ref pathNormalized.Ref(), in path); Result res = SetUpPath(ref pathNormalized.Ref(), in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (pathNormalized == RootDir) if (pathNormalized == RootDir)
return ResultFs.DirectoryUndeletable.Log(); return ResultFs.DirectoryUndeletable.Log();
rc = _baseFileSystem.Get.DeleteDirectoryRecursively(in pathNormalized); res = _baseFileSystem.Get.DeleteDirectoryRecursively(in pathNormalized);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -391,11 +391,11 @@ public class FileSystemInterfaceAdapter : IFileSystemSf
public Result CleanDirectoryRecursively(in PathSf path) public Result CleanDirectoryRecursively(in PathSf path)
{ {
using var pathNormalized = new Path(); using var pathNormalized = new Path();
Result rc = SetUpPath(ref pathNormalized.Ref(), in path); Result res = SetUpPath(ref pathNormalized.Ref(), in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _baseFileSystem.Get.CleanDirectoryRecursively(in pathNormalized); res = _baseFileSystem.Get.CleanDirectoryRecursively(in pathNormalized);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -403,15 +403,15 @@ public class FileSystemInterfaceAdapter : IFileSystemSf
public Result RenameFile(in PathSf currentPath, in PathSf newPath) public Result RenameFile(in PathSf currentPath, in PathSf newPath)
{ {
using var currentPathNormalized = new Path(); using var currentPathNormalized = new Path();
Result rc = SetUpPath(ref currentPathNormalized.Ref(), in currentPath); Result res = SetUpPath(ref currentPathNormalized.Ref(), in currentPath);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var newPathNormalized = new Path(); using var newPathNormalized = new Path();
rc = SetUpPath(ref newPathNormalized.Ref(), in newPath); res = SetUpPath(ref newPathNormalized.Ref(), in newPath);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _baseFileSystem.Get.RenameFile(in currentPathNormalized, in newPathNormalized); res = _baseFileSystem.Get.RenameFile(in currentPathNormalized, in newPathNormalized);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -419,18 +419,18 @@ public class FileSystemInterfaceAdapter : IFileSystemSf
public Result RenameDirectory(in PathSf currentPath, in PathSf newPath) public Result RenameDirectory(in PathSf currentPath, in PathSf newPath)
{ {
using var currentPathNormalized = new Path(); using var currentPathNormalized = new Path();
Result rc = SetUpPath(ref currentPathNormalized.Ref(), in currentPath); Result res = SetUpPath(ref currentPathNormalized.Ref(), in currentPath);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var newPathNormalized = new Path(); using var newPathNormalized = new Path();
rc = SetUpPath(ref newPathNormalized.Ref(), in newPath); res = SetUpPath(ref newPathNormalized.Ref(), in newPath);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (PathUtility.IsSubPath(currentPathNormalized.GetString(), newPathNormalized.GetString())) if (PathUtility.IsSubPath(currentPathNormalized.GetString(), newPathNormalized.GetString()))
return ResultFs.DirectoryUnrenamable.Log(); return ResultFs.DirectoryUnrenamable.Log();
rc = _baseFileSystem.Get.RenameDirectory(in currentPathNormalized, in newPathNormalized); res = _baseFileSystem.Get.RenameDirectory(in currentPathNormalized, in newPathNormalized);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -440,11 +440,11 @@ public class FileSystemInterfaceAdapter : IFileSystemSf
UnsafeHelpers.SkipParamInit(out entryType); UnsafeHelpers.SkipParamInit(out entryType);
using var pathNormalized = new Path(); using var pathNormalized = new Path();
Result rc = SetUpPath(ref pathNormalized.Ref(), in path); Result res = SetUpPath(ref pathNormalized.Ref(), in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _baseFileSystem.Get.GetEntryType(out DirectoryEntryType type, in pathNormalized); res = _baseFileSystem.Get.GetEntryType(out DirectoryEntryType type, in pathNormalized);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
entryType = (uint)type; entryType = (uint)type;
return Result.Success; return Result.Success;
@ -455,11 +455,11 @@ public class FileSystemInterfaceAdapter : IFileSystemSf
UnsafeHelpers.SkipParamInit(out freeSpace); UnsafeHelpers.SkipParamInit(out freeSpace);
using var pathNormalized = new Path(); using var pathNormalized = new Path();
Result rc = SetUpPath(ref pathNormalized.Ref(), in path); Result res = SetUpPath(ref pathNormalized.Ref(), in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _baseFileSystem.Get.GetFreeSpaceSize(out long space, in pathNormalized); res = _baseFileSystem.Get.GetFreeSpaceSize(out long space, in pathNormalized);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
freeSpace = space; freeSpace = space;
return Result.Success; return Result.Success;
@ -470,11 +470,11 @@ public class FileSystemInterfaceAdapter : IFileSystemSf
UnsafeHelpers.SkipParamInit(out totalSpace); UnsafeHelpers.SkipParamInit(out totalSpace);
using var pathNormalized = new Path(); using var pathNormalized = new Path();
Result rc = SetUpPath(ref pathNormalized.Ref(), in path); Result res = SetUpPath(ref pathNormalized.Ref(), in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _baseFileSystem.Get.GetTotalSpaceSize(out long space, in pathNormalized); res = _baseFileSystem.Get.GetTotalSpaceSize(out long space, in pathNormalized);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
totalSpace = space; totalSpace = space;
return Result.Success; return Result.Success;
@ -485,21 +485,21 @@ public class FileSystemInterfaceAdapter : IFileSystemSf
const int maxTryCount = 2; const int maxTryCount = 2;
using var pathNormalized = new Path(); using var pathNormalized = new Path();
Result rc = SetUpPath(ref pathNormalized.Ref(), in path); Result res = SetUpPath(ref pathNormalized.Ref(), in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var file = new UniqueRef<IFile>(); using var file = new UniqueRef<IFile>();
for (int tryNum = 0; tryNum < maxTryCount; tryNum++) for (int tryNum = 0; tryNum < maxTryCount; tryNum++)
{ {
rc = _baseFileSystem.Get.OpenFile(ref file.Ref(), in pathNormalized, (OpenMode)mode); res = _baseFileSystem.Get.OpenFile(ref file.Ref(), in pathNormalized, (OpenMode)mode);
// Retry on ResultDataCorrupted // Retry on ResultDataCorrupted
if (!ResultFs.DataCorrupted.Includes(rc)) if (!ResultFs.DataCorrupted.Includes(res))
break; break;
} }
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using SharedRef<FileSystemInterfaceAdapter> selfReference = using SharedRef<FileSystemInterfaceAdapter> selfReference =
SharedRef<FileSystemInterfaceAdapter>.Create(in _selfReference); SharedRef<FileSystemInterfaceAdapter>.Create(in _selfReference);
@ -515,22 +515,22 @@ public class FileSystemInterfaceAdapter : IFileSystemSf
const int maxTryCount = 2; const int maxTryCount = 2;
using var pathNormalized = new Path(); using var pathNormalized = new Path();
Result rc = SetUpPath(ref pathNormalized.Ref(), in path); Result res = SetUpPath(ref pathNormalized.Ref(), in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var directory = new UniqueRef<IDirectory>(); using var directory = new UniqueRef<IDirectory>();
for (int tryNum = 0; tryNum < maxTryCount; tryNum++) for (int tryNum = 0; tryNum < maxTryCount; tryNum++)
{ {
rc = _baseFileSystem.Get.OpenDirectory(ref directory.Ref(), in pathNormalized, res = _baseFileSystem.Get.OpenDirectory(ref directory.Ref(), in pathNormalized,
(OpenDirectoryMode)mode); (OpenDirectoryMode)mode);
// Retry on ResultDataCorrupted // Retry on ResultDataCorrupted
if (!ResultFs.DataCorrupted.Includes(rc)) if (!ResultFs.DataCorrupted.Includes(res))
break; break;
} }
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using SharedRef<FileSystemInterfaceAdapter> selfReference = using SharedRef<FileSystemInterfaceAdapter> selfReference =
SharedRef<FileSystemInterfaceAdapter>.Create(in _selfReference); SharedRef<FileSystemInterfaceAdapter>.Create(in _selfReference);
@ -551,11 +551,11 @@ public class FileSystemInterfaceAdapter : IFileSystemSf
UnsafeHelpers.SkipParamInit(out timeStamp); UnsafeHelpers.SkipParamInit(out timeStamp);
using var pathNormalized = new Path(); using var pathNormalized = new Path();
Result rc = SetUpPath(ref pathNormalized.Ref(), in path); Result res = SetUpPath(ref pathNormalized.Ref(), in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _baseFileSystem.Get.GetFileTimeStampRaw(out FileTimeStampRaw tempTimeStamp, in pathNormalized); res = _baseFileSystem.Get.GetFileTimeStampRaw(out FileTimeStampRaw tempTimeStamp, in pathNormalized);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
timeStamp = tempTimeStamp; timeStamp = tempTimeStamp;
return Result.Success; return Result.Success;
@ -578,16 +578,16 @@ public class FileSystemInterfaceAdapter : IFileSystemSf
return Result.Success; return Result.Success;
} }
Result rc = PermissionCheck((QueryId)queryId, this); Result res = PermissionCheck((QueryId)queryId, this);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var pathNormalized = new Path(); using var pathNormalized = new Path();
rc = SetUpPath(ref pathNormalized.Ref(), in path); res = SetUpPath(ref pathNormalized.Ref(), in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _baseFileSystem.Get.QueryEntry(outBuffer.Buffer, inBuffer.Buffer, (QueryId)queryId, res = _baseFileSystem.Get.QueryEntry(outBuffer.Buffer, inBuffer.Buffer, (QueryId)queryId,
in pathNormalized); in pathNormalized);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }

View File

@ -82,11 +82,11 @@ internal class LocationResolverSet : IDisposable
if (Utility.IsHostFsMountName(lrPath.Value)) if (Utility.IsHostFsMountName(lrPath.Value))
pathFlags.AllowWindowsPath(); pathFlags.AllowWindowsPath();
Result rc = outPath.InitializeWithReplaceUnc(lrPath.Value); Result res = outPath.InitializeWithReplaceUnc(lrPath.Value);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = outPath.Normalize(pathFlags); res = outPath.Normalize(pathFlags);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -107,9 +107,9 @@ internal class LocationResolverSet : IDisposable
if (!_resolvers[index].HasValue) if (!_resolvers[index].HasValue)
{ {
_resolvers[index].Set(null); _resolvers[index].Set(null);
Result rc = Hos.Lr.OpenLocationResolver(out _resolvers[index].Value, storageId); Result res = Hos.Lr.OpenLocationResolver(out _resolvers[index].Value, storageId);
if (rc.IsFailure()) if (res.IsFailure())
{ {
_resolvers[index].Clear(); _resolvers[index].Clear();
return ResultLr.ApplicationNotFound.Log(); return ResultLr.ApplicationNotFound.Log();
@ -137,8 +137,8 @@ internal class LocationResolverSet : IDisposable
if (!_aocResolver.HasValue) if (!_aocResolver.HasValue)
{ {
Result rc = Hos.Lr.OpenAddOnContentLocationResolver(out AddOnContentLocationResolver lr); Result res = Hos.Lr.OpenAddOnContentLocationResolver(out AddOnContentLocationResolver lr);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
_aocResolver.Set(in lr); _aocResolver.Set(in lr);
} }
@ -149,11 +149,11 @@ internal class LocationResolverSet : IDisposable
public Result ResolveApplicationControlPath(ref Fs.Path outPath, Ncm.ApplicationId applicationId, StorageId storageId) public Result ResolveApplicationControlPath(ref Fs.Path outPath, Ncm.ApplicationId applicationId, StorageId storageId)
{ {
Result rc = GetLocationResolver(out LocationResolver resolver, storageId); Result res = GetLocationResolver(out LocationResolver resolver, storageId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = resolver.ResolveApplicationControlPath(out Lr.Path path, applicationId); res = resolver.ResolveApplicationControlPath(out Lr.Path path, applicationId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return SetUpFsPath(ref outPath, in path); return SetUpFsPath(ref outPath, in path);
} }
@ -162,11 +162,11 @@ internal class LocationResolverSet : IDisposable
{ {
UnsafeHelpers.SkipParamInit(out isDirectory); UnsafeHelpers.SkipParamInit(out isDirectory);
Result rc = GetLocationResolver(out LocationResolver resolver, storageId); Result res = GetLocationResolver(out LocationResolver resolver, storageId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = resolver.ResolveApplicationHtmlDocumentPath(out Lr.Path path, applicationId); res = resolver.ResolveApplicationHtmlDocumentPath(out Lr.Path path, applicationId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
isDirectory = PathUtility.IsDirectoryPath(path.Value); isDirectory = PathUtility.IsDirectoryPath(path.Value);
@ -177,11 +177,11 @@ internal class LocationResolverSet : IDisposable
{ {
UnsafeHelpers.SkipParamInit(out isDirectory); UnsafeHelpers.SkipParamInit(out isDirectory);
Result rc = GetLocationResolver(out LocationResolver resolver, storageId); Result res = GetLocationResolver(out LocationResolver resolver, storageId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = resolver.ResolveProgramPath(out Lr.Path path, programId); res = resolver.ResolveProgramPath(out Lr.Path path, programId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
isDirectory = PathUtility.IsDirectoryPath(path.Value); isDirectory = PathUtility.IsDirectoryPath(path.Value);
@ -192,11 +192,11 @@ internal class LocationResolverSet : IDisposable
{ {
UnsafeHelpers.SkipParamInit(out isDirectory); UnsafeHelpers.SkipParamInit(out isDirectory);
Result rc = GetLocationResolver(out LocationResolver resolver, storageId); Result res = GetLocationResolver(out LocationResolver resolver, storageId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = resolver.ResolveProgramPathForDebug(out Lr.Path path, programId); res = resolver.ResolveProgramPathForDebug(out Lr.Path path, programId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
isDirectory = PathUtility.IsDirectoryPath(path.Value); isDirectory = PathUtility.IsDirectoryPath(path.Value);
@ -205,11 +205,11 @@ internal class LocationResolverSet : IDisposable
public Result ResolveAddOnContentPath(ref Fs.Path outPath, DataId dataId) public Result ResolveAddOnContentPath(ref Fs.Path outPath, DataId dataId)
{ {
Result rc = GetAddOnContentLocationResolver(out AddOnContentLocationResolver resolver); Result res = GetAddOnContentLocationResolver(out AddOnContentLocationResolver resolver);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = resolver.ResolveAddOnContentPath(out Lr.Path path, dataId); res = resolver.ResolveAddOnContentPath(out Lr.Path path, dataId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return SetUpFsPath(ref outPath, in path); return SetUpFsPath(ref outPath, in path);
} }
@ -219,11 +219,11 @@ internal class LocationResolverSet : IDisposable
if (storageId == StorageId.None) if (storageId == StorageId.None)
return ResultFs.InvalidAlignment.Log(); return ResultFs.InvalidAlignment.Log();
Result rc = GetLocationResolver(out LocationResolver resolver, storageId); Result res = GetLocationResolver(out LocationResolver resolver, storageId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = resolver.ResolveDataPath(out Lr.Path path, dataId); res = resolver.ResolveDataPath(out Lr.Path path, dataId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return SetUpFsPath(ref outPath, in path); return SetUpFsPath(ref outPath, in path);
} }
@ -233,11 +233,11 @@ internal class LocationResolverSet : IDisposable
RegisteredLocationResolver resolver = null; RegisteredLocationResolver resolver = null;
try try
{ {
Result rc = GetRegisteredLocationResolver(out resolver); Result res = GetRegisteredLocationResolver(out resolver);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = resolver.ResolveProgramPath(out Lr.Path path, new ProgramId(id)); res = resolver.ResolveProgramPath(out Lr.Path path, new ProgramId(id));
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return SetUpFsPath(ref outPath, in path); return SetUpFsPath(ref outPath, in path);
} }
@ -252,11 +252,11 @@ internal class LocationResolverSet : IDisposable
RegisteredLocationResolver resolver = null; RegisteredLocationResolver resolver = null;
try try
{ {
Result rc = GetRegisteredLocationResolver(out resolver); Result res = GetRegisteredLocationResolver(out resolver);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = resolver.ResolveHtmlDocumentPath(out Lr.Path path, new ProgramId(id)); res = resolver.ResolveHtmlDocumentPath(out Lr.Path path, new ProgramId(id));
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return SetUpFsPath(ref outPath, in path); return SetUpFsPath(ref outPath, in path);
} }

View File

@ -100,15 +100,15 @@ internal class MultiCommitManager : IMultiCommitManager
private Result EnsureSaveDataForContext() private Result EnsureSaveDataForContext()
{ {
using var contextFileSystem = new SharedRef<IFileSystem>(); using var contextFileSystem = new SharedRef<IFileSystem>();
Result rc = _multiCommitInterface.Get.OpenMultiCommitContext(ref contextFileSystem.Ref()); Result res = _multiCommitInterface.Get.OpenMultiCommitContext(ref contextFileSystem.Ref());
if (rc.IsFailure()) if (res.IsFailure())
{ {
if (!ResultFs.TargetNotFound.Includes(rc)) if (!ResultFs.TargetNotFound.Includes(res))
return rc; return res;
rc = _fsServer.Hos.Fs.CreateSystemSaveData(SaveDataId, SaveDataSize, SaveJournalSize, SaveDataFlags.None); res = _fsServer.Hos.Fs.CreateSystemSaveData(SaveDataId, SaveDataSize, SaveJournalSize, SaveDataFlags.None);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
return Result.Success; return Result.Success;
@ -128,8 +128,8 @@ internal class MultiCommitManager : IMultiCommitManager
return ResultFs.MultiCommitFileSystemLimit.Log(); return ResultFs.MultiCommitFileSystemLimit.Log();
using var fsaFileSystem = new SharedRef<IFileSystem>(); using var fsaFileSystem = new SharedRef<IFileSystem>();
Result rc = fileSystem.Get.GetImpl(ref fsaFileSystem.Ref()); Result res = fileSystem.Get.GetImpl(ref fsaFileSystem.Ref());
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Check that the file system hasn't already been added // Check that the file system hasn't already been added
for (int i = 0; i < _fileSystemCount; i++) for (int i = 0; i < _fileSystemCount; i++)
@ -155,20 +155,20 @@ internal class MultiCommitManager : IMultiCommitManager
_counter = 1; _counter = 1;
using var contextUpdater = new ContextUpdater(contextFileSystem); using var contextUpdater = new ContextUpdater(contextFileSystem);
Result rc = contextUpdater.Create(_counter, _fileSystemCount); Result res = contextUpdater.Create(_counter, _fileSystemCount);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = CommitProvisionallyFileSystem(_counter); res = CommitProvisionallyFileSystem(_counter);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = contextUpdater.CommitProvisionallyDone(); res = contextUpdater.CommitProvisionallyDone();
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = CommitFileSystem(); res = CommitFileSystem();
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = contextUpdater.CommitDone(); res = contextUpdater.CommitDone();
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -182,11 +182,11 @@ internal class MultiCommitManager : IMultiCommitManager
using ScopedLock<SdkMutexType> scopedLock = ScopedLock.Lock(ref Globals.MultiCommitMutex); using ScopedLock<SdkMutexType> scopedLock = ScopedLock.Lock(ref Globals.MultiCommitMutex);
using var contextFileSystem = new SharedRef<IFileSystem>(); using var contextFileSystem = new SharedRef<IFileSystem>();
Result rc = EnsureSaveDataForContext(); Result res = EnsureSaveDataForContext();
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _multiCommitInterface.Get.OpenMultiCommitContext(ref contextFileSystem.Ref()); res = _multiCommitInterface.Get.OpenMultiCommitContext(ref contextFileSystem.Ref());
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Commit(contextFileSystem.Get); return Commit(contextFileSystem.Get);
} }
@ -198,20 +198,20 @@ internal class MultiCommitManager : IMultiCommitManager
/// <returns>The <see cref="Result"/> of the operation.</returns> /// <returns>The <see cref="Result"/> of the operation.</returns>
private Result CommitProvisionallyFileSystem(long counter) private Result CommitProvisionallyFileSystem(long counter)
{ {
Result rc = Result.Success; Result res = Result.Success;
int i; int i;
for (i = 0; i < _fileSystemCount; i++) for (i = 0; i < _fileSystemCount; i++)
{ {
Assert.SdkNotNull(_fileSystems[i].Get); Assert.SdkNotNull(_fileSystems[i].Get);
rc = _fileSystems[i].Get.CommitProvisionally(counter); res = _fileSystems[i].Get.CommitProvisionally(counter);
if (rc.IsFailure()) if (res.IsFailure())
break; break;
} }
if (rc.IsFailure()) if (res.IsFailure())
{ {
// Rollback all provisional commits including the failed commit // Rollback all provisional commits including the failed commit
for (int j = 0; j <= i; j++) for (int j = 0; j <= i; j++)
@ -222,7 +222,7 @@ internal class MultiCommitManager : IMultiCommitManager
} }
} }
return rc; return res;
} }
/// <summary> /// <summary>
@ -269,17 +269,17 @@ internal class MultiCommitManager : IMultiCommitManager
IFileSystem contextFs, SaveDataFileSystemServiceImpl saveService) IFileSystem contextFs, SaveDataFileSystemServiceImpl saveService)
{ {
using var contextFilePath = new Fs.Path(); using var contextFilePath = new Fs.Path();
Result rc = PathFunctions.SetUpFixedPath(ref contextFilePath.Ref(), CommitContextFileName); Result res = PathFunctions.SetUpFixedPath(ref contextFilePath.Ref(), CommitContextFileName);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Read the multi-commit context // Read the multi-commit context
using var contextFile = new UniqueRef<IFile>(); using var contextFile = new UniqueRef<IFile>();
rc = contextFs.OpenFile(ref contextFile.Ref(), in contextFilePath, OpenMode.ReadWrite); res = contextFs.OpenFile(ref contextFile.Ref(), in contextFilePath, OpenMode.ReadWrite);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
Unsafe.SkipInit(out Context context); Unsafe.SkipInit(out Context context);
rc = contextFile.Get.Read(out _, 0, SpanHelpers.AsByteSpan(ref context), ReadOption.None); res = contextFile.Get.Read(out _, 0, SpanHelpers.AsByteSpan(ref context), ReadOption.None);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Note: Nintendo doesn't check if the proper amount of bytes were read, but it // Note: Nintendo doesn't check if the proper amount of bytes were read, but it
// doesn't really matter since the context is validated. // doesn't really matter since the context is validated.
@ -301,32 +301,32 @@ internal class MultiCommitManager : IMultiCommitManager
using var reader = new SharedRef<SaveDataInfoReaderImpl>(); using var reader = new SharedRef<SaveDataInfoReaderImpl>();
using var accessor = new UniqueRef<SaveDataIndexerAccessor>(); using var accessor = new UniqueRef<SaveDataIndexerAccessor>();
rc = saveService.OpenSaveDataIndexerAccessor(ref accessor.Ref(), out _, SaveDataSpaceId.User); res = saveService.OpenSaveDataIndexerAccessor(ref accessor.Ref(), out _, SaveDataSpaceId.User);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = accessor.Get.GetInterface().OpenSaveDataInfoReader(ref reader.Ref()); res = accessor.Get.GetInterface().OpenSaveDataInfoReader(ref reader.Ref());
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Iterate through all the saves to find any provisionally committed save data // Iterate through all the saves to find any provisionally committed save data
while (true) while (true)
{ {
Unsafe.SkipInit(out SaveDataInfo info); Unsafe.SkipInit(out SaveDataInfo info);
rc = reader.Get.Read(out long readCount, OutBuffer.FromStruct(ref info)); res = reader.Get.Read(out long readCount, OutBuffer.FromStruct(ref info));
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Break once we're done iterating all save data // Break once we're done iterating all save data
if (readCount == 0) if (readCount == 0)
break; break;
rc = multiCommitInterface.IsProvisionallyCommittedSaveData(out bool isProvisionallyCommitted, res = multiCommitInterface.IsProvisionallyCommittedSaveData(out bool isProvisionallyCommitted,
in info); in info);
// Note: Multi-commits are only recovered at boot time, so some saves could be missed if there // Note: Multi-commits are only recovered at boot time, so some saves could be missed if there
// are more than MaxFileSystemCount provisionally committed saves. // are more than MaxFileSystemCount provisionally committed saves.
// In theory this shouldn't happen because a multi-commit should only be interrupted if the // In theory this shouldn't happen because a multi-commit should only be interrupted if the
// entire OS is brought down. // entire OS is brought down.
if (rc.IsSuccess() && isProvisionallyCommitted && saveCount < MaxFileSystemCount) if (res.IsSuccess() && isProvisionallyCommitted && saveCount < MaxFileSystemCount)
{ {
savesToRecover[saveCount] = info; savesToRecover[saveCount] = info;
saveCount++; saveCount++;
@ -339,11 +339,11 @@ internal class MultiCommitManager : IMultiCommitManager
// If any commits fail, the result from the first failed recovery will be returned. // If any commits fail, the result from the first failed recovery will be returned.
for (int i = 0; i < saveCount; i++) for (int i = 0; i < saveCount; i++)
{ {
rc = multiCommitInterface.RecoverProvisionallyCommittedSaveData(in savesToRecover[i], false); res = multiCommitInterface.RecoverProvisionallyCommittedSaveData(in savesToRecover[i], false);
if (rc.IsFailure() && !recoveryResult.IsFailure()) if (res.IsFailure() && !recoveryResult.IsFailure())
{ {
recoveryResult = rc; recoveryResult = res;
} }
} }
@ -369,9 +369,9 @@ internal class MultiCommitManager : IMultiCommitManager
// Keep track of the first error that occurs during the recovery // Keep track of the first error that occurs during the recovery
Result recoveryResult = Result.Success; Result recoveryResult = Result.Success;
Result rc = RecoverCommit(multiCommitInterface, contextFs, saveService); Result res = RecoverCommit(multiCommitInterface, contextFs, saveService);
if (rc.IsFailure()) if (res.IsFailure())
{ {
// Note: Yes, the next ~50 lines are exactly the same as the code in RecoverCommit except // Note: Yes, the next ~50 lines are exactly the same as the code in RecoverCommit except
// for a single bool value. No, Nintendo doesn't split it out into its own function. // for a single bool value. No, Nintendo doesn't split it out into its own function.
@ -382,32 +382,32 @@ internal class MultiCommitManager : IMultiCommitManager
using var reader = new SharedRef<SaveDataInfoReaderImpl>(); using var reader = new SharedRef<SaveDataInfoReaderImpl>();
using var accessor = new UniqueRef<SaveDataIndexerAccessor>(); using var accessor = new UniqueRef<SaveDataIndexerAccessor>();
rc = saveService.OpenSaveDataIndexerAccessor(ref accessor.Ref(), out _, SaveDataSpaceId.User); res = saveService.OpenSaveDataIndexerAccessor(ref accessor.Ref(), out _, SaveDataSpaceId.User);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = accessor.Get.GetInterface().OpenSaveDataInfoReader(ref reader.Ref()); res = accessor.Get.GetInterface().OpenSaveDataInfoReader(ref reader.Ref());
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Iterate through all the saves to find any provisionally committed save data // Iterate through all the saves to find any provisionally committed save data
while (true) while (true)
{ {
Unsafe.SkipInit(out SaveDataInfo info); Unsafe.SkipInit(out SaveDataInfo info);
rc = reader.Get.Read(out long readCount, OutBuffer.FromStruct(ref info)); res = reader.Get.Read(out long readCount, OutBuffer.FromStruct(ref info));
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Break once we're done iterating all save data // Break once we're done iterating all save data
if (readCount == 0) if (readCount == 0)
break; break;
rc = multiCommitInterface.IsProvisionallyCommittedSaveData(out bool isProvisionallyCommitted, res = multiCommitInterface.IsProvisionallyCommittedSaveData(out bool isProvisionallyCommitted,
in info); in info);
// Note: Multi-commits are only recovered at boot time, so some saves could be missed if there // Note: Multi-commits are only recovered at boot time, so some saves could be missed if there
// are more than MaxFileSystemCount provisionally committed saves. // are more than MaxFileSystemCount provisionally committed saves.
// In theory this shouldn't happen because a multi-commit should only be interrupted if the // In theory this shouldn't happen because a multi-commit should only be interrupted if the
// entire OS is brought down. // entire OS is brought down.
if (rc.IsSuccess() && isProvisionallyCommitted && saveCount < MaxFileSystemCount) if (res.IsSuccess() && isProvisionallyCommitted && saveCount < MaxFileSystemCount)
{ {
savesToRecover[saveCount] = info; savesToRecover[saveCount] = info;
saveCount++; saveCount++;
@ -420,25 +420,25 @@ internal class MultiCommitManager : IMultiCommitManager
// If any commits fail, the result from the first failed recovery will be returned. // If any commits fail, the result from the first failed recovery will be returned.
for (int i = 0; i < saveCount; i++) for (int i = 0; i < saveCount; i++)
{ {
rc = multiCommitInterface.RecoverProvisionallyCommittedSaveData(in savesToRecover[i], true); res = multiCommitInterface.RecoverProvisionallyCommittedSaveData(in savesToRecover[i], true);
if (rc.IsFailure() && !recoveryResult.IsFailure()) if (res.IsFailure() && !recoveryResult.IsFailure())
{ {
recoveryResult = rc; recoveryResult = res;
} }
} }
} }
using var contextFilePath = new Fs.Path(); using var contextFilePath = new Fs.Path();
rc = PathFunctions.SetUpFixedPath(ref contextFilePath.Ref(), CommitContextFileName); res = PathFunctions.SetUpFixedPath(ref contextFilePath.Ref(), CommitContextFileName);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Delete the commit context file // Delete the commit context file
rc = contextFs.DeleteFile(in contextFilePath); res = contextFs.DeleteFile(in contextFilePath);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = contextFs.Commit(); res = contextFs.Commit();
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return recoveryResult; return recoveryResult;
} }
@ -462,12 +462,12 @@ internal class MultiCommitManager : IMultiCommitManager
using var fileSystem = new SharedRef<IFileSystem>(); using var fileSystem = new SharedRef<IFileSystem>();
// Check if a multi-commit was interrupted by checking if there's a commit context file. // Check if a multi-commit was interrupted by checking if there's a commit context file.
Result rc = multiCommitInterface.OpenMultiCommitContext(ref fileSystem.Ref()); Result res = multiCommitInterface.OpenMultiCommitContext(ref fileSystem.Ref());
if (rc.IsFailure()) if (res.IsFailure())
{ {
if (!ResultFs.PathNotFound.Includes(rc) && !ResultFs.TargetNotFound.Includes(rc)) if (!ResultFs.PathNotFound.Includes(res) && !ResultFs.TargetNotFound.Includes(res))
return rc; return res;
// Unable to open the multi-commit context file system, so there's nothing to recover // Unable to open the multi-commit context file system, so there's nothing to recover
needsRecovery = false; needsRecovery = false;
@ -476,16 +476,16 @@ internal class MultiCommitManager : IMultiCommitManager
if (needsRecovery) if (needsRecovery)
{ {
using var contextFilePath = new Fs.Path(); using var contextFilePath = new Fs.Path();
rc = PathFunctions.SetUpFixedPath(ref contextFilePath.Ref(), CommitContextFileName); res = PathFunctions.SetUpFixedPath(ref contextFilePath.Ref(), CommitContextFileName);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var file = new UniqueRef<IFile>(); using var file = new UniqueRef<IFile>();
rc = fileSystem.Get.OpenFile(ref file.Ref(), in contextFilePath, OpenMode.Read); res = fileSystem.Get.OpenFile(ref file.Ref(), in contextFilePath, OpenMode.Read);
if (rc.IsFailure()) if (res.IsFailure())
{ {
// Unable to open the context file. No multi-commit to recover. // Unable to open the context file. No multi-commit to recover.
if (ResultFs.PathNotFound.Includes(rc)) if (ResultFs.PathNotFound.Includes(res))
needsRecovery = false; needsRecovery = false;
} }
} }
@ -547,31 +547,31 @@ internal class MultiCommitManager : IMultiCommitManager
public Result Create(long counter, int fileSystemCount) public Result Create(long counter, int fileSystemCount)
{ {
using var contextFilePath = new Fs.Path(); using var contextFilePath = new Fs.Path();
Result rc = PathFunctions.SetUpFixedPath(ref contextFilePath.Ref(), CommitContextFileName); Result res = PathFunctions.SetUpFixedPath(ref contextFilePath.Ref(), CommitContextFileName);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Open context file and create if it doesn't exist // Open context file and create if it doesn't exist
using (var contextFile = new UniqueRef<IFile>()) using (var contextFile = new UniqueRef<IFile>())
{ {
rc = _fileSystem.OpenFile(ref contextFile.Ref(), in contextFilePath, OpenMode.Read); res = _fileSystem.OpenFile(ref contextFile.Ref(), in contextFilePath, OpenMode.Read);
if (rc.IsFailure()) if (res.IsFailure())
{ {
if (!ResultFs.PathNotFound.Includes(rc)) if (!ResultFs.PathNotFound.Includes(res))
return rc; return res;
rc = _fileSystem.CreateFile(in contextFilePath, CommitContextFileSize); res = _fileSystem.CreateFile(in contextFilePath, CommitContextFileSize);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _fileSystem.OpenFile(ref contextFile.Ref(), in contextFilePath, OpenMode.Read); res = _fileSystem.OpenFile(ref contextFile.Ref(), in contextFilePath, OpenMode.Read);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
} }
using (var contextFile = new UniqueRef<IFile>()) using (var contextFile = new UniqueRef<IFile>())
{ {
rc = _fileSystem.OpenFile(ref contextFile.Ref(), in contextFilePath, OpenMode.ReadWrite); res = _fileSystem.OpenFile(ref contextFile.Ref(), in contextFilePath, OpenMode.ReadWrite);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
_context.Version = CurrentCommitContextVersion; _context.Version = CurrentCommitContextVersion;
_context.State = CommitState.NotCommitted; _context.State = CommitState.NotCommitted;
@ -579,15 +579,15 @@ internal class MultiCommitManager : IMultiCommitManager
_context.Counter = counter; _context.Counter = counter;
// Write the initial context to the file // Write the initial context to the file
rc = contextFile.Get.Write(0, SpanHelpers.AsByteSpan(ref _context), WriteOption.None); res = contextFile.Get.Write(0, SpanHelpers.AsByteSpan(ref _context), WriteOption.None);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = contextFile.Get.Flush(); res = contextFile.Get.Flush();
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
rc = _fileSystem.Commit(); res = _fileSystem.Commit();
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -601,20 +601,20 @@ internal class MultiCommitManager : IMultiCommitManager
{ {
using (var contextFilePath = new Fs.Path()) using (var contextFilePath = new Fs.Path())
{ {
Result rc = PathFunctions.SetUpFixedPath(ref contextFilePath.Ref(), CommitContextFileName); Result res = PathFunctions.SetUpFixedPath(ref contextFilePath.Ref(), CommitContextFileName);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var contextFile = new UniqueRef<IFile>(); using var contextFile = new UniqueRef<IFile>();
rc = _fileSystem.OpenFile(ref contextFile.Ref(), in contextFilePath, OpenMode.ReadWrite); res = _fileSystem.OpenFile(ref contextFile.Ref(), in contextFilePath, OpenMode.ReadWrite);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
_context.State = CommitState.ProvisionallyCommitted; _context.State = CommitState.ProvisionallyCommitted;
rc = contextFile.Get.Write(0, SpanHelpers.AsByteSpan(ref _context), WriteOption.None); res = contextFile.Get.Write(0, SpanHelpers.AsByteSpan(ref _context), WriteOption.None);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = contextFile.Get.Flush(); res = contextFile.Get.Flush();
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
return _fileSystem.Commit(); return _fileSystem.Commit();
@ -627,14 +627,14 @@ internal class MultiCommitManager : IMultiCommitManager
public Result CommitDone() public Result CommitDone()
{ {
using var contextFilePath = new Fs.Path(); using var contextFilePath = new Fs.Path();
Result rc = PathFunctions.SetUpFixedPath(ref contextFilePath.Ref(), CommitContextFileName); Result res = PathFunctions.SetUpFixedPath(ref contextFilePath.Ref(), CommitContextFileName);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _fileSystem.DeleteFile(in contextFilePath); res = _fileSystem.DeleteFile(in contextFilePath);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _fileSystem.Commit(); res = _fileSystem.Commit();
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
_fileSystem = null; _fileSystem = null;
return Result.Success; return Result.Success;

View File

@ -137,8 +137,8 @@ public class SaveDataFileSystemCacheManager : IDisposable
} }
else else
{ {
Result rc = fileSystem.Get.RollbackOnlyModified(); Result res = fileSystem.Get.RollbackOnlyModified();
if (rc.IsSuccess()) if (res.IsSuccess())
{ {
using ScopedLock<SdkRecursiveMutexType> scopedLock = ScopedLock.Lock(ref _mutex); using ScopedLock<SdkRecursiveMutexType> scopedLock = ScopedLock.Lock(ref _mutex);

View File

@ -39,18 +39,18 @@ public class StorageInterfaceAdapter : IStorageSf
if (destination.Size < size) if (destination.Size < size)
return ResultFs.InvalidSize.Log(); return ResultFs.InvalidSize.Log();
Result rc = Result.Success; Result res = Result.Success;
for (int tryNum = 0; tryNum < maxTryCount; tryNum++) for (int tryNum = 0; tryNum < maxTryCount; tryNum++)
{ {
rc = _baseStorage.Get.Read(offset, destination.Buffer.Slice(0, (int)size)); res = _baseStorage.Get.Read(offset, destination.Buffer.Slice(0, (int)size));
// Retry on ResultDataCorrupted // Retry on ResultDataCorrupted
if (!ResultFs.DataCorrupted.Includes(rc)) if (!ResultFs.DataCorrupted.Includes(res))
break; break;
} }
return rc; return res;
} }
public Result Write(long offset, InBuffer source, long size) public Result Write(long offset, InBuffer source, long size)
@ -94,17 +94,17 @@ public class StorageInterfaceAdapter : IStorageSf
{ {
Unsafe.SkipInit(out QueryRangeInfo info); Unsafe.SkipInit(out QueryRangeInfo info);
Result rc = _baseStorage.Get.OperateRange(SpanHelpers.AsByteSpan(ref info), OperationId.QueryRange, Result res = _baseStorage.Get.OperateRange(SpanHelpers.AsByteSpan(ref info), OperationId.QueryRange,
offset, size, ReadOnlySpan<byte>.Empty); offset, size, ReadOnlySpan<byte>.Empty);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rangeInfo.Merge(in info); rangeInfo.Merge(in info);
} }
else if (operationId == (int)OperationId.InvalidateCache) else if (operationId == (int)OperationId.InvalidateCache)
{ {
Result rc = _baseStorage.Get.OperateRange(Span<byte>.Empty, OperationId.InvalidateCache, offset, size, Result res = _baseStorage.Get.OperateRange(Span<byte>.Empty, OperationId.InvalidateCache, offset, size,
ReadOnlySpan<byte>.Empty); ReadOnlySpan<byte>.Empty);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
return Result.Success; return Result.Success;

View File

@ -26,8 +26,8 @@ internal static class Utility
// Check if the directory exists // Check if the directory exists
using var dir = new UniqueRef<IDirectory>(); using var dir = new UniqueRef<IDirectory>();
Result rc = baseFileSystem.Get.OpenDirectory(ref dir.Ref(), rootPath, OpenDirectoryMode.Directory); Result res = baseFileSystem.Get.OpenDirectory(ref dir.Ref(), rootPath, OpenDirectoryMode.Directory);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
dir.Reset(); dir.Reset();
@ -35,8 +35,8 @@ internal static class Utility
if (!fs.HasValue) if (!fs.HasValue)
return ResultFs.AllocationMemoryFailedInSubDirectoryFileSystemCreatorA.Log(); return ResultFs.AllocationMemoryFailedInSubDirectoryFileSystemCreatorA.Log();
rc = fs.Get.Initialize(in rootPath); res = fs.Get.Initialize(in rootPath);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
outSubDirFileSystem.SetByMove(ref fs.Ref()); outSubDirFileSystem.SetByMove(ref fs.Ref());
@ -54,8 +54,8 @@ internal static class Utility
} }
// Ensure the path exists or check if it's a directory // Ensure the path exists or check if it's a directory
Result rc = FsSystem.Utility.EnsureDirectory(baseFileSystem.Get, in rootPath); Result res = FsSystem.Utility.EnsureDirectory(baseFileSystem.Get, in rootPath);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return CreateSubDirectoryFileSystem(ref outFileSystem, ref baseFileSystem, rootPath); return CreateSubDirectoryFileSystem(ref outFileSystem, ref baseFileSystem, rootPath);
} }

View File

@ -77,8 +77,8 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
using var scopedContext = new ScopedStorageLayoutTypeSetter(storageFlag); using var scopedContext = new ScopedStorageLayoutTypeSetter(storageFlag);
// Get the program info for the caller and verify permissions // Get the program info for the caller and verify permissions
Result rc = GetProgramInfo(out ProgramInfo callerProgramInfo); Result res = GetProgramInfo(out ProgramInfo callerProgramInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (fsType != FileSystemProxyType.Manual) if (fsType != FileSystemProxyType.Manual)
{ {
@ -102,8 +102,8 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
// Get the program info for the owner of the file system being opened // Get the program info for the owner of the file system being opened
rc = GetProgramInfoByProgramId(out ProgramInfo ownerProgramInfo, programId.Value); res = GetProgramInfoByProgramId(out ProgramInfo ownerProgramInfo, programId.Value);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Try to find the path to the original version of the file system // Try to find the path to the original version of the file system
using var originalPath = new Path(); using var originalPath = new Path();
@ -127,9 +127,9 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
return originalResult; return originalResult;
// There is an original version and no patch version. Open the original directly // There is an original version and no patch version. Open the original directly
rc = _serviceImpl.OpenFileSystem(ref fileSystem.Ref(), in originalPath, fsType, programId.Value, res = _serviceImpl.OpenFileSystem(ref fileSystem.Ref(), in originalPath, fsType, programId.Value,
isDirectory); isDirectory);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
else else
{ {
@ -141,9 +141,9 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
: ref PathExtensions.GetNullRef(); : ref PathExtensions.GetNullRef();
// Open the file system using both the original and patch versions // Open the file system using both the original and patch versions
rc = _serviceImpl.OpenFileSystemWithPatch(ref fileSystem.Ref(), in originalNcaPath, in patchPath, res = _serviceImpl.OpenFileSystemWithPatch(ref fileSystem.Ref(), in originalNcaPath, in patchPath,
fsType, programId.Value); fsType, programId.Value);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
// Add all the file system wrappers // Add all the file system wrappers
@ -231,8 +231,8 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
const StorageLayoutType storageFlag = StorageLayoutType.All; const StorageLayoutType storageFlag = StorageLayoutType.All;
using var scopedContext = new ScopedStorageLayoutTypeSetter(storageFlag); using var scopedContext = new ScopedStorageLayoutTypeSetter(storageFlag);
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
AccessControl ac = programInfo.AccessControl; AccessControl ac = programInfo.AccessControl;
@ -278,21 +278,21 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
bool canMountSystemDataPrivate = ac.GetAccessibilityFor(AccessibilityType.MountSystemDataPrivate).CanRead; bool canMountSystemDataPrivate = ac.GetAccessibilityFor(AccessibilityType.MountSystemDataPrivate).CanRead;
using var pathNormalized = new Path(); using var pathNormalized = new Path();
rc = pathNormalized.InitializeWithReplaceUnc(path.Str); res = pathNormalized.InitializeWithReplaceUnc(path.Str);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
var pathFlags = new PathFlags(); var pathFlags = new PathFlags();
pathFlags.AllowWindowsPath(); pathFlags.AllowWindowsPath();
pathFlags.AllowMountName(); pathFlags.AllowMountName();
rc = pathNormalized.Normalize(pathFlags); res = pathNormalized.Normalize(pathFlags);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
bool isDirectory = PathUtility.IsDirectoryPath(in path); bool isDirectory = PathUtility.IsDirectoryPath(in path);
using var fileSystem = new SharedRef<IFileSystem>(); using var fileSystem = new SharedRef<IFileSystem>();
rc = _serviceImpl.OpenFileSystem(ref fileSystem.Ref(), in pathNormalized, fsType, canMountSystemDataPrivate, res = _serviceImpl.OpenFileSystem(ref fileSystem.Ref(), in pathNormalized, fsType, canMountSystemDataPrivate,
id, isDirectory); id, isDirectory);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Add all the wrappers for the file system // Add all the wrappers for the file system
using var typeSetFileSystem = using var typeSetFileSystem =
@ -321,17 +321,17 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
public Result OpenDataFileSystemWithProgramIndex(ref SharedRef<IFileSystemSf> outFileSystem, byte programIndex) public Result OpenDataFileSystemWithProgramIndex(ref SharedRef<IFileSystemSf> outFileSystem, byte programIndex)
{ {
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Get the program ID of the program with the specified index if in a multi-program application // Get the program ID of the program with the specified index if in a multi-program application
rc = _serviceImpl.ResolveRomReferenceProgramId(out ProgramId targetProgramId, programInfo.ProgramId, res = _serviceImpl.ResolveRomReferenceProgramId(out ProgramId targetProgramId, programInfo.ProgramId,
programIndex); programIndex);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var fileSystem = new SharedRef<IFileSystem>(); using var fileSystem = new SharedRef<IFileSystem>();
rc = OpenDataFileSystemCore(ref fileSystem.Ref(), out _, targetProgramId.Value, programInfo.StorageId); res = OpenDataFileSystemCore(ref fileSystem.Ref(), out _, targetProgramId.Value, programInfo.StorageId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Verify the caller has access to the file system // Verify the caller has access to the file system
if (targetProgramId != programInfo.ProgramId && if (targetProgramId != programInfo.ProgramId &&
@ -363,21 +363,21 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
using var scopedContext = new ScopedStorageLayoutTypeSetter(StorageLayoutType.All); using var scopedContext = new ScopedStorageLayoutTypeSetter(StorageLayoutType.All);
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!programInfo.AccessControl.CanCall(OperationType.GetRightsId)) if (!programInfo.AccessControl.CanCall(OperationType.GetRightsId))
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
using var programPath = new Path(); using var programPath = new Path();
rc = _serviceImpl.ResolveProgramPath(out bool isDirectory, ref programPath.Ref(), programId, storageId); res = _serviceImpl.ResolveProgramPath(out bool isDirectory, ref programPath.Ref(), programId, storageId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (isDirectory) if (isDirectory)
return ResultFs.TargetNotFound.Log(); return ResultFs.TargetNotFound.Log();
rc = _serviceImpl.GetRightsId(out RightsId rightsId, out _, in programPath, programId); res = _serviceImpl.GetRightsId(out RightsId rightsId, out _, in programPath, programId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
outRightsId = rightsId; outRightsId = rightsId;
@ -391,28 +391,28 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
using var scopedContext = new ScopedStorageLayoutTypeSetter(StorageLayoutType.All); using var scopedContext = new ScopedStorageLayoutTypeSetter(StorageLayoutType.All);
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!programInfo.AccessControl.CanCall(OperationType.GetRightsId)) if (!programInfo.AccessControl.CanCall(OperationType.GetRightsId))
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
using var pathNormalized = new Path(); using var pathNormalized = new Path();
rc = pathNormalized.Initialize(path.Str); res = pathNormalized.Initialize(path.Str);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
var pathFlags = new PathFlags(); var pathFlags = new PathFlags();
pathFlags.AllowWindowsPath(); pathFlags.AllowWindowsPath();
pathFlags.AllowMountName(); pathFlags.AllowMountName();
rc = pathNormalized.Normalize(pathFlags); res = pathNormalized.Normalize(pathFlags);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (PathUtility.IsDirectoryPath(in path)) if (PathUtility.IsDirectoryPath(in path))
return ResultFs.TargetNotFound.Log(); return ResultFs.TargetNotFound.Log();
rc = _serviceImpl.GetRightsId(out RightsId rightsId, out byte keyGeneration, in pathNormalized, res = _serviceImpl.GetRightsId(out RightsId rightsId, out byte keyGeneration, in pathNormalized,
new ProgramId(checkThroughProgramId)); new ProgramId(checkThroughProgramId));
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
outRightsId = rightsId; outRightsId = rightsId;
outKeyGeneration = keyGeneration; outKeyGeneration = keyGeneration;
@ -430,15 +430,15 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
using var scopedContext = new ScopedStorageLayoutTypeSetter(storageFlag); using var scopedContext = new ScopedStorageLayoutTypeSetter(storageFlag);
using var programPath = new Path(); using var programPath = new Path();
Result rc = _serviceImpl.ResolveRomPath(out bool isDirectory, ref programPath.Ref(), programId, storageId); Result res = _serviceImpl.ResolveRomPath(out bool isDirectory, ref programPath.Ref(), programId, storageId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
isHostFs = Utility.IsHostFsMountName(programPath.GetString()); isHostFs = Utility.IsHostFsMountName(programPath.GetString());
using var fileSystem = new SharedRef<IFileSystem>(); using var fileSystem = new SharedRef<IFileSystem>();
rc = _serviceImpl.OpenDataFileSystem(ref fileSystem.Ref(), in programPath, FileSystemProxyType.Rom, res = _serviceImpl.OpenDataFileSystem(ref fileSystem.Ref(), in programPath, FileSystemProxyType.Rom,
programId, isDirectory); programId, isDirectory);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Add all the file system wrappers // Add all the file system wrappers
using var typeSetFileSystem = using var typeSetFileSystem =
@ -455,8 +455,8 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
StorageLayoutType storageFlag = contentStorageId == ContentStorageId.System ? StorageLayoutType.Bis : StorageLayoutType.All; StorageLayoutType storageFlag = contentStorageId == ContentStorageId.System ? StorageLayoutType.Bis : StorageLayoutType.All;
using var scopedLayoutType = new ScopedStorageLayoutTypeSetter(storageFlag); using var scopedLayoutType = new ScopedStorageLayoutTypeSetter(storageFlag);
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
Accessibility accessibility = Accessibility accessibility =
programInfo.AccessControl.GetAccessibilityFor(AccessibilityType.MountContentStorage); programInfo.AccessControl.GetAccessibilityFor(AccessibilityType.MountContentStorage);
@ -465,8 +465,8 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
using var fileSystem = new SharedRef<IFileSystem>(); using var fileSystem = new SharedRef<IFileSystem>();
rc = _serviceImpl.OpenContentStorageFileSystem(ref fileSystem.Ref(), contentStorageId); res = _serviceImpl.OpenContentStorageFileSystem(ref fileSystem.Ref(), contentStorageId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Add all the file system wrappers // Add all the file system wrappers
using var typeSetFileSystem = using var typeSetFileSystem =
@ -485,8 +485,8 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
public Result RegisterExternalKey(in RightsId rightsId, in AccessKey accessKey) public Result RegisterExternalKey(in RightsId rightsId, in AccessKey accessKey)
{ {
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!programInfo.AccessControl.CanCall(OperationType.RegisterExternalKey)) if (!programInfo.AccessControl.CanCall(OperationType.RegisterExternalKey))
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
@ -496,8 +496,8 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
public Result UnregisterExternalKey(in RightsId rightsId) public Result UnregisterExternalKey(in RightsId rightsId)
{ {
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!programInfo.AccessControl.CanCall(OperationType.RegisterExternalKey)) if (!programInfo.AccessControl.CanCall(OperationType.RegisterExternalKey))
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
@ -507,8 +507,8 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
public Result UnregisterAllExternalKey() public Result UnregisterAllExternalKey()
{ {
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!programInfo.AccessControl.CanCall(OperationType.RegisterExternalKey)) if (!programInfo.AccessControl.CanCall(OperationType.RegisterExternalKey))
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
@ -518,8 +518,8 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
public Result RegisterUpdatePartition() public Result RegisterUpdatePartition()
{ {
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!programInfo.AccessControl.CanCall(OperationType.RegisterUpdatePartition)) if (!programInfo.AccessControl.CanCall(OperationType.RegisterUpdatePartition))
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
@ -527,8 +527,8 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
ulong targetProgramId = programInfo.ProgramIdValue; ulong targetProgramId = programInfo.ProgramIdValue;
using var programPath = new Path(); using var programPath = new Path();
rc = _serviceImpl.ResolveRomPath(out _, ref programPath.Ref(), targetProgramId, programInfo.StorageId); res = _serviceImpl.ResolveRomPath(out _, ref programPath.Ref(), targetProgramId, programInfo.StorageId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return _serviceImpl.RegisterUpdatePartition(targetProgramId, in programPath); return _serviceImpl.RegisterUpdatePartition(targetProgramId, in programPath);
} }
@ -538,8 +538,8 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
var storageFlag = StorageLayoutType.All; var storageFlag = StorageLayoutType.All;
using var scopedLayoutType = new ScopedStorageLayoutTypeSetter(storageFlag); using var scopedLayoutType = new ScopedStorageLayoutTypeSetter(storageFlag);
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
Accessibility accessibility = Accessibility accessibility =
programInfo.AccessControl.GetAccessibilityFor(AccessibilityType.MountRegisteredUpdatePartition); programInfo.AccessControl.GetAccessibilityFor(AccessibilityType.MountRegisteredUpdatePartition);
@ -547,8 +547,8 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
using var fileSystem = new SharedRef<IFileSystem>(); using var fileSystem = new SharedRef<IFileSystem>();
rc = _serviceImpl.OpenRegisteredUpdatePartition(ref fileSystem.Ref()); res = _serviceImpl.OpenRegisteredUpdatePartition(ref fileSystem.Ref());
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Add all the file system wrappers // Add all the file system wrappers
using var typeSetFileSystem = using var typeSetFileSystem =
@ -572,8 +572,8 @@ internal class NcaFileSystemService : IRomFileSystemAccessFailureManager
public Result SetSdCardEncryptionSeed(in EncryptionSeed encryptionSeed) public Result SetSdCardEncryptionSeed(in EncryptionSeed encryptionSeed)
{ {
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result res = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!programInfo.AccessControl.CanCall(OperationType.SetEncryptionSeed)) if (!programInfo.AccessControl.CanCall(OperationType.SetEncryptionSeed))
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();

View File

@ -94,9 +94,9 @@ public class NcaFileSystemServiceImpl
// Open the root filesystem based on the path's mount name // Open the root filesystem based on the path's mount name
using var baseFileSystem = new SharedRef<IFileSystem>(); using var baseFileSystem = new SharedRef<IFileSystem>();
Result rc = ParseMountName(ref currentPath, ref baseFileSystem.Ref(), out bool shouldContinue, Result res = ParseMountName(ref currentPath, ref baseFileSystem.Ref(), out bool shouldContinue,
out MountInfo mountNameInfo); out MountInfo mountNameInfo);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Don't continue if the rest of the path is empty // Don't continue if the rest of the path is empty
if (!shouldContinue) if (!shouldContinue)
@ -104,18 +104,18 @@ public class NcaFileSystemServiceImpl
if (type == FileSystemProxyType.Logo && mountNameInfo.IsGameCard) if (type == FileSystemProxyType.Logo && mountNameInfo.IsGameCard)
{ {
rc = _config.BaseFsService.OpenGameCardFileSystem(ref outFileSystem, (uint)mountNameInfo.GcHandle, res = _config.BaseFsService.OpenGameCardFileSystem(ref outFileSystem, (uint)mountNameInfo.GcHandle,
GameCardPartition.Logo); GameCardPartition.Logo);
if (rc.IsSuccess()) if (res.IsSuccess())
return Result.Success; return Result.Success;
if (!ResultFs.PartitionNotFound.Includes(rc)) if (!ResultFs.PartitionNotFound.Includes(res))
return rc; return res;
} }
rc = CheckDirOrNcaOrNsp(ref currentPath, out isDirectory); res = CheckDirOrNcaOrNsp(ref currentPath, out isDirectory);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (isDirectory) if (isDirectory)
{ {
@ -123,17 +123,17 @@ public class NcaFileSystemServiceImpl
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
using var directoryPath = new Path(); using var directoryPath = new Path();
rc = directoryPath.InitializeWithNormalization(currentPath.Value); res = directoryPath.InitializeWithNormalization(currentPath.Value);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (type == FileSystemProxyType.Manual) if (type == FileSystemProxyType.Manual)
{ {
using var hostFileSystem = new SharedRef<IFileSystem>(); using var hostFileSystem = new SharedRef<IFileSystem>();
using var readOnlyFileSystem = new SharedRef<IFileSystem>(); using var readOnlyFileSystem = new SharedRef<IFileSystem>();
rc = ParseDirWithPathCaseNormalizationOnCaseSensitiveHostFs(ref hostFileSystem.Ref(), res = ParseDirWithPathCaseNormalizationOnCaseSensitiveHostFs(ref hostFileSystem.Ref(),
in directoryPath); in directoryPath);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
readOnlyFileSystem.Reset(new ReadOnlyFileSystem(ref hostFileSystem.Ref())); readOnlyFileSystem.Reset(new ReadOnlyFileSystem(ref hostFileSystem.Ref()));
outFileSystem.SetByMove(ref readOnlyFileSystem.Ref()); outFileSystem.SetByMove(ref readOnlyFileSystem.Ref());
@ -146,9 +146,9 @@ public class NcaFileSystemServiceImpl
using var nspFileSystem = new SharedRef<IFileSystem>(); using var nspFileSystem = new SharedRef<IFileSystem>();
using SharedRef<IFileSystem> tempFileSystem = SharedRef<IFileSystem>.CreateCopy(in baseFileSystem); using SharedRef<IFileSystem> tempFileSystem = SharedRef<IFileSystem>.CreateCopy(in baseFileSystem);
rc = ParseNsp(ref currentPath, ref nspFileSystem.Ref(), ref baseFileSystem.Ref()); res = ParseNsp(ref currentPath, ref nspFileSystem.Ref(), ref baseFileSystem.Ref());
if (rc.IsSuccess()) if (res.IsSuccess())
{ {
// Must be the end of the path to open Application Package FS type // Must be the end of the path to open Application Package FS type
if (currentPath.Value.At(0) == 0) if (currentPath.Value.At(0) == 0)
@ -172,13 +172,13 @@ public class NcaFileSystemServiceImpl
ulong openProgramId = mountNameInfo.IsHostFs ? ulong.MaxValue : id; ulong openProgramId = mountNameInfo.IsHostFs ? ulong.MaxValue : id;
rc = ParseNca(ref currentPath, out Nca nca, ref baseFileSystem.Ref(), openProgramId); res = ParseNca(ref currentPath, out Nca nca, ref baseFileSystem.Ref(), openProgramId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var ncaSectionStorage = new SharedRef<IStorage>(); using var ncaSectionStorage = new SharedRef<IStorage>();
rc = OpenStorageByContentType(ref ncaSectionStorage.Ref(), nca, out NcaFormatType fsType, type, res = OpenStorageByContentType(ref ncaSectionStorage.Ref(), nca, out NcaFormatType fsType, type,
mountNameInfo.IsGameCard, canMountSystemDataPrivate); mountNameInfo.IsGameCard, canMountSystemDataPrivate);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
switch (fsType) switch (fsType)
{ {
@ -207,9 +207,9 @@ public class NcaFileSystemServiceImpl
in Path originalNcaPath, in Path currentNcaPath, FileSystemProxyType fsType, ulong id) in Path originalNcaPath, in Path currentNcaPath, FileSystemProxyType fsType, ulong id)
{ {
using var romFsStorage = new SharedRef<IStorage>(); using var romFsStorage = new SharedRef<IStorage>();
Result rc = OpenStorageWithPatch(ref romFsStorage.Ref(), out Unsafe.NullRef<Hash>(), in originalNcaPath, Result res = OpenStorageWithPatch(ref romFsStorage.Ref(), out Unsafe.NullRef<Hash>(), in originalNcaPath,
in currentNcaPath, fsType, id); in currentNcaPath, fsType, id);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return _config.RomFsCreator.Create(ref outFileSystem, ref romFsStorage.Ref()); return _config.RomFsCreator.Create(ref outFileSystem, ref romFsStorage.Ref());
} }
@ -218,22 +218,22 @@ public class NcaFileSystemServiceImpl
ContentStorageId contentStorageId) ContentStorageId contentStorageId)
{ {
using var fileSystem = new SharedRef<IFileSystem>(); using var fileSystem = new SharedRef<IFileSystem>();
Result rc; Result res;
// Open the appropriate base file system for the content storage ID // Open the appropriate base file system for the content storage ID
switch (contentStorageId) switch (contentStorageId)
{ {
case ContentStorageId.System: case ContentStorageId.System:
rc = _config.BaseFsService.OpenBisFileSystem(ref fileSystem.Ref(), BisPartitionId.System); res = _config.BaseFsService.OpenBisFileSystem(ref fileSystem.Ref(), BisPartitionId.System);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
break; break;
case ContentStorageId.User: case ContentStorageId.User:
rc = _config.BaseFsService.OpenBisFileSystem(ref fileSystem.Ref(), BisPartitionId.User); res = _config.BaseFsService.OpenBisFileSystem(ref fileSystem.Ref(), BisPartitionId.User);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
break; break;
case ContentStorageId.SdCard: case ContentStorageId.SdCard:
rc = _config.BaseFsService.OpenSdCardProxyFileSystem(ref fileSystem.Ref()); res = _config.BaseFsService.OpenSdCardProxyFileSystem(ref fileSystem.Ref());
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
break; break;
default: default:
return ResultFs.InvalidArgument.Log(); return ResultFs.InvalidArgument.Log();
@ -255,24 +255,24 @@ public class NcaFileSystemServiceImpl
} }
using var contentStoragePath = new Path(); using var contentStoragePath = new Path();
rc = PathFunctions.SetUpFixedPath(ref contentStoragePath.Ref(), contentStoragePathBuffer); res = PathFunctions.SetUpFixedPath(ref contentStoragePath.Ref(), contentStoragePathBuffer);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Make sure the content storage path exists // Make sure the content storage path exists
rc = Utility.EnsureDirectory(fileSystem.Get, in contentStoragePath); res = Utility.EnsureDirectory(fileSystem.Get, in contentStoragePath);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var subDirFs = new SharedRef<IFileSystem>(); using var subDirFs = new SharedRef<IFileSystem>();
rc = _config.SubDirectoryFsCreator.Create(ref subDirFs.Ref(), ref fileSystem.Ref(), in contentStoragePath); res = _config.SubDirectoryFsCreator.Create(ref subDirFs.Ref(), ref fileSystem.Ref(), in contentStoragePath);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Only content on the SD card is encrypted // Only content on the SD card is encrypted
if (contentStorageId == ContentStorageId.SdCard) if (contentStorageId == ContentStorageId.SdCard)
{ {
using SharedRef<IFileSystem> tempFileSystem = SharedRef<IFileSystem>.CreateMove(ref subDirFs.Ref()); using SharedRef<IFileSystem> tempFileSystem = SharedRef<IFileSystem>.CreateMove(ref subDirFs.Ref());
rc = _config.EncryptedFsCreator.Create(ref subDirFs.Ref(), ref tempFileSystem.Ref(), res = _config.EncryptedFsCreator.Create(ref subDirFs.Ref(), ref tempFileSystem.Ref(),
IEncryptedFileSystemCreator.KeyId.Content, in _encryptionSeed); IEncryptedFileSystemCreator.KeyId.Content, in _encryptionSeed);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
outFileSystem.SetByMove(ref subDirFs.Ref()); outFileSystem.SetByMove(ref subDirFs.Ref());
@ -351,8 +351,8 @@ public class NcaFileSystemServiceImpl
path = path.Slice(8); path = path.Slice(8);
Result rc = _config.BaseFsService.OpenGameCardFileSystem(ref outFileSystem, (uint)handle, partition); Result res = _config.BaseFsService.OpenGameCardFileSystem(ref outFileSystem, (uint)handle, partition);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
info.GcHandle = handle; info.GcHandle = handle;
info.IsGameCard = true; info.IsGameCard = true;
@ -364,8 +364,8 @@ public class NcaFileSystemServiceImpl
{ {
path = path.Slice(CommonPaths.ContentStorageSystemMountName.Length); path = path.Slice(CommonPaths.ContentStorageSystemMountName.Length);
Result rc = OpenContentStorageFileSystem(ref outFileSystem, ContentStorageId.System); Result res = OpenContentStorageFileSystem(ref outFileSystem, ContentStorageId.System);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
info.CanMountNca = true; info.CanMountNca = true;
} }
@ -375,8 +375,8 @@ public class NcaFileSystemServiceImpl
{ {
path = path.Slice(CommonPaths.ContentStorageUserMountName.Length); path = path.Slice(CommonPaths.ContentStorageUserMountName.Length);
Result rc = OpenContentStorageFileSystem(ref outFileSystem, ContentStorageId.User); Result res = OpenContentStorageFileSystem(ref outFileSystem, ContentStorageId.User);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
info.CanMountNca = true; info.CanMountNca = true;
} }
@ -386,8 +386,8 @@ public class NcaFileSystemServiceImpl
{ {
path = path.Slice(CommonPaths.ContentStorageSdCardMountName.Length); path = path.Slice(CommonPaths.ContentStorageSdCardMountName.Length);
Result rc = OpenContentStorageFileSystem(ref outFileSystem, ContentStorageId.SdCard); Result res = OpenContentStorageFileSystem(ref outFileSystem, ContentStorageId.SdCard);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
info.CanMountNca = true; info.CanMountNca = true;
} }
@ -397,8 +397,8 @@ public class NcaFileSystemServiceImpl
{ {
path = path.Slice(CommonPaths.BisCalibrationFilePartitionMountName.Length); path = path.Slice(CommonPaths.BisCalibrationFilePartitionMountName.Length);
Result rc = _config.BaseFsService.OpenBisFileSystem(ref outFileSystem, BisPartitionId.CalibrationFile); Result res = _config.BaseFsService.OpenBisFileSystem(ref outFileSystem, BisPartitionId.CalibrationFile);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
else if (StringUtils.Compare(path, CommonPaths.BisSafeModePartitionMountName, else if (StringUtils.Compare(path, CommonPaths.BisSafeModePartitionMountName,
@ -406,8 +406,8 @@ public class NcaFileSystemServiceImpl
{ {
path = path.Slice(CommonPaths.BisSafeModePartitionMountName.Length); path = path.Slice(CommonPaths.BisSafeModePartitionMountName.Length);
Result rc = _config.BaseFsService.OpenBisFileSystem(ref outFileSystem, BisPartitionId.SafeMode); Result res = _config.BaseFsService.OpenBisFileSystem(ref outFileSystem, BisPartitionId.SafeMode);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
else if (StringUtils.Compare(path, CommonPaths.BisUserPartitionMountName, else if (StringUtils.Compare(path, CommonPaths.BisUserPartitionMountName,
@ -415,8 +415,8 @@ public class NcaFileSystemServiceImpl
{ {
path = path.Slice(CommonPaths.BisUserPartitionMountName.Length); path = path.Slice(CommonPaths.BisUserPartitionMountName.Length);
Result rc = _config.BaseFsService.OpenBisFileSystem(ref outFileSystem, BisPartitionId.User); Result res = _config.BaseFsService.OpenBisFileSystem(ref outFileSystem, BisPartitionId.User);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
else if (StringUtils.Compare(path, CommonPaths.BisSystemPartitionMountName, else if (StringUtils.Compare(path, CommonPaths.BisSystemPartitionMountName,
@ -424,8 +424,8 @@ public class NcaFileSystemServiceImpl
{ {
path = path.Slice(CommonPaths.BisSystemPartitionMountName.Length); path = path.Slice(CommonPaths.BisSystemPartitionMountName.Length);
Result rc = _config.BaseFsService.OpenBisFileSystem(ref outFileSystem, BisPartitionId.System); Result res = _config.BaseFsService.OpenBisFileSystem(ref outFileSystem, BisPartitionId.System);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
else if (StringUtils.Compare(path, CommonPaths.SdCardFileSystemMountName, else if (StringUtils.Compare(path, CommonPaths.SdCardFileSystemMountName,
@ -433,8 +433,8 @@ public class NcaFileSystemServiceImpl
{ {
path = path.Slice(CommonPaths.SdCardFileSystemMountName.Length); path = path.Slice(CommonPaths.SdCardFileSystemMountName.Length);
Result rc = _config.BaseFsService.OpenSdCardProxyFileSystem(ref outFileSystem); Result res = _config.BaseFsService.OpenSdCardProxyFileSystem(ref outFileSystem);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
else if (StringUtils.Compare(path, CommonPaths.HostRootFileSystemMountName, else if (StringUtils.Compare(path, CommonPaths.HostRootFileSystemMountName,
@ -443,14 +443,14 @@ public class NcaFileSystemServiceImpl
path = path.Slice(CommonPaths.HostRootFileSystemMountName.Length); path = path.Slice(CommonPaths.HostRootFileSystemMountName.Length);
using var rootPathEmpty = new Path(); using var rootPathEmpty = new Path();
Result rc = rootPathEmpty.InitializeAsEmpty(); Result res = rootPathEmpty.InitializeAsEmpty();
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
info.IsHostFs = true; info.IsHostFs = true;
info.CanMountNca = true; info.CanMountNca = true;
rc = OpenHostFileSystem(ref outFileSystem, in rootPathEmpty, openCaseSensitive: false); res = OpenHostFileSystem(ref outFileSystem, in rootPathEmpty, openCaseSensitive: false);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
} }
else if (StringUtils.Compare(path, CommonPaths.RegisteredUpdatePartitionMountName, else if (StringUtils.Compare(path, CommonPaths.RegisteredUpdatePartitionMountName,
@ -519,8 +519,8 @@ public class NcaFileSystemServiceImpl
ref SharedRef<IFileSystem> baseFileSystem, FileSystemProxyType fsType, bool preserveUnc) ref SharedRef<IFileSystem> baseFileSystem, FileSystemProxyType fsType, bool preserveUnc)
{ {
using var fileSystem = new SharedRef<IFileSystem>(); using var fileSystem = new SharedRef<IFileSystem>();
Result rc = _config.SubDirectoryFsCreator.Create(ref fileSystem.Ref(), ref baseFileSystem, in path); Result res = _config.SubDirectoryFsCreator.Create(ref fileSystem.Ref(), ref baseFileSystem, in path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return ParseContentTypeForDirectory(ref outContentFileSystem, ref fileSystem.Ref(), fsType); return ParseContentTypeForDirectory(ref outContentFileSystem, ref fileSystem.Ref(), fsType);
} }
@ -531,19 +531,19 @@ public class NcaFileSystemServiceImpl
using var pathRoot = new Path(); using var pathRoot = new Path();
using var pathData = new Path(); using var pathData = new Path();
Result rc = PathFunctions.SetUpFixedPath(ref pathData.Ref(), Result res = PathFunctions.SetUpFixedPath(ref pathData.Ref(),
new[] { (byte)'/', (byte)'d', (byte)'a', (byte)'t', (byte)'a' }); new[] { (byte)'/', (byte)'d', (byte)'a', (byte)'t', (byte)'a' });
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = pathRoot.Combine(in path, in pathData); res = pathRoot.Combine(in path, in pathData);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _config.TargetManagerFsCreator.NormalizeCaseOfPath(out bool isSupported, ref pathRoot.Ref()); res = _config.TargetManagerFsCreator.NormalizeCaseOfPath(out bool isSupported, ref pathRoot.Ref());
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _config.TargetManagerFsCreator.Create(ref outFileSystem, in pathRoot, isSupported, false, res = _config.TargetManagerFsCreator.Create(ref outFileSystem, in pathRoot, isSupported, false,
Result.Success); Result.Success);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -584,23 +584,23 @@ public class NcaFileSystemServiceImpl
nspPathLen += 4; nspPathLen += 4;
using var pathNsp = new Path(); using var pathNsp = new Path();
Result rc = pathNsp.InitializeWithNormalization(path, nspPathLen); Result res = pathNsp.InitializeWithNormalization(path, nspPathLen);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using var nspFileStorage = new SharedRef<FileStorageBasedFileSystem>(new FileStorageBasedFileSystem()); using var nspFileStorage = new SharedRef<FileStorageBasedFileSystem>(new FileStorageBasedFileSystem());
rc = nspFileStorage.Get.Initialize(ref baseFileSystem, in pathNsp, OpenMode.Read); res = nspFileStorage.Get.Initialize(ref baseFileSystem, in pathNsp, OpenMode.Read);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
using SharedRef<IStorage> tempStorage = SharedRef<IStorage>.CreateMove(ref nspFileStorage.Ref()); using SharedRef<IStorage> tempStorage = SharedRef<IStorage>.CreateMove(ref nspFileStorage.Ref());
rc = _config.PartitionFsCreator.Create(ref outFileSystem, ref tempStorage.Ref()); res = _config.PartitionFsCreator.Create(ref outFileSystem, ref tempStorage.Ref());
if (rc.IsSuccess()) if (res.IsSuccess())
{ {
path = path.Slice(nspPathLen); path = path.Slice(nspPathLen);
} }
return rc; return res;
} }
private Result ParseNca(ref U8Span path, out Nca nca, ref SharedRef<IFileSystem> baseFileSystem, ulong ncaId) private Result ParseNca(ref U8Span path, out Nca nca, ref SharedRef<IFileSystem> baseFileSystem, ulong ncaId)
@ -611,14 +611,14 @@ public class NcaFileSystemServiceImpl
var ncaFileStorage = new FileStorageBasedFileSystem(); var ncaFileStorage = new FileStorageBasedFileSystem();
using var pathNca = new Path(); using var pathNca = new Path();
Result rc = pathNca.InitializeWithNormalization(path); Result res = pathNca.InitializeWithNormalization(path);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = ncaFileStorage.Initialize(ref baseFileSystem, in pathNca, OpenMode.Read); res = ncaFileStorage.Initialize(ref baseFileSystem, in pathNca, OpenMode.Read);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _config.StorageOnNcaCreator.OpenNca(out Nca ncaTemp, ncaFileStorage); res = _config.StorageOnNcaCreator.OpenNca(out Nca ncaTemp, ncaFileStorage);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (ncaId == ulong.MaxValue) if (ncaId == ulong.MaxValue)
{ {
@ -668,15 +668,15 @@ public class NcaFileSystemServiceImpl
using var subDirFs = new SharedRef<IFileSystem>(); using var subDirFs = new SharedRef<IFileSystem>();
using var directoryPath = new Path(); using var directoryPath = new Path();
Result rc = PathFunctions.SetUpFixedPath(ref directoryPath.Ref(), dirName); Result res = PathFunctions.SetUpFixedPath(ref directoryPath.Ref(), dirName);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (directoryPath.IsEmpty()) if (directoryPath.IsEmpty())
return ResultFs.InvalidArgument.Log(); return ResultFs.InvalidArgument.Log();
// Open the subdirectory filesystem // Open the subdirectory filesystem
rc = _config.SubDirectoryFsCreator.Create(ref subDirFs.Ref(), ref baseFileSystem, in directoryPath); res = _config.SubDirectoryFsCreator.Create(ref subDirFs.Ref(), ref baseFileSystem, in directoryPath);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
outFileSystem.SetByMove(ref subDirFs.Ref()); outFileSystem.SetByMove(ref subDirFs.Ref());
return Result.Success; return Result.Success;
@ -691,8 +691,8 @@ public class NcaFileSystemServiceImpl
return Result.Success; return Result.Success;
// ReSharper disable once UnusedVariable // ReSharper disable once UnusedVariable
Result rc = _externalKeyManager.Get(rightsId, out AccessKey accessKey); Result res = _externalKeyManager.Get(rightsId, out AccessKey accessKey);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// todo: Set key in nca reader // todo: Set key in nca reader
@ -747,15 +747,15 @@ public class NcaFileSystemServiceImpl
if (nca.Header.DistributionType == DistributionType.GameCard && !isGameCard) if (nca.Header.DistributionType == DistributionType.GameCard && !isGameCard)
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
Result rc = SetExternalKeyForRightsId(nca); Result res = SetExternalKeyForRightsId(nca);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = GetPartitionIndex(out int sectionIndex, fsProxyType); res = GetPartitionIndex(out int sectionIndex, fsProxyType);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
rc = _config.StorageOnNcaCreator.Create(ref outNcaStorage, out NcaFsHeader fsHeader, nca, res = _config.StorageOnNcaCreator.Create(ref outNcaStorage, out NcaFsHeader fsHeader, nca,
sectionIndex, fsProxyType == FileSystemProxyType.Code); sectionIndex, fsProxyType == FileSystemProxyType.Code);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
fsType = fsHeader.FormatType; fsType = fsHeader.FormatType;
return Result.Success; return Result.Success;
@ -783,14 +783,14 @@ public class NcaFileSystemServiceImpl
public Result ResolveProgramPath(out bool isDirectory, ref Path path, ProgramId programId, StorageId storageId) public Result ResolveProgramPath(out bool isDirectory, ref Path path, ProgramId programId, StorageId storageId)
{ {
Result rc = _locationResolverSet.ResolveProgramPath(out isDirectory, ref path, programId, storageId); Result res = _locationResolverSet.ResolveProgramPath(out isDirectory, ref path, programId, storageId);
if (rc.IsSuccess()) if (res.IsSuccess())
return Result.Success; return Result.Success;
isDirectory = false; isDirectory = false;
rc = _locationResolverSet.ResolveDataPath(ref path, new DataId(programId.Value), storageId); res = _locationResolverSet.ResolveDataPath(ref path, new DataId(programId.Value), storageId);
if (rc.IsSuccess()) if (res.IsSuccess())
return Result.Success; return Result.Success;
return ResultFs.TargetNotFound.Log(); return ResultFs.TargetNotFound.Log();

View File

@ -46,8 +46,8 @@ internal readonly struct ProgramIndexRegistryService
// Verify the caller's permissions // Verify the caller's permissions
using (var programRegistry = new ProgramRegistryImpl(_fsServer)) using (var programRegistry = new ProgramRegistryImpl(_fsServer))
{ {
Result rc = programRegistry.GetProgramInfo(out ProgramInfo programInfo, _processId); Result res = programRegistry.GetProgramInfo(out ProgramInfo programInfo, _processId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
if (!programInfo.AccessControl.CanCall(OperationType.RegisterProgramIndexMapInfo)) if (!programInfo.AccessControl.CanCall(OperationType.RegisterProgramIndexMapInfo))
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
@ -85,8 +85,8 @@ internal readonly struct ProgramIndexRegistryService
UnsafeHelpers.SkipParamInit(out programIndex, out programCount); UnsafeHelpers.SkipParamInit(out programIndex, out programCount);
// No permissions are needed to call this method // No permissions are needed to call this method
Result rc = GetProgramInfo(out ProgramInfo programInfo, _processId); Result res = GetProgramInfo(out ProgramInfo programInfo, _processId);
if (rc.IsFailure()) return rc; if (res.IsFailure()) return res.Miss();
// Try to get map info for this process // Try to get map info for this process
Optional<ProgramIndexMapInfo> mapInfo = _serviceImpl.GetProgramIndexMapInfo(programInfo.ProgramId); Optional<ProgramIndexMapInfo> mapInfo = _serviceImpl.GetProgramIndexMapInfo(programInfo.ProgramId);

File diff suppressed because it is too large Load Diff

View File

@ -100,8 +100,8 @@ public class SaveDataFileSystemServiceImpl : IDisposable
_timeStampGetter = new TimeStampGetter(this); _timeStampGetter = new TimeStampGetter(this);
Result rc = _saveFileSystemCacheManager.Initialize(_config.SaveDataFileSystemCacheCount); Result res = _saveFileSystemCacheManager.Initialize(_config.SaveDataFileSystemCacheCount);
Abort.DoAbortUnless(rc.IsSuccess()); Abort.DoAbortUnless(res.IsSuccess());
} }
public void Dispose() public void Dispose()
@ -121,31 +121,31 @@ public class SaveDataFileSystemServiceImpl : IDisposable
using var fileSystem = new SharedRef<IFileSystem>(); using var fileSystem = new SharedRef<IFileSystem>();
Result rc = OpenSaveDataDirectoryFileSystem(ref fileSystem.Ref(), spaceId); Result res = OpenSaveDataDirectoryFileSystem(ref fileSystem.Ref(), spaceId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
// Get the path of the save data // Get the path of the save data
Unsafe.SkipInit(out Array18<byte> saveImageNameBuffer); Unsafe.SkipInit(out Array18<byte> saveImageNameBuffer);
using var saveImageName = new Path(); using var saveImageName = new Path();
rc = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer.Items, saveDataId); res = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer.Items, saveDataId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = fileSystem.Get.GetEntryType(out _, in saveImageName); res = fileSystem.Get.GetEntryType(out _, in saveImageName);
if (rc.IsSuccess()) if (res.IsSuccess())
{ {
exists = true; exists = true;
return Result.Success; return Result.Success;
} }
else if (ResultFs.PathNotFound.Includes(rc)) else if (ResultFs.PathNotFound.Includes(res))
{ {
exists = false; exists = false;
return Result.Success; return Result.Success;
} }
else else
{ {
return rc.Miss(); return res.Miss();
} }
} }
@ -160,8 +160,8 @@ public class SaveDataFileSystemServiceImpl : IDisposable
{ {
using var fileSystem = new SharedRef<IFileSystem>(); using var fileSystem = new SharedRef<IFileSystem>();
Result rc = OpenSaveDataDirectoryFileSystem(ref fileSystem.Ref(), spaceId, in saveDataRootPath, true); Result res = OpenSaveDataDirectoryFileSystem(ref fileSystem.Ref(), spaceId, in saveDataRootPath, true);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
bool isEmulatedOnHost = IsAllowedDirectorySaveData(spaceId, in saveDataRootPath); bool isEmulatedOnHost = IsAllowedDirectorySaveData(spaceId, in saveDataRootPath);
@ -170,11 +170,11 @@ public class SaveDataFileSystemServiceImpl : IDisposable
// Create the save data directory on the host if needed. // Create the save data directory on the host if needed.
Unsafe.SkipInit(out Array18<byte> saveDirectoryNameBuffer); Unsafe.SkipInit(out Array18<byte> saveDirectoryNameBuffer);
using var saveDirectoryName = new Path(); using var saveDirectoryName = new Path();
rc = PathFunctions.SetUpFixedPathSaveId(ref saveDirectoryName.Ref(), saveDirectoryNameBuffer.Items, saveDataId); res = PathFunctions.SetUpFixedPathSaveId(ref saveDirectoryName.Ref(), saveDirectoryNameBuffer.Items, saveDataId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = FsSystem.Utility.EnsureDirectory(fileSystem.Get, in saveDirectoryName); res = FsSystem.Utility.EnsureDirectory(fileSystem.Get, in saveDirectoryName);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
} }
using var saveDataFs = new SharedRef<ISaveDataFileSystem>(); using var saveDataFs = new SharedRef<ISaveDataFileSystem>();
@ -190,10 +190,10 @@ public class SaveDataFileSystemServiceImpl : IDisposable
bool openShared = SaveDataProperties.IsSharedOpenNeeded(type); bool openShared = SaveDataProperties.IsSharedOpenNeeded(type);
bool isReconstructible = SaveDataProperties.IsReconstructible(type, spaceId); bool isReconstructible = SaveDataProperties.IsReconstructible(type, spaceId);
rc = _config.SaveFsCreator.Create(ref saveDataFs.Ref(), ref fileSystem.Ref(), spaceId, saveDataId, res = _config.SaveFsCreator.Create(ref saveDataFs.Ref(), ref fileSystem.Ref(), spaceId, saveDataId,
isEmulatedOnHost, isDeviceUniqueMac, isJournalingSupported, isMultiCommitSupported, isEmulatedOnHost, isDeviceUniqueMac, isJournalingSupported, isMultiCommitSupported,
openReadOnly, openShared, _timeStampGetter, isReconstructible); openReadOnly, openShared, _timeStampGetter, isReconstructible);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
} }
if (!isEmulatedOnHost && cacheExtraData) if (!isEmulatedOnHost && cacheExtraData)
@ -201,8 +201,8 @@ public class SaveDataFileSystemServiceImpl : IDisposable
using SharedRef<ISaveDataExtraDataAccessor> extraDataAccessor = using SharedRef<ISaveDataExtraDataAccessor> extraDataAccessor =
SharedRef<ISaveDataExtraDataAccessor>.CreateCopy(in saveDataFs); SharedRef<ISaveDataExtraDataAccessor>.CreateCopy(in saveDataFs);
rc = _saveExtraDataCacheManager.Register(in extraDataAccessor, spaceId, saveDataId); res = _saveExtraDataCacheManager.Register(in extraDataAccessor, spaceId, saveDataId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
} }
} }
@ -233,9 +233,9 @@ public class SaveDataFileSystemServiceImpl : IDisposable
Unsafe.SkipInit(out Array27<byte> saveDataMetaIdDirectoryNameBuffer); Unsafe.SkipInit(out Array27<byte> saveDataMetaIdDirectoryNameBuffer);
using var saveDataMetaIdDirectoryName = new Path(); using var saveDataMetaIdDirectoryName = new Path();
Result rc = PathFunctions.SetUpFixedPathSaveMetaDir(ref saveDataMetaIdDirectoryName.Ref(), Result res = PathFunctions.SetUpFixedPathSaveMetaDir(ref saveDataMetaIdDirectoryName.Ref(),
saveDataMetaIdDirectoryNameBuffer.Items, saveDataId); saveDataMetaIdDirectoryNameBuffer.Items, saveDataId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return OpenSaveDataDirectoryFileSystemImpl(ref outFileSystem, spaceId, in saveDataMetaIdDirectoryName).Ret(); return OpenSaveDataDirectoryFileSystemImpl(ref outFileSystem, spaceId, in saveDataMetaIdDirectoryName).Ret();
} }
@ -275,9 +275,9 @@ public class SaveDataFileSystemServiceImpl : IDisposable
public Result FinishExtendSaveDataFileSystem(ulong saveDataId, SaveDataSpaceId spaceId) public Result FinishExtendSaveDataFileSystem(ulong saveDataId, SaveDataSpaceId spaceId)
{ {
Result rc = DeleteSaveDataMeta(saveDataId, spaceId, SaveDataMetaType.ExtensionContext); Result res = DeleteSaveDataMeta(saveDataId, spaceId, SaveDataMetaType.ExtensionContext);
if (rc.IsFailure() && !ResultFs.PathNotFound.Includes(rc)) if (res.IsFailure() && !ResultFs.PathNotFound.Includes(res))
return rc.Miss(); return res.Miss();
return Result.Success; return Result.Success;
} }
@ -286,9 +286,9 @@ public class SaveDataFileSystemServiceImpl : IDisposable
in Path saveDataRootPath) in Path saveDataRootPath)
{ {
using var saveDataFile = new UniqueRef<IFile>(); using var saveDataFile = new UniqueRef<IFile>();
Result rc = OpenSaveDataImageFile(ref saveDataFile.Ref(), spaceId, saveDataId, in saveDataRootPath); Result res = OpenSaveDataImageFile(ref saveDataFile.Ref(), spaceId, saveDataId, in saveDataRootPath);
if (rc.IsSuccess()) if (res.IsSuccess())
{ {
saveDataFile.Get.SetSize(originalSize).IgnoreResult(); saveDataFile.Get.SetSize(originalSize).IgnoreResult();
} }
@ -308,18 +308,18 @@ public class SaveDataFileSystemServiceImpl : IDisposable
{ {
using var fileSystem = new SharedRef<IFileSystem>(); using var fileSystem = new SharedRef<IFileSystem>();
Result rc = OpenSaveDataMetaDirectoryFileSystem(ref fileSystem.Ref(), spaceId, saveDataId); Result res = OpenSaveDataMetaDirectoryFileSystem(ref fileSystem.Ref(), spaceId, saveDataId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
Unsafe.SkipInit(out Array15<byte> saveDataMetaNameBuffer); Unsafe.SkipInit(out Array15<byte> saveDataMetaNameBuffer);
using var saveDataMetaName = new Path(); using var saveDataMetaName = new Path();
rc = PathFunctions.SetUpFixedPathSaveMetaName(ref saveDataMetaName.Ref(), saveDataMetaNameBuffer.Items, res = PathFunctions.SetUpFixedPathSaveMetaName(ref saveDataMetaName.Ref(), saveDataMetaNameBuffer.Items,
(uint)metaType); (uint)metaType);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = fileSystem.Get.CreateFile(in saveDataMetaName, metaFileSize); res = fileSystem.Get.CreateFile(in saveDataMetaName, metaFileSize);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -328,18 +328,18 @@ public class SaveDataFileSystemServiceImpl : IDisposable
{ {
using var fileSystem = new SharedRef<IFileSystem>(); using var fileSystem = new SharedRef<IFileSystem>();
Result rc = OpenSaveDataMetaDirectoryFileSystem(ref fileSystem.Ref(), spaceId, saveDataId); Result res = OpenSaveDataMetaDirectoryFileSystem(ref fileSystem.Ref(), spaceId, saveDataId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
Unsafe.SkipInit(out Array15<byte> saveDataMetaNameBuffer); Unsafe.SkipInit(out Array15<byte> saveDataMetaNameBuffer);
using var saveDataMetaName = new Path(); using var saveDataMetaName = new Path();
rc = PathFunctions.SetUpFixedPathSaveMetaName(ref saveDataMetaName.Ref(), saveDataMetaNameBuffer.Items, res = PathFunctions.SetUpFixedPathSaveMetaName(ref saveDataMetaName.Ref(), saveDataMetaNameBuffer.Items,
(uint)metaType); (uint)metaType);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = fileSystem.Get.DeleteFile(in saveDataMetaName); res = fileSystem.Get.DeleteFile(in saveDataMetaName);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -358,27 +358,27 @@ public class SaveDataFileSystemServiceImpl : IDisposable
using var fileSystem = new SharedRef<IFileSystem>(); using var fileSystem = new SharedRef<IFileSystem>();
using var saveDataMetaDirectoryName = new Path(); using var saveDataMetaDirectoryName = new Path();
Result rc = PathFunctions.SetUpFixedPath(ref saveDataMetaDirectoryName.Ref(), metaDirName); Result res = PathFunctions.SetUpFixedPath(ref saveDataMetaDirectoryName.Ref(), metaDirName);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = OpenSaveDataDirectoryFileSystemImpl(ref fileSystem.Ref(), spaceId, in saveDataMetaDirectoryName, res = OpenSaveDataDirectoryFileSystemImpl(ref fileSystem.Ref(), spaceId, in saveDataMetaDirectoryName,
createIfMissing: false); createIfMissing: false);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
using var saveDataIdDirectoryName = new Path(); using var saveDataIdDirectoryName = new Path();
PathFunctions.SetUpFixedPathSaveId(ref saveDataIdDirectoryName.Ref(), saveDataIdDirectoryNameBuffer.Items, PathFunctions.SetUpFixedPathSaveId(ref saveDataIdDirectoryName.Ref(), saveDataIdDirectoryNameBuffer.Items,
saveDataId); saveDataId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
// Delete the save data's meta directory, ignoring the error if the directory is already gone // Delete the save data's meta directory, ignoring the error if the directory is already gone
rc = fileSystem.Get.DeleteDirectoryRecursively(in saveDataIdDirectoryName); res = fileSystem.Get.DeleteDirectoryRecursively(in saveDataIdDirectoryName);
if (rc.IsFailure()) if (res.IsFailure())
{ {
if (ResultFs.PathNotFound.Includes(rc)) if (ResultFs.PathNotFound.Includes(res))
return Result.Success; return Result.Success;
return rc.Miss(); return res.Miss();
} }
return Result.Success; return Result.Success;
@ -389,18 +389,18 @@ public class SaveDataFileSystemServiceImpl : IDisposable
{ {
using var fileSystem = new SharedRef<IFileSystem>(); using var fileSystem = new SharedRef<IFileSystem>();
Result rc = OpenSaveDataMetaDirectoryFileSystem(ref fileSystem.Ref(), spaceId, saveDataId); Result res = OpenSaveDataMetaDirectoryFileSystem(ref fileSystem.Ref(), spaceId, saveDataId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
Unsafe.SkipInit(out Array15<byte> saveDataMetaNameBuffer); Unsafe.SkipInit(out Array15<byte> saveDataMetaNameBuffer);
using var saveDataMetaName = new Path(); using var saveDataMetaName = new Path();
rc = PathFunctions.SetUpFixedPathSaveMetaName(ref saveDataMetaName.Ref(), saveDataMetaNameBuffer.Items, res = PathFunctions.SetUpFixedPathSaveMetaName(ref saveDataMetaName.Ref(), saveDataMetaNameBuffer.Items,
(uint)metaType); (uint)metaType);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = fileSystem.Get.OpenFile(ref outMetaFile, in saveDataMetaName, OpenMode.ReadWrite); res = fileSystem.Get.OpenFile(ref outMetaFile, in saveDataMetaName, OpenMode.ReadWrite);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -418,13 +418,13 @@ public class SaveDataFileSystemServiceImpl : IDisposable
using var fileSystem = new SharedRef<IFileSystem>(); using var fileSystem = new SharedRef<IFileSystem>();
Result rc = OpenSaveDataDirectoryFileSystem(ref fileSystem.Ref(), creationInfo.SpaceId, in saveDataRootPath, Result res = OpenSaveDataDirectoryFileSystem(ref fileSystem.Ref(), creationInfo.SpaceId, in saveDataRootPath,
allowEmulatedSave: false); allowEmulatedSave: false);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
using var saveImageName = new Path(); using var saveImageName = new Path();
rc = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer.Items, saveDataId); res = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer.Items, saveDataId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
bool isPseudoSaveFs = _config.IsPseudoSaveData(); bool isPseudoSaveFs = _config.IsPseudoSaveData();
bool isCreationSuccessful = false; bool isCreationSuccessful = false;
@ -433,8 +433,8 @@ public class SaveDataFileSystemServiceImpl : IDisposable
{ {
if (isPseudoSaveFs) if (isPseudoSaveFs)
{ {
rc = FsSystem.Utility.EnsureDirectory(fileSystem.Get, in saveImageName); res = FsSystem.Utility.EnsureDirectory(fileSystem.Get, in saveImageName);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
} }
else else
{ {
@ -445,8 +445,8 @@ public class SaveDataFileSystemServiceImpl : IDisposable
extraData.Attribute = creationInfo.Attribute; extraData.Attribute = creationInfo.Attribute;
extraData.OwnerId = ownerId; extraData.OwnerId = ownerId;
rc = GetSaveDataCommitTimeStamp(out extraData.TimeStamp); res = GetSaveDataCommitTimeStamp(out extraData.TimeStamp);
if (rc.IsFailure()) if (res.IsFailure())
extraData.TimeStamp = 0; extraData.TimeStamp = 0;
extraData.CommitId = 0; extraData.CommitId = 0;
@ -457,9 +457,9 @@ public class SaveDataFileSystemServiceImpl : IDisposable
extraData.JournalSize = journalSize; extraData.JournalSize = journalSize;
extraData.FormatType = creationInfo.FormatType; extraData.FormatType = creationInfo.FormatType;
rc = WriteSaveDataFileSystemExtraData(spaceId, saveDataId, in extraData, in saveDataRootPath, res = WriteSaveDataFileSystemExtraData(spaceId, saveDataId, in extraData, in saveDataRootPath,
creationInfo.Attribute.Type, updateTimeStamp: true); creationInfo.Attribute.Type, updateTimeStamp: true);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
isCreationSuccessful = true; isCreationSuccessful = true;
return Result.Success; return Result.Success;
@ -491,22 +491,22 @@ public class SaveDataFileSystemServiceImpl : IDisposable
_saveFileSystemCacheManager.Unregister(spaceId, saveDataId); _saveFileSystemCacheManager.Unregister(spaceId, saveDataId);
// Open the directory containing the save data // Open the directory containing the save data
Result rc = OpenSaveDataDirectoryFileSystem(ref fileSystem.Ref(), spaceId, in saveDataRootPath, false); Result res = OpenSaveDataDirectoryFileSystem(ref fileSystem.Ref(), spaceId, in saveDataRootPath, false);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
using var saveImageName = new Path(); using var saveImageName = new Path();
rc = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer.Items, saveDataId); res = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer.Items, saveDataId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
// Check if the save data is a file or a directory // Check if the save data is a file or a directory
rc = fileSystem.Get.GetEntryType(out DirectoryEntryType entryType, in saveImageName); res = fileSystem.Get.GetEntryType(out DirectoryEntryType entryType, in saveImageName);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
// Delete the save data, wiping the file if needed // Delete the save data, wiping the file if needed
if (entryType == DirectoryEntryType.Directory) if (entryType == DirectoryEntryType.Directory)
{ {
rc = fileSystem.Get.DeleteDirectoryRecursively(in saveImageName); res = fileSystem.Get.DeleteDirectoryRecursively(in saveImageName);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
} }
else else
{ {
@ -518,10 +518,10 @@ public class SaveDataFileSystemServiceImpl : IDisposable
if (GetDebugConfigurationService().Get(DebugOptionKey.SaveDataEncryption, 0) != 0) if (GetDebugConfigurationService().Get(DebugOptionKey.SaveDataEncryption, 0) != 0)
{ {
using SharedRef<IFileSystem> tempFileSystem = SharedRef<IFileSystem>.CreateCopy(in fileSystem); using SharedRef<IFileSystem> tempFileSystem = SharedRef<IFileSystem>.CreateCopy(in fileSystem);
rc = _config.SaveFsCreator.IsDataEncrypted(out isDataEncrypted, ref tempFileSystem.Ref(), res = _config.SaveFsCreator.IsDataEncrypted(out isDataEncrypted, ref tempFileSystem.Ref(),
saveDataId, _config.BufferManager, IsDeviceUniqueMac(spaceId), isReconstructible: false); saveDataId, _config.BufferManager, IsDeviceUniqueMac(spaceId), isReconstructible: false);
if (rc.IsFailure()) if (res.IsFailure())
isDataEncrypted = false; isDataEncrypted = false;
} }
@ -535,8 +535,8 @@ public class SaveDataFileSystemServiceImpl : IDisposable
} }
} }
rc = fileSystem.Get.DeleteFile(in saveImageName); res = fileSystem.Get.DeleteFile(in saveImageName);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
} }
return Result.Success; return Result.Success;
@ -561,26 +561,26 @@ public class SaveDataFileSystemServiceImpl : IDisposable
using var extraDataAccessor = new SharedRef<ISaveDataExtraDataAccessor>(); using var extraDataAccessor = new SharedRef<ISaveDataExtraDataAccessor>();
// Try to grab an extra data accessor for the requested save from the cache. // Try to grab an extra data accessor for the requested save from the cache.
Result rc = _saveExtraDataCacheManager.GetCache(ref extraDataAccessor.Ref(), spaceId, saveDataId); Result res = _saveExtraDataCacheManager.GetCache(ref extraDataAccessor.Ref(), spaceId, saveDataId);
if (rc.IsFailure()) if (res.IsFailure())
{ {
// Try to open the extra data accessor if it's not in the cache. // Try to open the extra data accessor if it's not in the cache.
// We won't actually use the returned save data FS. // We won't actually use the returned save data FS.
// Opening the FS should cache an extra data accessor for it. // Opening the FS should cache an extra data accessor for it.
rc = OpenSaveDataFileSystem(ref unusedSaveDataFs.Ref(), spaceId, saveDataId, saveDataRootPath, res = OpenSaveDataFileSystem(ref unusedSaveDataFs.Ref(), spaceId, saveDataId, saveDataRootPath,
openReadOnly: true, type, cacheExtraData: true); openReadOnly: true, type, cacheExtraData: true);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
// Try to grab an accessor from the cache again. // Try to grab an accessor from the cache again.
rc = _saveExtraDataCacheManager.GetCache(ref extraDataAccessor.Ref(), spaceId, saveDataId); res = _saveExtraDataCacheManager.GetCache(ref extraDataAccessor.Ref(), spaceId, saveDataId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
} }
// We successfully got an extra data accessor. Read the extra data from it. // We successfully got an extra data accessor. Read the extra data from it.
rc = extraDataAccessor.Get.ReadExtraData(out extraData); res = extraDataAccessor.Get.ReadExtraData(out extraData);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -601,30 +601,30 @@ public class SaveDataFileSystemServiceImpl : IDisposable
using var extraDataAccessor = new SharedRef<ISaveDataExtraDataAccessor>(); using var extraDataAccessor = new SharedRef<ISaveDataExtraDataAccessor>();
// Try to grab an extra data accessor for the requested save from the cache. // Try to grab an extra data accessor for the requested save from the cache.
Result rc = _saveExtraDataCacheManager.GetCache(ref extraDataAccessor.Ref(), spaceId, saveDataId); Result res = _saveExtraDataCacheManager.GetCache(ref extraDataAccessor.Ref(), spaceId, saveDataId);
if (rc.IsFailure()) if (res.IsFailure())
{ {
// No accessor was found in the cache. Try to open one. // No accessor was found in the cache. Try to open one.
// We won't actually use the returned save data FS. // We won't actually use the returned save data FS.
// Opening the FS should cache an extra data accessor for it. // Opening the FS should cache an extra data accessor for it.
rc = OpenSaveDataFileSystem(ref unusedSaveDataFs.Ref(), spaceId, saveDataId, saveDataRootPath, res = OpenSaveDataFileSystem(ref unusedSaveDataFs.Ref(), spaceId, saveDataId, saveDataRootPath,
openReadOnly: false, type, cacheExtraData: true); openReadOnly: false, type, cacheExtraData: true);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
// Try to grab an accessor from the cache again. // Try to grab an accessor from the cache again.
rc = _saveExtraDataCacheManager.GetCache(ref extraDataAccessor.Ref(), spaceId, saveDataId); res = _saveExtraDataCacheManager.GetCache(ref extraDataAccessor.Ref(), spaceId, saveDataId);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
} }
// We should have a valid accessor if we've reached this point. // We should have a valid accessor if we've reached this point.
// Write and commit the extra data. // Write and commit the extra data.
rc = extraDataAccessor.Get.WriteExtraData(in extraData); res = extraDataAccessor.Get.WriteExtraData(in extraData);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = extraDataAccessor.Get.CommitExtraData(updateTimeStamp); res = extraDataAccessor.Get.CommitExtraData(updateTimeStamp);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -656,7 +656,7 @@ public class SaveDataFileSystemServiceImpl : IDisposable
public Result OpenSaveDataDirectoryFileSystem(ref SharedRef<IFileSystem> outFileSystem, public Result OpenSaveDataDirectoryFileSystem(ref SharedRef<IFileSystem> outFileSystem,
SaveDataSpaceId spaceId, in Path saveDataRootPath, bool allowEmulatedSave) SaveDataSpaceId spaceId, in Path saveDataRootPath, bool allowEmulatedSave)
{ {
Result rc; Result res;
if (allowEmulatedSave && IsAllowedDirectorySaveData(spaceId, in saveDataRootPath)) if (allowEmulatedSave && IsAllowedDirectorySaveData(spaceId, in saveDataRootPath))
{ {
@ -665,28 +665,28 @@ public class SaveDataFileSystemServiceImpl : IDisposable
using (var tmFileSystem = new SharedRef<IFileSystem>()) using (var tmFileSystem = new SharedRef<IFileSystem>())
{ {
// Ensure the target save data directory exists // Ensure the target save data directory exists
rc = _config.TargetManagerFsCreator.Create(ref tmFileSystem.Ref(), in saveDataRootPath, res = _config.TargetManagerFsCreator.Create(ref tmFileSystem.Ref(), in saveDataRootPath,
openCaseSensitive: false, ensureRootPathExists: true, openCaseSensitive: false, ensureRootPathExists: true,
ResultFs.SaveDataRootPathUnavailable.Value); ResultFs.SaveDataRootPathUnavailable.Value);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
} }
using var path = new Path(); using var path = new Path();
rc = path.Initialize(in saveDataRootPath); res = path.Initialize(in saveDataRootPath);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = _config.TargetManagerFsCreator.NormalizeCaseOfPath(out bool isTargetFsCaseSensitive, ref path.Ref()); res = _config.TargetManagerFsCreator.NormalizeCaseOfPath(out bool isTargetFsCaseSensitive, ref path.Ref());
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = _config.TargetManagerFsCreator.Create(ref outFileSystem, in path, isTargetFsCaseSensitive, res = _config.TargetManagerFsCreator.Create(ref outFileSystem, in path, isTargetFsCaseSensitive,
ensureRootPathExists: false, ResultFs.SaveDataRootPathUnavailable.Value); ensureRootPathExists: false, ResultFs.SaveDataRootPathUnavailable.Value);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
} }
else else
{ {
rc = _config.LocalFsCreator.Create(ref outFileSystem, in saveDataRootPath, openCaseSensitive: true, res = _config.LocalFsCreator.Create(ref outFileSystem, in saveDataRootPath, openCaseSensitive: true,
ensureRootPathExists: true, ResultFs.SaveDataRootPathUnavailable.Value); ensureRootPathExists: true, ResultFs.SaveDataRootPathUnavailable.Value);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
} }
return Result.Success; return Result.Success;
@ -704,11 +704,11 @@ public class SaveDataFileSystemServiceImpl : IDisposable
saveDirName = new[] { (byte)'/', (byte)'s', (byte)'a', (byte)'v', (byte)'e' }; // /save saveDirName = new[] { (byte)'/', (byte)'s', (byte)'a', (byte)'v', (byte)'e' }; // /save
} }
rc = PathFunctions.SetUpFixedPath(ref saveDataAreaDirectoryName.Ref(), saveDirName); res = PathFunctions.SetUpFixedPath(ref saveDataAreaDirectoryName.Ref(), saveDirName);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = OpenSaveDataDirectoryFileSystemImpl(ref outFileSystem, spaceId, in saveDataAreaDirectoryName); res = OpenSaveDataDirectoryFileSystemImpl(ref outFileSystem, spaceId, in saveDataAreaDirectoryName);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
@ -728,13 +728,13 @@ public class SaveDataFileSystemServiceImpl : IDisposable
{ {
case SaveDataSpaceId.System: case SaveDataSpaceId.System:
{ {
Result rc = _config.BaseFsService.OpenBisFileSystem(ref baseFileSystem.Ref(), BisPartitionId.System, Result res = _config.BaseFsService.OpenBisFileSystem(ref baseFileSystem.Ref(), BisPartitionId.System,
caseSensitive: true); caseSensitive: true);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = Utility.WrapSubDirectory(ref outFileSystem, ref baseFileSystem.Ref(), in directoryPath, res = Utility.WrapSubDirectory(ref outFileSystem, ref baseFileSystem.Ref(), in directoryPath,
createIfMissing); createIfMissing);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
break; break;
} }
@ -742,13 +742,13 @@ public class SaveDataFileSystemServiceImpl : IDisposable
case SaveDataSpaceId.User: case SaveDataSpaceId.User:
case SaveDataSpaceId.Temporary: case SaveDataSpaceId.Temporary:
{ {
Result rc = _config.BaseFsService.OpenBisFileSystem(ref baseFileSystem.Ref(), BisPartitionId.User, Result res = _config.BaseFsService.OpenBisFileSystem(ref baseFileSystem.Ref(), BisPartitionId.User,
caseSensitive: true); caseSensitive: true);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = Utility.WrapSubDirectory(ref outFileSystem, ref baseFileSystem.Ref(), in directoryPath, res = Utility.WrapSubDirectory(ref outFileSystem, ref baseFileSystem.Ref(), in directoryPath,
createIfMissing); createIfMissing);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
break; break;
} }
@ -756,55 +756,55 @@ public class SaveDataFileSystemServiceImpl : IDisposable
case SaveDataSpaceId.SdSystem: case SaveDataSpaceId.SdSystem:
case SaveDataSpaceId.SdUser: case SaveDataSpaceId.SdUser:
{ {
Result rc = _config.BaseFsService.OpenSdCardProxyFileSystem(ref baseFileSystem.Ref(), Result res = _config.BaseFsService.OpenSdCardProxyFileSystem(ref baseFileSystem.Ref(),
openCaseSensitive: true); openCaseSensitive: true);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
Unsafe.SkipInit(out Array64<byte> pathParentBuffer); Unsafe.SkipInit(out Array64<byte> pathParentBuffer);
using var pathParent = new Path(); using var pathParent = new Path();
rc = PathFunctions.SetUpFixedPathSingleEntry(ref pathParent.Ref(), pathParentBuffer.Items, res = PathFunctions.SetUpFixedPathSingleEntry(ref pathParent.Ref(), pathParentBuffer.Items,
CommonPaths.SdCardNintendoRootDirectoryName); CommonPaths.SdCardNintendoRootDirectoryName);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
using var pathSdRoot = new Path(); using var pathSdRoot = new Path();
rc = pathSdRoot.Combine(in pathParent, in directoryPath); res = pathSdRoot.Combine(in pathParent, in directoryPath);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
using SharedRef<IFileSystem> tempFileSystem = SharedRef<IFileSystem>.CreateMove(ref baseFileSystem.Ref()); using SharedRef<IFileSystem> tempFileSystem = SharedRef<IFileSystem>.CreateMove(ref baseFileSystem.Ref());
rc = Utility.WrapSubDirectory(ref baseFileSystem.Ref(), ref tempFileSystem.Ref(), in pathSdRoot, createIfMissing); res = Utility.WrapSubDirectory(ref baseFileSystem.Ref(), ref tempFileSystem.Ref(), in pathSdRoot, createIfMissing);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = _config.EncryptedFsCreator.Create(ref outFileSystem, ref baseFileSystem.Ref(), res = _config.EncryptedFsCreator.Create(ref outFileSystem, ref baseFileSystem.Ref(),
IEncryptedFileSystemCreator.KeyId.Save, in _encryptionSeed); IEncryptedFileSystemCreator.KeyId.Save, in _encryptionSeed);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
break; break;
} }
case SaveDataSpaceId.ProperSystem: case SaveDataSpaceId.ProperSystem:
{ {
Result rc = _config.BaseFsService.OpenBisFileSystem(ref baseFileSystem.Ref(), Result res = _config.BaseFsService.OpenBisFileSystem(ref baseFileSystem.Ref(),
BisPartitionId.SystemProperPartition, caseSensitive: true); BisPartitionId.SystemProperPartition, caseSensitive: true);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = Utility.WrapSubDirectory(ref outFileSystem, ref baseFileSystem.Ref(), in directoryPath, res = Utility.WrapSubDirectory(ref outFileSystem, ref baseFileSystem.Ref(), in directoryPath,
createIfMissing); createIfMissing);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
break; break;
} }
case SaveDataSpaceId.SafeMode: case SaveDataSpaceId.SafeMode:
{ {
Result rc = _config.BaseFsService.OpenBisFileSystem(ref baseFileSystem.Ref(), BisPartitionId.SafeMode, Result res = _config.BaseFsService.OpenBisFileSystem(ref baseFileSystem.Ref(), BisPartitionId.SafeMode,
caseSensitive: true); caseSensitive: true);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
rc = Utility.WrapSubDirectory(ref outFileSystem, ref baseFileSystem.Ref(), in directoryPath, res = Utility.WrapSubDirectory(ref outFileSystem, ref baseFileSystem.Ref(), in directoryPath,
createIfMissing); createIfMissing);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
break; break;
} }
@ -890,8 +890,8 @@ public class SaveDataFileSystemServiceImpl : IDisposable
UnsafeHelpers.SkipParamInit(out count); UnsafeHelpers.SkipParamInit(out count);
using var accessor = new UniqueRef<SaveDataIndexerAccessor>(); using var accessor = new UniqueRef<SaveDataIndexerAccessor>();
Result rc = OpenSaveDataIndexerAccessor(ref accessor.Ref(), out bool _, SaveDataSpaceId.User); Result res = OpenSaveDataIndexerAccessor(ref accessor.Ref(), out bool _, SaveDataSpaceId.User);
if (rc.IsFailure()) return rc.Miss(); if (res.IsFailure()) return res.Miss();
count = accessor.Get.GetInterface().GetIndexCount(); count = accessor.Get.GetInterface().GetIndexCount();
return Result.Success; return Result.Success;

Some files were not shown because too many files have changed in this diff Show More