mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Move custom storage client code together
This commit is contained in:
parent
0fe3031701
commit
22940f20e5
4 changed files with 37 additions and 37 deletions
34
src/LibHac/Fs/CustomStorage.cs
Normal file
34
src/LibHac/Fs/CustomStorage.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -87,7 +87,7 @@ namespace LibHac.FsService
|
||||||
Result rc = FsCreators.SdFileSystemCreator.Create(out IFileSystem sdFs);
|
Result rc = FsCreators.SdFileSystemCreator.Create(out IFileSystem sdFs);
|
||||||
if (rc.IsFailure()) return rc;
|
if (rc.IsFailure()) return rc;
|
||||||
|
|
||||||
string customStorageDir = Util.GetCustomStorageDirectoryName(CustomStorageId.SdCard);
|
string customStorageDir = CustomStorage.GetCustomStorageDirectoryName(CustomStorageId.SdCard);
|
||||||
string subDirName = $"/{NintendoDirectoryName}/{customStorageDir}";
|
string subDirName = $"/{NintendoDirectoryName}/{customStorageDir}";
|
||||||
|
|
||||||
rc = Util.CreateSubFileSystem(out IFileSystem subFs, sdFs, subDirName, true);
|
rc = Util.CreateSubFileSystem(out IFileSystem subFs, sdFs, subDirName, true);
|
||||||
|
@ -106,7 +106,7 @@ namespace LibHac.FsService
|
||||||
BisPartitionId.User);
|
BisPartitionId.User);
|
||||||
if (rc.IsFailure()) return rc;
|
if (rc.IsFailure()) return rc;
|
||||||
|
|
||||||
string customStorageDir = Util.GetCustomStorageDirectoryName(CustomStorageId.User);
|
string customStorageDir = CustomStorage.GetCustomStorageDirectoryName(CustomStorageId.User);
|
||||||
string subDirName = $"/{customStorageDir}";
|
string subDirName = $"/{customStorageDir}";
|
||||||
|
|
||||||
rc = Util.CreateSubFileSystem(out IFileSystem subFs, userFs, subDirName, true);
|
rc = Util.CreateSubFileSystem(out IFileSystem subFs, userFs, subDirName, true);
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using LibHac.Fs;
|
||||||
using LibHac.Fs;
|
|
||||||
using LibHac.FsSystem;
|
using LibHac.FsSystem;
|
||||||
|
|
||||||
namespace LibHac.FsService
|
namespace LibHac.FsService
|
||||||
|
@ -50,17 +49,5 @@ namespace LibHac.FsService
|
||||||
spaceId == SaveDataSpaceId.ProperSystem ||
|
spaceId == SaveDataSpaceId.ProperSystem ||
|
||||||
spaceId == SaveDataSpaceId.Safe;
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue