mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-11-18 02:10:38 +00:00
PAK model cleanup
This commit is contained in:
@@ -8,4 +8,4 @@ namespace SabreTools.Data.Models.PAK
|
||||
|
||||
public const uint SignatureUInt32 = 0x4b434150;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace SabreTools.Data.Models.PAK
|
||||
/// Item Name
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 56)]
|
||||
public string? ItemName;
|
||||
public string ItemName;
|
||||
|
||||
/// <summary>
|
||||
/// Item Offset
|
||||
|
||||
@@ -9,11 +9,11 @@ namespace SabreTools.Data.Models.PAK
|
||||
/// <summary>
|
||||
/// Deserialized directory header data
|
||||
/// </summary>
|
||||
public Header? Header { get; set; }
|
||||
public Header Header { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Deserialized directory items data
|
||||
/// </summary>
|
||||
public DirectoryItem[]? DirectoryItems { get; set; }
|
||||
public DirectoryItem[] DirectoryItems { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace SabreTools.Data.Models.PAK
|
||||
/// Signature
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)]
|
||||
public string? Signature;
|
||||
public string Signature;
|
||||
|
||||
/// <summary>
|
||||
/// Directory Offset
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
public bool Extract(string outputDirectory, bool includeDebug)
|
||||
{
|
||||
// If we have no directory items
|
||||
if (DirectoryItems == null || DirectoryItems.Length == 0)
|
||||
if (DirectoryItems.Length == 0)
|
||||
return false;
|
||||
|
||||
// Loop through and extract all files to the output
|
||||
@@ -32,7 +32,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
public bool ExtractFile(int index, string outputDirectory, bool includeDebug)
|
||||
{
|
||||
// If we have no directory items
|
||||
if (DirectoryItems == null || DirectoryItems.Length == 0)
|
||||
if (DirectoryItems.Length == 0)
|
||||
return false;
|
||||
|
||||
// If the directory item index is invalid
|
||||
@@ -50,7 +50,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
return false;
|
||||
|
||||
// Ensure directory separators are consistent
|
||||
string filename = directoryItem.ItemName ?? $"file{index}";
|
||||
string filename = directoryItem.ItemName.Length == 0 ? $"file{index}" : directoryItem.ItemName;
|
||||
if (Path.DirectorySeparatorChar == '\\')
|
||||
filename = filename.Replace('/', '\\');
|
||||
else if (Path.DirectorySeparatorChar == '/')
|
||||
|
||||
@@ -22,28 +22,21 @@ namespace SabreTools.Serialization.Wrappers
|
||||
Print(builder, Model.DirectoryItems);
|
||||
}
|
||||
|
||||
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.Signature, " Signature");
|
||||
builder.AppendLine(header.DirectoryOffset, " Directory offset");
|
||||
builder.AppendLine(header.DirectoryLength, " Directory length");
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, DirectoryItem[]? entries)
|
||||
private static void Print(StringBuilder builder, DirectoryItem[] entries)
|
||||
{
|
||||
builder.AppendLine(" Directory Items Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (entries == null || entries.Length == 0)
|
||||
if (entries.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No directory items");
|
||||
builder.AppendLine();
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
#region Extension Properties
|
||||
|
||||
/// <inheritdoc cref="Models.PAK.File.DirectoryItems"/>
|
||||
public DirectoryItem[] DirectoryItems => Model.DirectoryItems ?? [];
|
||||
public DirectoryItem[] DirectoryItems => Model.DirectoryItems;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user