hactoolnet: Use FileSystemClient instead of Horizon

This commit is contained in:
Alex Barney 2020-04-06 22:17:04 -07:00
parent 1b1e8e6780
commit 5018bbad6a
4 changed files with 14 additions and 11 deletions

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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)