Adjust PFS0 printing

This commit is contained in:
Alex Barney 2018-10-03 15:09:20 -05:00
parent 58226afd7b
commit 67ad322310
3 changed files with 21 additions and 21 deletions

View file

@ -189,11 +189,9 @@ namespace LibHac
headerDec.Read(headerBytes, 0, headerBytes.Length); headerDec.Read(headerBytes, 0, headerBytes.Length);
} }
using (var reader = new BinaryReader(new MemoryStream(headerBytes))) var reader = new BinaryReader(new MemoryStream(headerBytes));
{
Header = new NcaHeader(reader);
}
Header = new NcaHeader(reader);
} }
private void DecryptKeyArea(Keyset keyset) private void DecryptKeyArea(Keyset keyset)
@ -261,10 +259,9 @@ namespace LibHac
long offset = sect.Header.Bktr.SubsectionHeader.Offset; long offset = sect.Header.Bktr.SubsectionHeader.Offset;
using (var streamDec = new RandomAccessSectorStream(new Aes128CtrStream(GetStream(), DecryptedKeys[2], sect.Offset, sect.Size, sect.Offset, sect.Header.Ctr))) using (var streamDec = new RandomAccessSectorStream(new Aes128CtrStream(GetStream(), DecryptedKeys[2], sect.Offset, sect.Size, sect.Offset, sect.Header.Ctr)))
{ {
using (var reader = new BinaryReader(streamDec)) var reader = new BinaryReader(streamDec);
{
streamDec.Position = offset + 8; streamDec.Position = offset + 8;
var size = reader.ReadInt64(); long size = reader.ReadInt64();
if (size != offset) if (size != offset)
{ {
@ -272,7 +269,6 @@ namespace LibHac
} }
} }
} }
}
private void ValidateSuperblockHash(int index) private void ValidateSuperblockHash(int index)
{ {
@ -371,7 +367,6 @@ namespace LibHac
section.Position = dataOffset; section.Position = dataOffset;
logger?.SetTotal(blockCount); logger?.SetTotal(blockCount);
for (long i = 0; i < blockCount; i++) for (long i = 0; i < blockCount; i++)
{ {
var remaining = (dataLen - i * blockSize); var remaining = (dataLen - i * blockSize);

View file

@ -79,7 +79,7 @@ namespace hactoolnet
if (ctx.Options.ExefsOutDir != null || ctx.Options.ExefsOut != null) if (ctx.Options.ExefsOutDir != null || ctx.Options.ExefsOut != null)
{ {
NcaSection section = nca.Sections.FirstOrDefault(x => x.IsExefs); NcaSection section = nca.Sections.FirstOrDefault(x => x?.IsExefs == true);
if (section == null) if (section == null)
{ {

View file

@ -1,5 +1,4 @@
using System.IO; using System.IO;
using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using LibHac; using LibHac;
@ -25,7 +24,8 @@ namespace hactoolnet
private static string Print(this Pfs pfs) private static string Print(this Pfs pfs)
{ {
const int colLen = 65; const int colLen = 36;
const int fileNameLen = 39;
var sb = new StringBuilder(); var sb = new StringBuilder();
sb.AppendLine(); sb.AppendLine();
@ -35,10 +35,15 @@ namespace hactoolnet
PrintItem(sb, colLen, "Magic:", pfs.Header.Magic); PrintItem(sb, colLen, "Magic:", pfs.Header.Magic);
PrintItem(sb, colLen, "Number of files:", pfs.Header.NumFiles); PrintItem(sb, colLen, "Number of files:", pfs.Header.NumFiles);
sb.AppendLine("Files:"); for (int i = 0; i < pfs.Files.Length; i++)
foreach (PfsFileEntry file in pfs.Files.OrderBy(x => x.Offset))
{ {
PrintItem(sb, colLen, $"{file.Name}", $"{file.Offset:x12}-{file.Offset + file.Size:x12}"); PfsFileEntry file = pfs.Files[i];
string label = i == 0 ? "Files:" : "";
string offsets = $"{file.Offset:x12}-{file.Offset + file.Size:x12}{file.HashValidity.GetValidityString()}";
string data = $"pfs0:/{file.Name}".PadRight(fileNameLen) + offsets;
PrintItem(sb, colLen, label, data);
} }
return sb.ToString(); return sb.ToString();