Add properties to FileSystemServerImpl and StorageService

This commit is contained in:
Alex Barney 2021-02-07 00:32:17 -07:00
parent e50078d939
commit 270e61a501
8 changed files with 19 additions and 14 deletions

View file

@ -10,7 +10,7 @@ namespace LibHac.FsSrv
private Configuration _config;
private AccessFailureDetectionEventManager _eventManager;
internal HorizonClient HorizonClient => _config.FsServer.Globals.Hos;
internal HorizonClient HorizonClient => _config.FsServer.Hos;
public AccessFailureManagementServiceImpl(in Configuration configuration)
{

View file

@ -9,6 +9,7 @@ namespace LibHac.FsSrv
public FileSystemServerImpl Impl => new FileSystemServerImpl(this);
public StorageService Storage => new StorageService(this);
internal HorizonClient Hos => Globals.Hos;
/// <summary>
/// Creates a new <see cref="FileSystemServer"/> and registers its services using the provided HOS client.
@ -36,6 +37,8 @@ namespace LibHac.FsSrv
public readonly struct StorageService
{
internal readonly FileSystemServer FsSrv;
internal HorizonClient Hos => FsSrv.Hos;
internal ref FileSystemServerGlobals Globals => ref FsSrv.Globals;
internal StorageService(FileSystemServer parentServer) => FsSrv = parentServer;
}
@ -44,7 +47,9 @@ namespace LibHac.FsSrv
public readonly struct FileSystemServerImpl
{
internal readonly FileSystemServer FsSrv;
internal HorizonClient Hos => FsSrv.Hos;
internal ref FileSystemServerGlobals Globals => ref FsSrv.Globals;
public FileSystemServerImpl(FileSystemServer parentServer) => FsSrv = parentServer;
internal FileSystemServerImpl(FileSystemServer parentServer) => FsSrv = parentServer;
}
}

View file

@ -57,7 +57,7 @@ namespace LibHac.FsSrv
private static FileSystemProxyConfiguration InitializeFileSystemProxy(FileSystemServer server,
FileSystemServerConfig config)
{
var saveDataIndexerManager = new SaveDataIndexerManager(server.Globals.Hos.Fs, Fs.SaveData.SaveIndexerId,
var saveDataIndexerManager = new SaveDataIndexerManager(server.Hos.Fs, Fs.SaveData.SaveIndexerId,
new ArrayPoolMemoryResource(), new SdHandleManager(), false);
var programRegistryService = new ProgramRegistryServiceImpl(server);

View file

@ -16,25 +16,25 @@ namespace LibHac.FsSrv.Impl
{
public static SdCardEventSimulator GetSdCardEventSimulator(this FileSystemServerImpl fs)
{
ref DeviceEventSimulatorGlobals g = ref fs.FsSrv.Globals.DeviceEventSimulator;
using var guard = new InitializationGuard(ref g.SdCardEventSimulatorInit, fs.FsSrv.Globals.InitMutex);
ref DeviceEventSimulatorGlobals g = ref fs.Globals.DeviceEventSimulator;
using var guard = new InitializationGuard(ref g.SdCardEventSimulatorInit, fs.Globals.InitMutex);
if (guard.IsInitialized)
return g.SdCardEventSimulator;
g.SdCardEventSimulator = new SdCardEventSimulator(fs.FsSrv.Globals.Hos.Os);
g.SdCardEventSimulator = new SdCardEventSimulator(fs.Hos.Os);
return g.SdCardEventSimulator;
}
public static GameCardEventSimulator GetGameCardEventSimulator(this FileSystemServerImpl fs)
{
ref DeviceEventSimulatorGlobals g = ref fs.FsSrv.Globals.DeviceEventSimulator;
using var guard = new InitializationGuard(ref g.GameCardEventSimulatorInit, fs.FsSrv.Globals.InitMutex);
ref DeviceEventSimulatorGlobals g = ref fs.Globals.DeviceEventSimulator;
using var guard = new InitializationGuard(ref g.GameCardEventSimulatorInit, fs.Globals.InitMutex);
if (guard.IsInitialized)
return g.GameCardEventSimulator;
g.GameCardEventSimulator = new GameCardEventSimulator(fs.FsSrv.Globals.Hos.Os);
g.GameCardEventSimulator = new GameCardEventSimulator(fs.Hos.Os);
return g.GameCardEventSimulator;
}
}

View file

@ -16,7 +16,7 @@ namespace LibHac.FsSrv.Impl
private SdkMutexType _mutex;
private FileSystemServer _fsServer;
private HorizonClient Hos => _fsServer.Globals.Hos;
private HorizonClient Hos => _fsServer.Hos;
public LocationResolverSet(FileSystemServer fsServer)
{

View file

@ -24,7 +24,7 @@ namespace LibHac.FsSrv
private bool _isSdCardAccessible;
// Timestamp getter
internal HorizonClient Hos => _config.FsServer.Globals.Hos;
internal HorizonClient Hos => _config.FsServer.Hos;
public SaveDataFileSystemServiceImpl(in Configuration configuration)
{

View file

@ -39,8 +39,8 @@ namespace LibHac.FsSrv.Storage
public static IStorageDeviceManagerFactory GetStorageDeviceManagerFactory(this StorageService storage,
IStorageDeviceManagerFactory factory)
{
ref StorageDeviceManagerFactoryGlobals g = ref storage.FsSrv.Globals.StorageDeviceManagerFactory;
using var initGuard = new InitializationGuard(ref g.FactoryGuard, storage.FsSrv.Globals.InitMutex);
ref StorageDeviceManagerFactoryGlobals g = ref storage.Globals.StorageDeviceManagerFactory;
using var initGuard = new InitializationGuard(ref g.FactoryGuard, storage.Globals.InitMutex);
if (initGuard.IsInitialized)
return g.Factory;

View file

@ -52,7 +52,7 @@ namespace LibHac.FsSrv
private long GetSystemSeconds()
{
OsState os = _fsServer.Globals.Hos.Os;
OsState os = _fsServer.Hos.Os;
Tick tick = os.GetSystemTick();
TimeSpan timeSpan = os.ConvertToTimeSpan(tick);