2020-10-05 21:25:39 +02:00
|
|
|
|
using LibHac.Common.Keys;
|
|
|
|
|
using LibHac.Fs;
|
2020-06-10 07:55:59 +02:00
|
|
|
|
using LibHac.Fs.Fsa;
|
2020-08-07 20:45:11 +02:00
|
|
|
|
using LibHac.FsSrv;
|
2020-02-14 01:21:24 +01:00
|
|
|
|
|
|
|
|
|
namespace LibHac.Tests.Fs.FileSystemClientTests
|
|
|
|
|
{
|
|
|
|
|
public static class FileSystemServerFactory
|
|
|
|
|
{
|
2020-08-23 23:37:08 +02:00
|
|
|
|
private static FileSystemClient CreateClientImpl(bool sdCardInserted, out IFileSystem rootFs)
|
2020-02-14 01:21:24 +01:00
|
|
|
|
{
|
2020-04-03 06:57:08 +02:00
|
|
|
|
rootFs = new InMemoryFileSystem();
|
2020-02-14 01:21:24 +01:00
|
|
|
|
|
2020-10-05 21:25:39 +02:00
|
|
|
|
var defaultObjects = DefaultFsServerObjects.GetDefaultEmulatedCreators(rootFs, new KeySet());
|
2020-02-14 01:21:24 +01:00
|
|
|
|
|
|
|
|
|
defaultObjects.SdCard.SetSdCardInsertionStatus(sdCardInserted);
|
|
|
|
|
|
|
|
|
|
var config = new FileSystemServerConfig();
|
|
|
|
|
config.FsCreators = defaultObjects.FsCreators;
|
|
|
|
|
config.DeviceOperator = defaultObjects.DeviceOperator;
|
|
|
|
|
config.ExternalKeySet = new ExternalKeySet();
|
|
|
|
|
|
2020-08-23 23:37:08 +02:00
|
|
|
|
var horizon = new Horizon(new StopWatchTimeSpanGenerator(), config);
|
2020-02-14 01:21:24 +01:00
|
|
|
|
|
2020-08-26 08:03:48 +02:00
|
|
|
|
HorizonClient horizonClient = horizon.CreatePrivilegedHorizonClient();
|
2020-08-23 23:37:08 +02:00
|
|
|
|
|
|
|
|
|
return horizonClient.Fs;
|
2020-02-14 01:21:24 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static FileSystemClient CreateClient(bool sdCardInserted)
|
|
|
|
|
{
|
2020-08-23 23:37:08 +02:00
|
|
|
|
return CreateClientImpl(sdCardInserted, out _);
|
2020-04-03 06:57:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static FileSystemClient CreateClient(out IFileSystem rootFs)
|
|
|
|
|
{
|
2020-08-23 23:37:08 +02:00
|
|
|
|
return CreateClientImpl(false, out rootFs);
|
2020-02-14 01:21:24 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|