mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Add romfs support to CLI
This commit is contained in:
parent
9276a213bc
commit
38dca5c526
2 changed files with 40 additions and 0 deletions
|
@ -36,6 +36,7 @@ namespace hactoolnet
|
|||
case FileType.Pfs0:
|
||||
break;
|
||||
case FileType.Romfs:
|
||||
ProcessRomFs(ctx);
|
||||
break;
|
||||
case FileType.Nax0:
|
||||
break;
|
||||
|
@ -367,6 +368,43 @@ namespace hactoolnet
|
|||
}
|
||||
}
|
||||
|
||||
private static void ProcessRomFs(Context ctx)
|
||||
{
|
||||
using (var file = new FileStream(ctx.Options.InFile, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
var romfs = new Romfs(file);
|
||||
ProcessRomFs(ctx, romfs);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ProcessRomFs(Context ctx, Romfs romfs)
|
||||
{
|
||||
using (var file = new FileStream(ctx.Options.InFile, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
if (ctx.Options.ListRomFs)
|
||||
{
|
||||
foreach (var romfsFile in romfs.Files)
|
||||
{
|
||||
ctx.Logger.LogMessage(romfsFile.FullPath);
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx.Options.RomfsOut != null)
|
||||
{
|
||||
using (var outFile = new FileStream(ctx.Options.RomfsOut, FileMode.Create, FileAccess.ReadWrite))
|
||||
{
|
||||
var romfsStream = romfs.OpenRawStream();
|
||||
romfsStream.CopyStream(outFile, romfsStream.Length, ctx.Logger);
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx.Options.RomfsOutDir != null)
|
||||
{
|
||||
romfs.Extract(ctx.Options.RomfsOutDir, ctx.Logger);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Nca GetXciMainNca(Xci xci, Context ctx)
|
||||
{
|
||||
if (xci.SecurePartition == null)
|
||||
|
|
|
@ -90,6 +90,8 @@ namespace libhac
|
|||
|
||||
public bool FileExists(string filename) => FileDict.ContainsKey(filename);
|
||||
|
||||
public Stream OpenRawStream() => StreamSource.CreateStream();
|
||||
|
||||
private void SetReferences()
|
||||
{
|
||||
var dirDict = Directories.ToDictionary(x => x.Offset, x => x);
|
||||
|
|
Loading…
Reference in a new issue