From 172817a7d5c5164e3a0826e71dfc0232cd0c5b16 Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Thu, 24 Oct 2019 13:17:08 -0500 Subject: [PATCH] Make EmulatedSdFileSystemCreator config easier Also make unintentionally internal classes public and enforce var style --- .../Creators/EmulatedSdFileSystemCreator.cs | 22 ++++++++++++++----- .../FsService/EmulatedDeviceOperator.cs | 2 +- src/hactoolnet/ProcessNca.cs | 4 ++-- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/LibHac/FsService/Creators/EmulatedSdFileSystemCreator.cs b/src/LibHac/FsService/Creators/EmulatedSdFileSystemCreator.cs index 8000510d..aee47b1a 100644 --- a/src/LibHac/FsService/Creators/EmulatedSdFileSystemCreator.cs +++ b/src/LibHac/FsService/Creators/EmulatedSdFileSystemCreator.cs @@ -3,20 +3,26 @@ using LibHac.Fs; namespace LibHac.FsService.Creators { - class EmulatedSdFileSystemCreator : ISdFileSystemCreator + public class EmulatedSdFileSystemCreator : ISdFileSystemCreator { private const string DefaultPath = "/sdcard"; - public IFileSystem RootFileSystem { get; set; } - public string Path { get; set; } + private IFileSystem RootFileSystem { get; } + private string Path { get; } - public IFileSystem SdCardFileSystem { get; set; } + private IFileSystem SdCardFileSystem { get; set; } public EmulatedSdFileSystemCreator(IFileSystem rootFileSystem) { RootFileSystem = rootFileSystem; } + public EmulatedSdFileSystemCreator(IFileSystem rootFileSystem, string path) + { + RootFileSystem = rootFileSystem; + Path = path; + } + public Result Create(out IFileSystem fileSystem) { fileSystem = default; @@ -37,7 +43,13 @@ namespace LibHac.FsService.Creators // Todo: Add ProxyFileSystem? - return Util.CreateSubFileSystem(out fileSystem, RootFileSystem, path, true); + Result rc = Util.CreateSubFileSystem(out IFileSystem sdFileSystem, RootFileSystem, path, true); + if (rc.IsFailure()) return rc; + + SdCardFileSystem = sdFileSystem; + fileSystem = sdFileSystem; + + return Result.Success; } public Result Format(bool closeOpenEntries) diff --git a/src/LibHac/FsService/EmulatedDeviceOperator.cs b/src/LibHac/FsService/EmulatedDeviceOperator.cs index 5e529756..e1378f96 100644 --- a/src/LibHac/FsService/EmulatedDeviceOperator.cs +++ b/src/LibHac/FsService/EmulatedDeviceOperator.cs @@ -3,7 +3,7 @@ using LibHac.Fs; namespace LibHac.FsService { - class EmulatedDeviceOperator : IDeviceOperator + public class EmulatedDeviceOperator : IDeviceOperator { private EmulatedGameCard GameCard { get; set; } diff --git a/src/hactoolnet/ProcessNca.cs b/src/hactoolnet/ProcessNca.cs index 9a078e85..169d19d4 100644 --- a/src/hactoolnet/ProcessNca.cs +++ b/src/hactoolnet/ProcessNca.cs @@ -234,9 +234,9 @@ namespace hactoolnet PrintItem(sb, colLen, "TitleID:", $"{nca.Header.TitleId:X16}"); if (nca.CanOpenSection(NcaSectionType.Code)) { IFileSystem fs = nca.OpenFileSystem(NcaSectionType.Code, IntegrityCheckLevel.None); - Result r = fs.OpenFile(out var file, "/main.npdm", OpenMode.Read); + Result r = fs.OpenFile(out IFile file, "/main.npdm", OpenMode.Read); if (r.IsSuccess()) { - NpdmBinary npdm = new NpdmBinary(file.AsStream(), null); + var npdm = new NpdmBinary(file.AsStream(), null); PrintItem(sb, colLen, "Title Name:", npdm.TitleName); } }