2021-05-17 07:52:27 +02:00
|
|
|
|
using LibHac.Bcat;
|
|
|
|
|
using LibHac.Common.Keys;
|
2020-08-24 08:35:00 +02:00
|
|
|
|
using LibHac.Fs.Fsa;
|
|
|
|
|
using LibHac.FsSrv;
|
2021-12-19 09:35:45 +01:00
|
|
|
|
using LibHac.Tools.Fs;
|
2020-08-24 08:35:00 +02:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
namespace LibHac.Tests;
|
|
|
|
|
|
|
|
|
|
public static class HorizonFactory
|
2020-08-24 08:35:00 +02:00
|
|
|
|
{
|
2021-11-14 20:08:57 +01:00
|
|
|
|
public static Horizon CreateBasicHorizon()
|
2020-08-24 08:35:00 +02:00
|
|
|
|
{
|
2021-11-14 20:08:57 +01:00
|
|
|
|
IFileSystem rootFs = new InMemoryFileSystem();
|
|
|
|
|
var keySet = new KeySet();
|
2020-08-24 08:35:00 +02:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
var horizon = new Horizon(new HorizonConfiguration());
|
2021-05-17 07:52:27 +02:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
HorizonClient fsServerClient = horizon.CreatePrivilegedHorizonClient();
|
|
|
|
|
var fsServer = new FileSystemServer(fsServerClient);
|
2021-05-17 07:52:27 +02:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
var defaultObjects = DefaultFsServerObjects.GetDefaultEmulatedCreators(rootFs, keySet, fsServer);
|
2020-08-24 08:35:00 +02:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
var config = new FileSystemServerConfig();
|
|
|
|
|
config.FsCreators = defaultObjects.FsCreators;
|
|
|
|
|
config.DeviceOperator = defaultObjects.DeviceOperator;
|
|
|
|
|
config.ExternalKeySet = new ExternalKeySet();
|
2020-08-24 08:35:00 +02:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
FileSystemServerInitializer.InitializeWithConfig(fsServerClient, fsServer, config);
|
2021-05-17 07:52:27 +02:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
HorizonClient bcatServerClient = horizon.CreateHorizonClient();
|
|
|
|
|
_ = new BcatServer(bcatServerClient);
|
2020-08-24 08:35:00 +02:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
return horizon;
|
2020-08-24 08:35:00 +02:00
|
|
|
|
}
|
2021-12-19 09:35:45 +01:00
|
|
|
|
}
|