From c2e4b80bacc62daa9a8228cc4941c01654083208 Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Sat, 30 Apr 2022 13:28:53 -0700 Subject: [PATCH] Ensure all FS shim classes are updated for 14.0.0 --- src/LibHac/Fs/Shim/Application.cs | 2 +- src/LibHac/Fs/Shim/BcatSaveData.cs | 2 +- src/LibHac/Fs/Shim/Bis.cs | 2 +- src/LibHac/Fs/Shim/Code.cs | 2 +- src/LibHac/Fs/Shim/Content.cs | 2 +- src/LibHac/Fs/Shim/ContentStorage.cs | 2 +- src/LibHac/Fs/Shim/CustomStorage.cs | 2 +- src/LibHac/Fs/Shim/Debug.cs | 2 +- src/LibHac/Fs/Shim/FileDataCache.cs | 12 ++++++++++- .../{Impl => Shim}/FileDataCacheAccessor.cs | 3 ++- .../Fs/Shim/FileSystemServiceObjectAdapter.cs | 6 +++--- src/LibHac/Fs/Shim/GameCard.cs | 20 +++++++++++-------- src/LibHac/Fs/Shim/Host.cs | 2 +- src/LibHac/Fs/Shim/LoaderApi.cs | 2 +- src/LibHac/Fs/Shim/PosixTime.cs | 2 +- src/LibHac/Fs/Shim/ProgramIndexMapInfo.cs | 2 +- src/LibHac/Fs/Shim/ProgramRegistry.cs | 2 +- src/LibHac/Fs/Shim/RightsId.cs | 2 +- src/LibHac/Fs/Shim/SaveDataTransferAdapter.cs | 10 +++++----- .../Fs/Shim/SaveDataTransferVersion2.cs | 14 +++++++++++++ src/LibHac/Fs/Shim/SdCard.cs | 6 +++++- src/LibHac/Fs/Shim/SdmmcControl.cs | 2 +- src/LibHac/Fs/Shim/SignedSystemPartition.cs | 2 +- src/LibHac/Fs/Shim/SystemSaveData.cs | 2 +- 24 files changed, 69 insertions(+), 36 deletions(-) rename src/LibHac/Fs/{Impl => Shim}/FileDataCacheAccessor.cs (89%) diff --git a/src/LibHac/Fs/Shim/Application.cs b/src/LibHac/Fs/Shim/Application.cs index ba44e43d..b1116531 100644 --- a/src/LibHac/Fs/Shim/Application.cs +++ b/src/LibHac/Fs/Shim/Application.cs @@ -14,7 +14,7 @@ namespace LibHac.Fs.Shim; /// /// Contains functions for mounting application packages. /// -/// Based on FS 13.1.0 (nnSdk 13.4.0) +/// Based on nnSdk 14.3.0 [SkipLocalsInit] public static class Application { diff --git a/src/LibHac/Fs/Shim/BcatSaveData.cs b/src/LibHac/Fs/Shim/BcatSaveData.cs index 8f924186..3c515a6a 100644 --- a/src/LibHac/Fs/Shim/BcatSaveData.cs +++ b/src/LibHac/Fs/Shim/BcatSaveData.cs @@ -16,7 +16,7 @@ namespace LibHac.Fs.Shim; /// /// Contains functions for mounting BCAT save data. /// -/// Based on FS 13.1.0 (nnSdk 13.4.0) +/// Based on nnSdk 14.3.0 [SkipLocalsInit] public static class BcatSaveData { diff --git a/src/LibHac/Fs/Shim/Bis.cs b/src/LibHac/Fs/Shim/Bis.cs index 6cfd7474..9298649c 100644 --- a/src/LibHac/Fs/Shim/Bis.cs +++ b/src/LibHac/Fs/Shim/Bis.cs @@ -19,7 +19,7 @@ namespace LibHac.Fs.Shim; /// Contains functions for mounting built-in-storage partition file systems /// and opening the raw partitions as s. /// -/// Based on FS 13.1.0 (nnSdk 13.4.0) +/// Based on nnSdk 14.3.0 [SkipLocalsInit] public static class Bis { diff --git a/src/LibHac/Fs/Shim/Code.cs b/src/LibHac/Fs/Shim/Code.cs index 245286c6..d5df1784 100644 --- a/src/LibHac/Fs/Shim/Code.cs +++ b/src/LibHac/Fs/Shim/Code.cs @@ -15,7 +15,7 @@ namespace LibHac.Fs.Shim; /// /// Contains functions for mounting code file systems. /// -/// Based on FS 13.1.0 (nnSdk 13.4.0) +/// Based on nnSdk 14.3.0 [SkipLocalsInit] public static class Code { diff --git a/src/LibHac/Fs/Shim/Content.cs b/src/LibHac/Fs/Shim/Content.cs index 7b04a708..a067ff26 100644 --- a/src/LibHac/Fs/Shim/Content.cs +++ b/src/LibHac/Fs/Shim/Content.cs @@ -16,7 +16,7 @@ namespace LibHac.Fs.Shim; /// /// Contains functions for mounting content file systems. /// -/// Based on FS 13.1.0 (nnSdk 13.4.0) +/// Based on nnSdk 14.3.0 [SkipLocalsInit] public static class Content { diff --git a/src/LibHac/Fs/Shim/ContentStorage.cs b/src/LibHac/Fs/Shim/ContentStorage.cs index 04a66784..590839ef 100644 --- a/src/LibHac/Fs/Shim/ContentStorage.cs +++ b/src/LibHac/Fs/Shim/ContentStorage.cs @@ -16,7 +16,7 @@ namespace LibHac.Fs.Shim; /// /// Contains functions for mounting the directories where content is stored. /// -/// Based on FS 13.1.0 (nnSdk 13.4.0) +/// Based on nnSdk 14.3.0 [SkipLocalsInit] public static class ContentStorage { diff --git a/src/LibHac/Fs/Shim/CustomStorage.cs b/src/LibHac/Fs/Shim/CustomStorage.cs index 319c45ca..27545b29 100644 --- a/src/LibHac/Fs/Shim/CustomStorage.cs +++ b/src/LibHac/Fs/Shim/CustomStorage.cs @@ -13,7 +13,7 @@ namespace LibHac.Fs.Shim; /// /// Contains functions for mounting custom storage file systems. /// -/// Based on FS 13.1.0 (nnSdk 13.4.0) +/// Based on nnSdk 14.3.0 [SkipLocalsInit] public static class CustomStorage { diff --git a/src/LibHac/Fs/Shim/Debug.cs b/src/LibHac/Fs/Shim/Debug.cs index e34323e3..65b4557b 100644 --- a/src/LibHac/Fs/Shim/Debug.cs +++ b/src/LibHac/Fs/Shim/Debug.cs @@ -17,7 +17,7 @@ public enum DebugOptionKey : uint /// /// Contains debug-related functions for the FS service. /// -/// Based on nnSdk 13.4.0 +/// Based on nnSdk 14.3.0 public static class DebugShim { public static Result CreatePaddingFile(this FileSystemClient fs, long size) diff --git a/src/LibHac/Fs/Shim/FileDataCache.cs b/src/LibHac/Fs/Shim/FileDataCache.cs index 35138910..d442db26 100644 --- a/src/LibHac/Fs/Shim/FileDataCache.cs +++ b/src/LibHac/Fs/Shim/FileDataCache.cs @@ -10,12 +10,18 @@ namespace LibHac.Fs.Impl /// /// Handles getting scoped read access to the global file data cache. /// - /// Based on FS 13.1.0 (nnSdk 13.4.0) + /// Based on nnSdk 14.3.0 internal struct GlobalFileDataCacheAccessorReadableScopedPointer : IDisposable { private FileDataCacheAccessor _accessor; private ReaderWriterLock _lock; + public GlobalFileDataCacheAccessorReadableScopedPointer() + { + _accessor = null; + _lock = null; + } + public void Dispose() { _lock?.ReleaseReadLock(); @@ -36,6 +42,10 @@ namespace LibHac.Fs.Impl namespace LibHac.Fs.Shim { + /// + /// Contains functions for configuring the global file data cache. + /// + /// Based on nnSdk 14.3.0 public static class FileDataCacheShim { internal struct Globals : IDisposable diff --git a/src/LibHac/Fs/Impl/FileDataCacheAccessor.cs b/src/LibHac/Fs/Shim/FileDataCacheAccessor.cs similarity index 89% rename from src/LibHac/Fs/Impl/FileDataCacheAccessor.cs rename to src/LibHac/Fs/Shim/FileDataCacheAccessor.cs index 1bab0250..79c36224 100644 --- a/src/LibHac/Fs/Impl/FileDataCacheAccessor.cs +++ b/src/LibHac/Fs/Shim/FileDataCacheAccessor.cs @@ -1,12 +1,13 @@ using System; using LibHac.Fs.Fsa; +// ReSharper disable once CheckNamespace namespace LibHac.Fs.Impl; /// /// Provides access to an . /// -/// Based on FS 13.1.0 (nnSdk 13.4.0) +/// Based on nnSdk 14.3.0 internal class FileDataCacheAccessor { private readonly IFileDataCache _cache; diff --git a/src/LibHac/Fs/Shim/FileSystemServiceObjectAdapter.cs b/src/LibHac/Fs/Shim/FileSystemServiceObjectAdapter.cs index 8d14426d..20e88640 100644 --- a/src/LibHac/Fs/Shim/FileSystemServiceObjectAdapter.cs +++ b/src/LibHac/Fs/Shim/FileSystemServiceObjectAdapter.cs @@ -21,7 +21,7 @@ namespace LibHac.Fs.Impl; /// An adapter for using an service object as an . Used /// when receiving a Horizon IPC file object so it can be used as an locally. /// -/// Based on FS 13.1.0 (nnSdk 13.4.0) +/// Based on nnSdk 14.3.0 internal class FileServiceObjectAdapter : IFile { private SharedRef _baseFile; @@ -87,7 +87,7 @@ internal class FileServiceObjectAdapter : IFile /// An adapter for using an service object as an . Used /// when receiving a Horizon IPC directory object so it can be used as an locally. /// -/// Based on FS 13.1.0 (nnSdk 13.4.0) +/// Based on nnSdk 14.3.0 internal class DirectoryServiceObjectAdapter : IDirectory { private SharedRef _baseDirectory; @@ -119,7 +119,7 @@ internal class DirectoryServiceObjectAdapter : IDirectory /// An adapter for using an service object as an . Used /// when receiving a Horizon IPC file system object so it can be used as an locally. /// -/// Based on FS 13.1.0 (nnSdk 13.4.0) +/// Based on nnSdk 14.3.0 internal class FileSystemServiceObjectAdapter : IFileSystem, IMultiCommitTarget { private SharedRef _baseFs; diff --git a/src/LibHac/Fs/Shim/GameCard.cs b/src/LibHac/Fs/Shim/GameCard.cs index d6a92f8a..0dab8227 100644 --- a/src/LibHac/Fs/Shim/GameCard.cs +++ b/src/LibHac/Fs/Shim/GameCard.cs @@ -14,6 +14,10 @@ using IStorageSf = LibHac.FsSrv.Sf.IStorage; namespace LibHac.Fs.Shim; +/// +/// Contains functions used for mounting and interacting with the game card. +/// +/// Based on nnSdk 14.3.0 [SkipLocalsInit] public static class GameCard { @@ -32,13 +36,13 @@ public static class GameCard private class GameCardCommonMountNameGenerator : ICommonMountNameGenerator { - private GameCardHandle Handle { get; } - private GameCardPartition PartitionId { get; } + private readonly GameCardHandle _handle; + private readonly GameCardPartition _partitionId; public GameCardCommonMountNameGenerator(GameCardHandle handle, GameCardPartition partitionId) { - Handle = handle; - PartitionId = partitionId; + _handle = handle; + _partitionId = partitionId; } public void Dispose() { } @@ -50,7 +54,7 @@ public static class GameCard // Determine how much space we need. int requiredNameBufferSize = StringUtils.GetLength(CommonMountNames.GameCardFileSystemMountName, PathTool.MountNameLengthMax) + - StringUtils.GetLength(GetGameCardMountNameSuffix(PartitionId), PathTool.MountNameLengthMax) + + StringUtils.GetLength(GetGameCardMountNameSuffix(_partitionId), PathTool.MountNameLengthMax) + handleDigitCount + 2; Assert.SdkRequiresGreaterEqual(nameBuffer.Length, requiredNameBufferSize); @@ -58,8 +62,8 @@ public static class GameCard // Generate the name. var sb = new U8StringBuilder(nameBuffer); sb.Append(CommonMountNames.GameCardFileSystemMountName) - .Append(GetGameCardMountNameSuffix(PartitionId)) - .AppendFormat(Handle.Value, 'x', (byte)handleDigitCount) + .Append(GetGameCardMountNameSuffix(_partitionId)) + .AppendFormat(_handle.Value, 'x', (byte)handleDigitCount) .Append(StringTraits.DriveSeparator); Assert.SdkEqual(sb.Length, requiredNameBufferSize - 1); @@ -180,4 +184,4 @@ public static class GameCard outStorage.Set(ref storageAdapter.Ref()); return Result.Success; } -} +} \ No newline at end of file diff --git a/src/LibHac/Fs/Shim/Host.cs b/src/LibHac/Fs/Shim/Host.cs index dc9bc64f..dc804d67 100644 --- a/src/LibHac/Fs/Shim/Host.cs +++ b/src/LibHac/Fs/Shim/Host.cs @@ -19,7 +19,7 @@ namespace LibHac.Fs.Shim; /// /// Contains functions for mounting file systems from a host computer. /// -/// Based on nnSdk 13.4.0 +/// Based on nnSdk 14.3.0 [SkipLocalsInit] public static class Host { diff --git a/src/LibHac/Fs/Shim/LoaderApi.cs b/src/LibHac/Fs/Shim/LoaderApi.cs index d7b0a7f5..94fbfa09 100644 --- a/src/LibHac/Fs/Shim/LoaderApi.cs +++ b/src/LibHac/Fs/Shim/LoaderApi.cs @@ -7,7 +7,7 @@ namespace LibHac.Fs.Shim; /// /// Contains functions for use by the Loader service. /// -/// Based on nnSdk 13.4.0 +/// Based on nnSdk 14.3.0 public static class LoaderApi { public static Result IsArchivedProgram(this FileSystemClient fs, out bool isArchived, ProcessId processId) diff --git a/src/LibHac/Fs/Shim/PosixTime.cs b/src/LibHac/Fs/Shim/PosixTime.cs index 22436ac0..9d32bc04 100644 --- a/src/LibHac/Fs/Shim/PosixTime.cs +++ b/src/LibHac/Fs/Shim/PosixTime.cs @@ -6,7 +6,7 @@ namespace LibHac.Fs.Shim; /// /// Contains functions for setting the current time used by FS. /// -/// Based on nnSdk 13.4.0 +/// Based on nnSdk 14.3.0 public static class PosixTimeShim { public static Result SetCurrentPosixTime(this FileSystemClient fs, Time.PosixTime currentPosixTime, diff --git a/src/LibHac/Fs/Shim/ProgramIndexMapInfo.cs b/src/LibHac/Fs/Shim/ProgramIndexMapInfo.cs index eb02288a..2d59563a 100644 --- a/src/LibHac/Fs/Shim/ProgramIndexMapInfo.cs +++ b/src/LibHac/Fs/Shim/ProgramIndexMapInfo.cs @@ -9,7 +9,7 @@ namespace LibHac.Fs.Shim; /// Contains functions for registering multi-program application /// information of the currently running application with FS. /// -/// Based on nnSdk 13.4.0 +/// Based on nnSdk 14.3.0 public static class ProgramIndexMapInfoShim { /// diff --git a/src/LibHac/Fs/Shim/ProgramRegistry.cs b/src/LibHac/Fs/Shim/ProgramRegistry.cs index dc9b3877..f33e7de9 100644 --- a/src/LibHac/Fs/Shim/ProgramRegistry.cs +++ b/src/LibHac/Fs/Shim/ProgramRegistry.cs @@ -12,7 +12,7 @@ namespace LibHac.Fs.Shim; /// Contains functions for registering and unregistering currently running /// processes and their permissions in the FS program registry. /// -/// Based on nnSdk 13.4.0 +/// Based on nnSdk 14.3.0 public static class ProgramRegistry { /// diff --git a/src/LibHac/Fs/Shim/RightsId.cs b/src/LibHac/Fs/Shim/RightsId.cs index 64d8639b..12306e86 100644 --- a/src/LibHac/Fs/Shim/RightsId.cs +++ b/src/LibHac/Fs/Shim/RightsId.cs @@ -8,7 +8,7 @@ namespace LibHac.Fs.Shim; /// /// Contains functions for working with rights IDs and external keys for NCA encryption. /// -/// Based on nnSdk 13.4.0 +/// Based on nnSdk 14.3.0 public static class RightsIdShim { public static Result GetRightsId(this FileSystemClient fs, out RightsId rightsId, ProgramId programId, diff --git a/src/LibHac/Fs/Shim/SaveDataTransferAdapter.cs b/src/LibHac/Fs/Shim/SaveDataTransferAdapter.cs index 3fe197e9..2dd57606 100644 --- a/src/LibHac/Fs/Shim/SaveDataTransferAdapter.cs +++ b/src/LibHac/Fs/Shim/SaveDataTransferAdapter.cs @@ -12,7 +12,7 @@ namespace LibHac.Fs.Impl; /// An adapter for interacting with an /// IPC service object via the non-IPC interface. /// -/// Based on nnSdk 13.4.0 +/// Based on nnSdk 14.3.0 public class SaveDataChunkIterator : ISaveDataChunkIterator { private SharedRef _baseInterface; @@ -61,7 +61,7 @@ public class SaveDataChunkIterator : ISaveDataChunkIterator /// An adapter for interacting with an /// IPC service object via the non-IPC interface. /// -/// Based on nnSdk 13.4.0 +/// Based on nnSdk 14.3.0 public class SaveDataChunkExporter : ISaveDataChunkExporter { private SharedRef _baseInterface; @@ -108,7 +108,7 @@ public class SaveDataChunkExporter : ISaveDataChunkExporter /// An adapter for interacting with an /// IPC service object via the non-IPC interface. /// -/// Based on nnSdk 13.4.0 +/// Based on nnSdk 14.3.0 public class SaveDataChunkImporter : ISaveDataChunkImporter { private SharedRef _baseInterface; @@ -141,7 +141,7 @@ public class SaveDataChunkImporter : ISaveDataChunkImporter /// An adapter for interacting with an /// IPC service object via the non-IPC interface. /// -/// Based on nnSdk 13.4.0 +/// Based on nnSdk 14.3.0 public class SaveDataExporterVersion2 : ISaveDataDivisionExporter { private SharedRef _baseInterface; @@ -320,7 +320,7 @@ public class SaveDataExporterVersion2 : ISaveDataDivisionExporter /// An adapter for interacting with an /// IPC service object via the non-IPC interface. /// -/// Based on nnSdk 13.4.0 +/// Based on nnSdk 14.3.0 public class SaveDataImporterVersion2 : ISaveDataDivisionImporter { private SharedRef _baseInterface; diff --git a/src/LibHac/Fs/Shim/SaveDataTransferVersion2.cs b/src/LibHac/Fs/Shim/SaveDataTransferVersion2.cs index 00d85bf6..03d004eb 100644 --- a/src/LibHac/Fs/Shim/SaveDataTransferVersion2.cs +++ b/src/LibHac/Fs/Shim/SaveDataTransferVersion2.cs @@ -14,6 +14,11 @@ using static LibHac.Fs.SaveData; // ReSharper disable once CheckNamespace namespace LibHac.Fs { + /// + /// An adapter for interacting with an + /// IPC service object. + /// + /// Based on nnSdk 14.3.0 public class SaveDataTransferManagerVersion2 : IDisposable { private SharedRef _baseInterface; @@ -253,6 +258,11 @@ namespace LibHac.Fs } } + /// + /// An adapter that automatically closes a given + /// IPC service object when disposed. + /// + /// Based on nnSdk 14.3.0 public class SaveDataTransferProhibiterForCloudBackUp : IDisposable { private SharedRef _prohibiter; @@ -271,6 +281,10 @@ namespace LibHac.Fs namespace LibHac.Fs.Shim { + /// + /// Contains functions used when doing save data cloud backup. + /// + /// Based on nnSdk 14.3.0 public static class SaveDataTransferVersion2Shim { public static Result OpenSaveDataTransferProhibiterForCloudBackUp(this FileSystemClientImpl fs, diff --git a/src/LibHac/Fs/Shim/SdCard.cs b/src/LibHac/Fs/Shim/SdCard.cs index 2f12e400..6c461f37 100644 --- a/src/LibHac/Fs/Shim/SdCard.cs +++ b/src/LibHac/Fs/Shim/SdCard.cs @@ -12,6 +12,10 @@ using IFileSystemSf = LibHac.FsSrv.Sf.IFileSystem; namespace LibHac.Fs.Shim; +/// +/// Contains functions used for mounting and interacting with the SD card. +/// +/// Based on nnSdk 14.3.0 [SkipLocalsInit] public static class SdCard { @@ -207,4 +211,4 @@ public static class SdCard fs.AbortIfNeeded(rc); return rc; } -} +} \ No newline at end of file diff --git a/src/LibHac/Fs/Shim/SdmmcControl.cs b/src/LibHac/Fs/Shim/SdmmcControl.cs index a72625e9..c7c7ab7b 100644 --- a/src/LibHac/Fs/Shim/SdmmcControl.cs +++ b/src/LibHac/Fs/Shim/SdmmcControl.cs @@ -5,7 +5,7 @@ namespace LibHac.Fs.Shim; /// /// Contains functions for suspending, resuming, and checking sdmmc status. /// -/// Based on nnSdk 13.4.0 +/// Based on nnSdk 14.3.0 public static class SdmmcControl { public static Result GetSdmmcConnectionStatus(this FileSystemClient fs, out SdmmcSpeedMode speedMode, diff --git a/src/LibHac/Fs/Shim/SignedSystemPartition.cs b/src/LibHac/Fs/Shim/SignedSystemPartition.cs index 5d662865..13a8981e 100644 --- a/src/LibHac/Fs/Shim/SignedSystemPartition.cs +++ b/src/LibHac/Fs/Shim/SignedSystemPartition.cs @@ -9,7 +9,7 @@ namespace LibHac.Fs.Shim; /// /// Contains functions for checking if a mounted file system was created from a signed system partition. /// -/// Based on nnSdk 13.4.0 +/// Based on nnSdk 14.3.0 public static class SignedSystemPartition { public static bool IsValidSignedSystemPartitionOnSdCard(this FileSystemClient fs, U8Span path) diff --git a/src/LibHac/Fs/Shim/SystemSaveData.cs b/src/LibHac/Fs/Shim/SystemSaveData.cs index 444ba221..753cd229 100644 --- a/src/LibHac/Fs/Shim/SystemSaveData.cs +++ b/src/LibHac/Fs/Shim/SystemSaveData.cs @@ -16,7 +16,7 @@ namespace LibHac.Fs.Shim; /// /// Contains functions for mounting system save data file systems. /// -/// Based on nnSdk 13.4.0 +/// Based on nnSdk 14.3.0 [SkipLocalsInit] public static class SystemSaveData {