From 5018bbad6af97177f2945740eff1aba5a3541043 Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Mon, 6 Apr 2020 22:17:04 -0700 Subject: [PATCH] hactoolnet: Use FileSystemClient instead of Horizon --- src/hactoolnet/Options.cs | 3 ++- src/hactoolnet/ProcessNca.cs | 12 +++++++----- src/hactoolnet/ProcessSave.cs | 2 +- src/hactoolnet/Program.cs | 8 ++++---- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/hactoolnet/Options.cs b/src/hactoolnet/Options.cs index 4a633aab..447280b9 100644 --- a/src/hactoolnet/Options.cs +++ b/src/hactoolnet/Options.cs @@ -1,4 +1,5 @@ using LibHac; +using LibHac.Fs; using LibHac.FsSystem; namespace hactoolnet @@ -93,6 +94,6 @@ namespace hactoolnet public Options Options; public Keyset Keyset; public ProgressBar Logger; - public Horizon Horizon; + public FileSystemClient FsClient; } } diff --git a/src/hactoolnet/ProcessNca.cs b/src/hactoolnet/ProcessNca.cs index 47697630..eef9771e 100644 --- a/src/hactoolnet/ProcessNca.cs +++ b/src/hactoolnet/ProcessNca.cs @@ -44,7 +44,7 @@ namespace hactoolnet if (ctx.Options.SectionOutDir[i] != null) { - FileSystemClient fs = ctx.Horizon.Fs; + FileSystemClient fs = ctx.FsClient; string mountName = $"section{i}"; @@ -95,7 +95,7 @@ namespace hactoolnet if (ctx.Options.RomfsOutDir != null) { - FileSystemClient fs = ctx.Horizon.Fs; + FileSystemClient fs = ctx.FsClient; fs.Register("rom".ToU8Span(), OpenFileSystemByType(NcaSectionType.Data)); fs.Register("output".ToU8Span(), new LocalFileSystem(ctx.Options.RomfsOutDir)); @@ -152,7 +152,7 @@ namespace hactoolnet if (ctx.Options.ExefsOutDir != null) { - FileSystemClient fs = ctx.Horizon.Fs; + FileSystemClient fs = ctx.FsClient; fs.Register("code".ToU8Span(), OpenFileSystemByType(NcaSectionType.Code)); fs.Register("output".ToU8Span(), new LocalFileSystem(ctx.Options.ExefsOutDir)); @@ -232,10 +232,12 @@ namespace hactoolnet PrintItem(sb, colLen, $"NPDM Signature{nca.VerifySignature2().GetValidityString()}:", nca.Header.Signature2.ToArray()); PrintItem(sb, colLen, "Content Size:", $"0x{nca.Header.NcaSize:x12}"); PrintItem(sb, colLen, "TitleID:", $"{nca.Header.TitleId:X16}"); - if (nca.CanOpenSection(NcaSectionType.Code)) { + if (nca.CanOpenSection(NcaSectionType.Code)) + { IFileSystem fs = nca.OpenFileSystem(NcaSectionType.Code, IntegrityCheckLevel.None); Result r = fs.OpenFile(out IFile file, "/main.npdm".ToU8String(), OpenMode.Read); - if (r.IsSuccess()) { + if (r.IsSuccess()) + { var npdm = new NpdmBinary(file.AsStream(), null); PrintItem(sb, colLen, "Title Name:", npdm.TitleName); } diff --git a/src/hactoolnet/ProcessSave.cs b/src/hactoolnet/ProcessSave.cs index 170b0b55..e663fccb 100644 --- a/src/hactoolnet/ProcessSave.cs +++ b/src/hactoolnet/ProcessSave.cs @@ -29,7 +29,7 @@ namespace hactoolnet bool signNeeded = ctx.Options.SignSave; var save = new SaveDataFileSystem(ctx.Keyset, file, ctx.Options.IntegrityLevel, true); - FileSystemClient fs = ctx.Horizon.Fs; + FileSystemClient fs = ctx.FsClient; fs.Register("save".ToU8Span(), save); diff --git a/src/hactoolnet/Program.cs b/src/hactoolnet/Program.cs index 108f8526..f2b4ab8a 100644 --- a/src/hactoolnet/Program.cs +++ b/src/hactoolnet/Program.cs @@ -59,17 +59,17 @@ namespace hactoolnet using (var logger = new ProgressBar()) { ctx.Logger = logger; - ctx.Horizon = new Horizon(new StopWatchTimeSpanGenerator()); + ctx.FsClient = new FileSystemClient(new StopWatchTimeSpanGenerator()); if (ctx.Options.AccessLog != null) { logWriter = new StreamWriter(ctx.Options.AccessLog); var accessLog = new TextWriterAccessLog(logWriter); - ctx.Horizon.Fs.SetAccessLogTarget(AccessLogTarget.All); - ctx.Horizon.Fs.SetGlobalAccessLogMode(GlobalAccessLogMode.Log); + ctx.FsClient.SetAccessLogTarget(AccessLogTarget.All); + ctx.FsClient.SetGlobalAccessLogMode(GlobalAccessLogMode.Log); - ctx.Horizon.Fs.SetAccessLogObject(accessLog); + ctx.FsClient.SetAccessLogObject(accessLog); } if (ctx.Options.ResultLog != null)