diff --git a/src/LibHac/Fs/CustomStorage.cs b/src/LibHac/Fs/CustomStorage.cs new file mode 100644 index 00000000..b1081b37 --- /dev/null +++ b/src/LibHac/Fs/CustomStorage.cs @@ -0,0 +1,34 @@ +using System; +using LibHac.Common; +using LibHac.FsService; + +namespace LibHac.Fs +{ + public static class CustomStorage + { + public static Result MountCustomStorage(this FileSystemClient fs, U8Span mountName, CustomStorageId storageId) + { + Result rc = MountHelpers.CheckMountName(mountName); + if (rc.IsFailure()) return rc; + + FileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject(); + + rc = fsProxy.OpenCustomStorageFileSystem(out IFileSystem customFs, storageId); + if (rc.IsFailure()) return rc; + + return fs.Register(mountName, customFs); + } + + public static string GetCustomStorageDirectoryName(CustomStorageId storageId) + { + switch (storageId) + { + case CustomStorageId.User: + case CustomStorageId.SdCard: + return "CustomStorage0"; + default: + throw new ArgumentOutOfRangeException(nameof(storageId), storageId, null); + } + } + } +} diff --git a/src/LibHac/Fs/FileSystemClient.Mount.cs b/src/LibHac/Fs/FileSystemClient.Mount.cs deleted file mode 100644 index 4eed577d..00000000 --- a/src/LibHac/Fs/FileSystemClient.Mount.cs +++ /dev/null @@ -1,21 +0,0 @@ -using LibHac.Common; -using LibHac.FsService; - -namespace LibHac.Fs -{ - public partial class FileSystemClient - { - public Result MountCustomStorage(U8Span mountName, CustomStorageId storageId) - { - Result rc = MountHelpers.CheckMountName(mountName); - if (rc.IsFailure()) return rc; - - FileSystemProxy fsProxy = GetFileSystemProxyServiceObject(); - - rc = fsProxy.OpenCustomStorageFileSystem(out IFileSystem customFs, storageId); - if (rc.IsFailure()) return rc; - - return FsManager.Register(mountName, customFs); - } - } -} diff --git a/src/LibHac/FsService/FileSystemProxyCore.cs b/src/LibHac/FsService/FileSystemProxyCore.cs index 3534074d..7f30413f 100644 --- a/src/LibHac/FsService/FileSystemProxyCore.cs +++ b/src/LibHac/FsService/FileSystemProxyCore.cs @@ -87,7 +87,7 @@ namespace LibHac.FsService Result rc = FsCreators.SdFileSystemCreator.Create(out IFileSystem sdFs); if (rc.IsFailure()) return rc; - string customStorageDir = Util.GetCustomStorageDirectoryName(CustomStorageId.SdCard); + string customStorageDir = CustomStorage.GetCustomStorageDirectoryName(CustomStorageId.SdCard); string subDirName = $"/{NintendoDirectoryName}/{customStorageDir}"; rc = Util.CreateSubFileSystem(out IFileSystem subFs, sdFs, subDirName, true); @@ -106,7 +106,7 @@ namespace LibHac.FsService BisPartitionId.User); if (rc.IsFailure()) return rc; - string customStorageDir = Util.GetCustomStorageDirectoryName(CustomStorageId.User); + string customStorageDir = CustomStorage.GetCustomStorageDirectoryName(CustomStorageId.User); string subDirName = $"/{customStorageDir}"; rc = Util.CreateSubFileSystem(out IFileSystem subFs, userFs, subDirName, true); diff --git a/src/LibHac/FsService/Util.cs b/src/LibHac/FsService/Util.cs index 195549e8..d41e462b 100644 --- a/src/LibHac/FsService/Util.cs +++ b/src/LibHac/FsService/Util.cs @@ -1,5 +1,4 @@ -using System; -using LibHac.Fs; +using LibHac.Fs; using LibHac.FsSystem; namespace LibHac.FsService @@ -50,17 +49,5 @@ namespace LibHac.FsService spaceId == SaveDataSpaceId.ProperSystem || spaceId == SaveDataSpaceId.Safe; } - - public static string GetCustomStorageDirectoryName(CustomStorageId storageId) - { - switch (storageId) - { - case CustomStorageId.User: - case CustomStorageId.SdCard: - return "CustomStorage0"; - default: - throw new ArgumentOutOfRangeException(nameof(storageId), storageId, null); - } - } } }