PFF model cleanup

This commit is contained in:
Matt Nadareski
2025-10-30 22:56:23 -04:00
parent 6307a51c0a
commit d65edadbbb
7 changed files with 17 additions and 31 deletions

View File

@@ -9,16 +9,16 @@ namespace SabreTools.Data.Models.PFF
/// <summary>
/// Archive header
/// </summary>
public Header? Header { get; set; }
public Header Header { get; set; }
/// <summary>
/// Segments
/// </summary>
public Segment[]? Segments { get; set; }
public Segment[] Segments { get; set; }
/// <summary>
/// Footer
/// </summary>
public Footer? Footer { get; set; }
public Footer Footer { get; set; }
}
}
}

View File

@@ -6,7 +6,7 @@ namespace SabreTools.Data.Models.PFF
public static readonly byte[] Version0SignatureBytes = [0x50, 0x46, 0x46, 0x30];
public const string Version0SignatureString = "PFF0";
public const uint Version0HSegmentSize = 0x00000020;
// Version 1 not confirmed
@@ -33,4 +33,4 @@ namespace SabreTools.Data.Models.PFF
public const string FooterKingTag = "KING";
}
}
}

View File

@@ -23,6 +23,6 @@ namespace SabreTools.Data.Models.PFF
/// King tag
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)]
public string? KingTag;
public string KingTag;
}
}
}

View File

@@ -20,7 +20,7 @@ namespace SabreTools.Data.Models.PFF
/// </summary>
/// <remarks>Versions 2 and 3 share the same signature but different header sizes</remarks>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)]
public string? Signature;
public string Signature;
/// <summary>
/// Number of files
@@ -37,4 +37,4 @@ namespace SabreTools.Data.Models.PFF
/// </summary>
public uint FileListOffset;
}
}
}

View File

@@ -43,4 +43,4 @@ namespace SabreTools.Data.Models.PFF
/// <remarks>Only for version 4</remarks>
public uint CompressionLevel { get; set; }
}
}
}

View File

@@ -23,17 +23,10 @@ namespace SabreTools.Serialization.Wrappers
Print(builder, Model.Footer);
}
private static void Print(StringBuilder builder, Header? header)
private static void Print(StringBuilder builder, Header header)
{
builder.AppendLine(" Header Information:");
builder.AppendLine(" -------------------------");
if (header == null)
{
builder.AppendLine(" No header");
builder.AppendLine();
return;
}
builder.AppendLine(header.HeaderSize, " Header size");
builder.AppendLine(header.Signature, " Signature");
builder.AppendLine(header.NumberOfFiles, " Number of files");
@@ -42,11 +35,11 @@ namespace SabreTools.Serialization.Wrappers
builder.AppendLine();
}
private static void Print(StringBuilder builder, Segment[]? entries)
private static void Print(StringBuilder builder, Segment[] entries)
{
builder.AppendLine(" Segments Information:");
builder.AppendLine(" -------------------------");
if (entries == null || entries.Length == 0)
if (entries.Length == 0)
{
builder.AppendLine(" No segments");
builder.AppendLine();
@@ -70,17 +63,10 @@ namespace SabreTools.Serialization.Wrappers
builder.AppendLine();
}
private static void Print(StringBuilder builder, Footer? footer)
private static void Print(StringBuilder builder, Footer footer)
{
builder.AppendLine(" Footer Information:");
builder.AppendLine(" -------------------------");
if (footer == null)
{
builder.AppendLine(" No footer");
builder.AppendLine();
return;
}
builder.AppendLine(footer.SystemIP, " System IP");
builder.AppendLine(footer.Reserved, " Reserved");
builder.AppendLine(footer.KingTag, " King tag");

View File

@@ -17,10 +17,10 @@ namespace SabreTools.Serialization.Wrappers
/// <summary>
/// Number of files in the archive
/// </summary>
public long FileCount => Model.Header?.NumberOfFiles ?? 0;
public long FileCount => Model.Header.NumberOfFiles;
/// <inheritdoc cref="Archive.Segments"/>
public Segment[] Segments => Model.Segments ?? [];
public Segment[] Segments => Model.Segments;
#endregion