Add DefaultFsServerObjects for creating a default server instance

This commit is contained in:
Alex Barney 2019-10-07 19:01:53 -05:00
parent 51a13068df
commit b517085e92
3 changed files with 43 additions and 24 deletions

View file

@ -1,6 +1,4 @@
using LibHac.Fs; namespace LibHac.FsService.Creators
namespace LibHac.FsService.Creators
{ {
public class FileSystemCreators public class FileSystemCreators
{ {
@ -20,25 +18,5 @@ namespace LibHac.FsService.Creators
public IMemoryStorageCreator MemoryStorageCreator { get; set; } public IMemoryStorageCreator MemoryStorageCreator { get; set; }
public IBuiltInStorageFileSystemCreator BuiltInStorageFileSystemCreator { get; set; } public IBuiltInStorageFileSystemCreator BuiltInStorageFileSystemCreator { get; set; }
public ISdFileSystemCreator SdFileSystemCreator { get; set; } public ISdFileSystemCreator SdFileSystemCreator { get; set; }
public IDeviceOperator DeviceOperator { get; set; }
public static (FileSystemCreators fsCreators, EmulatedGameCard gameCard) GetDefaultEmulatedCreators(
IFileSystem rootFileSystem, Keyset keyset)
{
var creators = new FileSystemCreators();
var gameCard = new EmulatedGameCard();
creators.SubDirectoryFileSystemCreator = new SubDirectoryFileSystemCreator();
creators.SaveDataFileSystemCreator = new SaveDataFileSystemCreator(keyset);
creators.GameCardStorageCreator = new EmulatedGameCardStorageCreator(gameCard);
creators.EncryptedFileSystemCreator = new EncryptedFileSystemCreator(keyset);
creators.BuiltInStorageFileSystemCreator = new EmulatedBisFileSystemCreator(rootFileSystem);
creators.SdFileSystemCreator = new EmulatedSdFileSystemCreator(rootFileSystem);
creators.DeviceOperator = new EmulatedDeviceOperator(gameCard);
return (creators, gameCard);
}
} }
} }

View file

@ -0,0 +1,34 @@
using LibHac.Fs;
using LibHac.FsService.Creators;
namespace LibHac.FsService
{
public class DefaultFsServerObjects
{
public FileSystemCreators FsCreators { get; set; }
public IDeviceOperator DeviceOperator { get; set; }
public EmulatedGameCard GameCard { get; set; }
public static DefaultFsServerObjects GetDefaultEmulatedCreators(IFileSystem rootFileSystem, Keyset keyset)
{
var creators = new FileSystemCreators();
var gameCard = new EmulatedGameCard(keyset);
creators.SubDirectoryFileSystemCreator = new SubDirectoryFileSystemCreator();
creators.SaveDataFileSystemCreator = new SaveDataFileSystemCreator(keyset);
creators.GameCardStorageCreator = new EmulatedGameCardStorageCreator(gameCard);
creators.EncryptedFileSystemCreator = new EncryptedFileSystemCreator(keyset);
creators.BuiltInStorageFileSystemCreator = new EmulatedBisFileSystemCreator(rootFileSystem);
creators.SdFileSystemCreator = new EmulatedSdFileSystemCreator(rootFileSystem);
var deviceOperator = new EmulatedDeviceOperator(gameCard);
return new DefaultFsServerObjects
{
FsCreators = creators,
DeviceOperator = deviceOperator,
GameCard = gameCard
};
}
}
}

View file

@ -9,7 +9,14 @@ namespace LibHac.FsService
private IStorage CardImageStorage { get; set; } private IStorage CardImageStorage { get; set; }
private int Handle { get; set; } private int Handle { get; set; }
private XciHeader CardHeader { get; set; } private XciHeader CardHeader { get; set; }
private Keyset Keyset { get; set; }
public EmulatedGameCard() { }
public EmulatedGameCard(Keyset keyset)
{
Keyset = keyset;
}
public GameCardHandle GetGameCardHandle() public GameCardHandle GetGameCardHandle()
{ {
return new GameCardHandle(Handle); return new GameCardHandle(Handle);
@ -31,7 +38,7 @@ namespace LibHac.FsService
CardImageStorage = cardImageStorage; CardImageStorage = cardImageStorage;
CardHeader = new XciHeader(null, cardImageStorage.AsStream()); CardHeader = new XciHeader(Keyset, cardImageStorage.AsStream());
} }
public void RemoveGameCard() public void RemoveGameCard()