Move custom storage client code together

This commit is contained in:
Alex Barney 2019-09-21 13:59:35 -05:00
parent 0fe3031701
commit 22940f20e5
4 changed files with 37 additions and 37 deletions

View file

@ -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);
}
}
}
}

View file

@ -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);
}
}
}

View file

@ -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);

View file

@ -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);
}
}
}
}