From b517085e92ef9e7554ad3ada4b8377c4ba949ebb Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Mon, 7 Oct 2019 19:01:53 -0500 Subject: [PATCH] Add DefaultFsServerObjects for creating a default server instance --- .../FsService/Creators/FileSystemCreators.cs | 24 +------------ .../FsService/DefaultFsServerObjects.cs | 34 +++++++++++++++++++ src/LibHac/FsService/EmulatedGameCard.cs | 9 ++++- 3 files changed, 43 insertions(+), 24 deletions(-) create mode 100644 src/LibHac/FsService/DefaultFsServerObjects.cs diff --git a/src/LibHac/FsService/Creators/FileSystemCreators.cs b/src/LibHac/FsService/Creators/FileSystemCreators.cs index 08b35243..c9c048a9 100644 --- a/src/LibHac/FsService/Creators/FileSystemCreators.cs +++ b/src/LibHac/FsService/Creators/FileSystemCreators.cs @@ -1,6 +1,4 @@ -using LibHac.Fs; - -namespace LibHac.FsService.Creators +namespace LibHac.FsService.Creators { public class FileSystemCreators { @@ -20,25 +18,5 @@ namespace LibHac.FsService.Creators public IMemoryStorageCreator MemoryStorageCreator { get; set; } public IBuiltInStorageFileSystemCreator BuiltInStorageFileSystemCreator { 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); - } } } diff --git a/src/LibHac/FsService/DefaultFsServerObjects.cs b/src/LibHac/FsService/DefaultFsServerObjects.cs new file mode 100644 index 00000000..9ea1f4c2 --- /dev/null +++ b/src/LibHac/FsService/DefaultFsServerObjects.cs @@ -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 + }; + } + } +} diff --git a/src/LibHac/FsService/EmulatedGameCard.cs b/src/LibHac/FsService/EmulatedGameCard.cs index e3e8ec25..121fc03c 100644 --- a/src/LibHac/FsService/EmulatedGameCard.cs +++ b/src/LibHac/FsService/EmulatedGameCard.cs @@ -9,7 +9,14 @@ namespace LibHac.FsService private IStorage CardImageStorage { get; set; } private int Handle { get; set; } private XciHeader CardHeader { get; set; } + private Keyset Keyset { get; set; } + public EmulatedGameCard() { } + + public EmulatedGameCard(Keyset keyset) + { + Keyset = keyset; + } public GameCardHandle GetGameCardHandle() { return new GameCardHandle(Handle); @@ -31,7 +38,7 @@ namespace LibHac.FsService CardImageStorage = cardImageStorage; - CardHeader = new XciHeader(null, cardImageStorage.AsStream()); + CardHeader = new XciHeader(Keyset, cardImageStorage.AsStream()); } public void RemoveGameCard()