mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Add RomFS building to hactoolnet
This commit is contained in:
parent
16e97bda8c
commit
5a0cd17dbf
5 changed files with 57 additions and 7 deletions
19
README.md
19
README.md
|
@ -18,9 +18,10 @@ Options:
|
|||
-y, --verify Verify all hashes in the input file.
|
||||
-h, --enablehash Enable hash checks when reading the input file.
|
||||
-k, --keyset Load keys from an external file.
|
||||
-t, --intype=type Specify input file type [nca, xci, romfs, pk11, pk21, ini1, kip1, switchfs, save, keygen]
|
||||
-t, --intype=type Specify input file type [nca, xci, romfs, pk11, pk21, ini1, kip1, switchfs, save, ndv0, keygen, romfsbuild]
|
||||
--titlekeys <file> Load title keys from an external file.
|
||||
NCA options:
|
||||
--plaintext <file> Specify file path for saving a decrypted copy of the NCA.
|
||||
--section0 <file> Specify Section 0 file path.
|
||||
--section1 <file> Specify Section 1 file path.
|
||||
--section2 <file> Specify Section 2 file path.
|
||||
|
@ -29,15 +30,18 @@ NCA options:
|
|||
--section1dir <dir> Specify Section 1 directory path.
|
||||
--section2dir <dir> Specify Section 2 directory path.
|
||||
--section3dir <dir> Specify Section 3 directory path.
|
||||
--exefs <file> Specify ExeFS directory path.
|
||||
--exefs <file> Specify ExeFS file path.
|
||||
--exefsdir <dir> Specify ExeFS directory path.
|
||||
--romfs <file> Specify RomFS directory path.
|
||||
--romfs <file> Specify RomFS file path.
|
||||
--romfsdir <dir> Specify RomFS directory path.
|
||||
--listromfs List files in RomFS.
|
||||
--basenca Set Base NCA to use with update partitions.
|
||||
RomFS options:
|
||||
--romfsdir <dir> Specify RomFS directory path.
|
||||
--listromfs List files in RomFS.
|
||||
RomFS creation options:
|
||||
Input path must be a directory
|
||||
--outfile <file> Specify created RomFS file path.
|
||||
XCI options:
|
||||
--rootdir <dir> Specify root XCI directory path.
|
||||
--updatedir <dir> Specify update XCI directory path.
|
||||
|
@ -60,6 +64,7 @@ Switch FS options:
|
|||
--sdseed <seed> Set console unique seed for SD card NAX0 encryption.
|
||||
--listapps List application info.
|
||||
--listtitles List title info for all titles.
|
||||
--listncas List info for all NCAs.
|
||||
--title <title id> Specify title ID to use.
|
||||
--outdir <dir> Specify directory path to save title NCAs to. (--title must be specified)
|
||||
--exefs <file> Specify ExeFS directory path. (--title must be specified)
|
||||
|
@ -68,10 +73,16 @@ Switch FS options:
|
|||
--romfsdir <dir> Specify RomFS directory path. (--title must be specified)
|
||||
--savedir <dir> Specify save file directory path.
|
||||
-y, --verify Verify all titles, or verify a single title if --title is set.
|
||||
Savefile options:
|
||||
Save data options:
|
||||
--outdir <dir> Specify directory path to save contents to.
|
||||
--debugoutdir <dir> Specify directory path to save intermediate data to for debugging.
|
||||
--sign Sign the save file. (Requires device_key in key file)
|
||||
--listfiles List files in save file.
|
||||
--replacefile <filename in save> <file> Replaces a file in the save data
|
||||
NDV0 (Delta) options:
|
||||
Input delta patch can be a delta NCA file or a delta fragment file.
|
||||
--basefile <file> Specify base file path.
|
||||
--outfile Specify patched file path.
|
||||
Keygen options:
|
||||
--outdir <dir> Specify directory path to save key files to.
|
||||
```
|
||||
|
|
|
@ -162,7 +162,7 @@ namespace hactoolnet
|
|||
sb.AppendLine(" -y, --verify Verify all hashes in the input file.");
|
||||
sb.AppendLine(" -h, --enablehash Enable hash checks when reading the input file.");
|
||||
sb.AppendLine(" -k, --keyset Load keys from an external file.");
|
||||
sb.AppendLine(" -t, --intype=type Specify input file type [nca, xci, romfs, pk11, pk21, ini1, kip1, switchfs, save, ndv0, keygen]");
|
||||
sb.AppendLine(" -t, --intype=type Specify input file type [nca, xci, romfs, pk11, pk21, ini1, kip1, switchfs, save, ndv0, keygen, romfsbuild]");
|
||||
sb.AppendLine(" --titlekeys <file> Load title keys from an external file.");
|
||||
sb.AppendLine("NCA options:");
|
||||
sb.AppendLine(" --plaintext <file> Specify file path for saving a decrypted copy of the NCA.");
|
||||
|
@ -174,15 +174,18 @@ namespace hactoolnet
|
|||
sb.AppendLine(" --section1dir <dir> Specify Section 1 directory path.");
|
||||
sb.AppendLine(" --section2dir <dir> Specify Section 2 directory path.");
|
||||
sb.AppendLine(" --section3dir <dir> Specify Section 3 directory path.");
|
||||
sb.AppendLine(" --exefs <file> Specify ExeFS directory path.");
|
||||
sb.AppendLine(" --exefs <file> Specify ExeFS file path.");
|
||||
sb.AppendLine(" --exefsdir <dir> Specify ExeFS directory path.");
|
||||
sb.AppendLine(" --romfs <file> Specify RomFS directory path.");
|
||||
sb.AppendLine(" --romfs <file> Specify RomFS file path.");
|
||||
sb.AppendLine(" --romfsdir <dir> Specify RomFS directory path.");
|
||||
sb.AppendLine(" --listromfs List files in RomFS.");
|
||||
sb.AppendLine(" --basenca Set Base NCA to use with update partitions.");
|
||||
sb.AppendLine("RomFS options:");
|
||||
sb.AppendLine(" --romfsdir <dir> Specify RomFS directory path.");
|
||||
sb.AppendLine(" --listromfs List files in RomFS.");
|
||||
sb.AppendLine("RomFS creation options:");
|
||||
sb.AppendLine(" Input path must be a directory");
|
||||
sb.AppendLine(" --outfile <file> Specify created RomFS file path.");
|
||||
sb.AppendLine("XCI options:");
|
||||
sb.AppendLine(" --rootdir <dir> Specify root XCI directory path.");
|
||||
sb.AppendLine(" --updatedir <dir> Specify update XCI directory path.");
|
||||
|
|
|
@ -64,6 +64,7 @@ namespace hactoolnet
|
|||
Pfs0,
|
||||
Nsp,
|
||||
Romfs,
|
||||
RomfsBuild,
|
||||
Nax0,
|
||||
Xci,
|
||||
SwitchFs,
|
||||
|
|
32
src/hactoolnet/ProcessRomFsBuild.cs
Normal file
32
src/hactoolnet/ProcessRomFsBuild.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using System.IO;
|
||||
using LibHac.IO;
|
||||
using LibHac.IO.RomFs;
|
||||
|
||||
namespace hactoolnet
|
||||
{
|
||||
internal static class ProcessRomFsBuild
|
||||
{
|
||||
public static void Process(Context ctx)
|
||||
{
|
||||
if (ctx.Options.OutFile == null)
|
||||
{
|
||||
ctx.Logger.LogMessage("Output file must be specified.");
|
||||
return;
|
||||
}
|
||||
|
||||
var localFs = new LocalFileSystem(ctx.Options.InFile);
|
||||
|
||||
var builder = new RomFsBuilder(localFs);
|
||||
IStorage romfs = builder.Build();
|
||||
|
||||
ctx.Logger.LogMessage($"Building RomFS as {ctx.Options.OutFile}");
|
||||
|
||||
using (var outFile = new FileStream(ctx.Options.OutFile, FileMode.Create, FileAccess.ReadWrite))
|
||||
{
|
||||
romfs.CopyToStream(outFile, romfs.Length, ctx.Logger);
|
||||
}
|
||||
|
||||
ctx.Logger.LogMessage($"Finished writing {ctx.Options.OutFile}");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -64,6 +64,9 @@ namespace hactoolnet
|
|||
case FileType.Romfs:
|
||||
ProcessRomfs.Process(ctx);
|
||||
break;
|
||||
case FileType.RomfsBuild:
|
||||
ProcessRomFsBuild.Process(ctx);
|
||||
break;
|
||||
case FileType.Nax0:
|
||||
break;
|
||||
case FileType.SwitchFs:
|
||||
|
|
Loading…
Reference in a new issue