mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-07-13 04:16:53 +00:00
Port SGA to new printing
This commit is contained in:
463
BinaryObjectScanner.Printing/SGA.cs
Normal file
463
BinaryObjectScanner.Printing/SGA.cs
Normal file
@@ -0,0 +1,463 @@
|
||||
using System.Text;
|
||||
using SabreTools.Models.SGA;
|
||||
|
||||
namespace BinaryObjectScanner.Printing
|
||||
{
|
||||
public static class SGA
|
||||
{
|
||||
public static void Print(StringBuilder builder, File file)
|
||||
{
|
||||
builder.AppendLine("SGA Information:");
|
||||
builder.AppendLine("-------------------------");
|
||||
builder.AppendLine();
|
||||
|
||||
// Header
|
||||
Print(builder, file.Header);
|
||||
|
||||
// Directory
|
||||
Print(builder, file.Directory);
|
||||
// TODO: Should we print the string table?
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Header header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Header? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (header == null)
|
||||
{
|
||||
builder.AppendLine(" No header");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendLine(header.Signature, " Signature");
|
||||
builder.AppendLine(header.MajorVersion, " Major version");
|
||||
builder.AppendLine(header.MinorVersion, " Minor version");
|
||||
switch (header)
|
||||
{
|
||||
case Header4 header4:
|
||||
builder.AppendLine(header4.FileMD5, " File MD5");
|
||||
builder.AppendLine(header4.Name, " Name");
|
||||
builder.AppendLine(header4.HeaderMD5, " Header MD5");
|
||||
builder.AppendLine(header4.HeaderLength, " Header length");
|
||||
builder.AppendLine(header4.FileDataOffset, " File data offset");
|
||||
builder.AppendLine(header4.Dummy0, " Dummy 0");
|
||||
break;
|
||||
|
||||
case Header6 header6:
|
||||
builder.AppendLine(header6.Name, " Name");
|
||||
builder.AppendLine(header6.HeaderLength, " Header length");
|
||||
builder.AppendLine(header6.FileDataOffset, " File data offset");
|
||||
builder.AppendLine(header6.Dummy0, " Dummy 0");
|
||||
break;
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Directory directory)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Directory? directory)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Directory Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (directory == null)
|
||||
{
|
||||
builder.AppendLine(" No directory");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (directory)
|
||||
{
|
||||
case Directory4 directory4:
|
||||
Print(builder, directory4.DirectoryHeader);
|
||||
Print(builder, directory4.Sections);
|
||||
Print(builder, directory4.Folders);
|
||||
Print(builder, directory4.Files);
|
||||
break;
|
||||
|
||||
case Directory5 directory5:
|
||||
Print(builder, directory5.DirectoryHeader);
|
||||
Print(builder, directory5.Sections);
|
||||
Print(builder, directory5.Folders);
|
||||
Print(builder, directory5.Files);
|
||||
break;
|
||||
|
||||
case Directory6 directory6:
|
||||
Print(builder, directory6.DirectoryHeader);
|
||||
Print(builder, directory6.Sections);
|
||||
Print(builder, directory6.Folders);
|
||||
Print(builder, directory6.Files);
|
||||
break;
|
||||
|
||||
case Directory7 directory7:
|
||||
Print(builder, directory7.DirectoryHeader);
|
||||
Print(builder, directory7.Sections);
|
||||
Print(builder, directory7.Folders);
|
||||
|
||||
/* Unmerged change from project 'b:\Programs\GitHub\BurnOutSharp\BinaryObjectScanner.Printing\BinaryObjectScanner.Printing.csproj ($net6.0)'
|
||||
Before:
|
||||
Print(builder, directory7.Files);
|
||||
After:
|
||||
Print(builder, (File6?[]?)directory7.Files);
|
||||
*/
|
||||
|
||||
/* Unmerged change from project 'b:\Programs\GitHub\BurnOutSharp\BinaryObjectScanner.Printing\BinaryObjectScanner.Printing.csproj ($net7.0)'
|
||||
Before:
|
||||
Print(builder, directory7.Files);
|
||||
After:
|
||||
Print(builder, (File6?[]?)directory7.Files);
|
||||
*/
|
||||
Print(builder, (File6[])directory7.Files);
|
||||
break;
|
||||
|
||||
default:
|
||||
builder.AppendLine($" Unrecognized directory type");
|
||||
break;
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DirectoryHeader4 header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DirectoryHeader4? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Directory Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (header == null)
|
||||
{
|
||||
builder.AppendLine(" No directory header");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendLine(header.SectionOffset, " Section offset");
|
||||
builder.AppendLine(header.SectionCount, " Section count");
|
||||
builder.AppendLine(header.FolderOffset, " Folder offset");
|
||||
builder.AppendLine(header.FolderCount, " Folder count");
|
||||
builder.AppendLine(header.FileOffset, " File offset");
|
||||
builder.AppendLine(header.FileCount, " File count");
|
||||
builder.AppendLine(header.StringTableOffset, " String table offset");
|
||||
builder.AppendLine(header.StringTableCount, " String table count");
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DirectoryHeader5 header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DirectoryHeader5? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Directory Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (header == null)
|
||||
{
|
||||
builder.AppendLine(" No directory header");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendLine(header.SectionOffset, " Section offset");
|
||||
builder.AppendLine(header.SectionCount, " Section count");
|
||||
builder.AppendLine(header.FolderOffset, " Folder offset");
|
||||
builder.AppendLine(header.FolderCount, " Folder count");
|
||||
builder.AppendLine(header.FileOffset, " File offset");
|
||||
builder.AppendLine(header.FileCount, " File count");
|
||||
builder.AppendLine(header.StringTableOffset, " String table offset");
|
||||
builder.AppendLine(header.StringTableCount, " String table count");
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DirectoryHeader7 header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DirectoryHeader7? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Directory Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (header == null)
|
||||
{
|
||||
builder.AppendLine(" No directory header");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendLine(header.SectionOffset, " Section offset");
|
||||
builder.AppendLine(header.SectionCount, " Section count");
|
||||
builder.AppendLine(header.FolderOffset, " Folder offset");
|
||||
builder.AppendLine(header.FolderCount, " Folder count");
|
||||
builder.AppendLine(header.FileOffset, " File offset");
|
||||
builder.AppendLine(header.FileCount, " File count");
|
||||
builder.AppendLine(header.StringTableOffset, " String table offset");
|
||||
builder.AppendLine(header.StringTableCount, " String table count");
|
||||
builder.AppendLine(header.HashTableOffset, " Hash table offset");
|
||||
builder.AppendLine(header.BlockSize, " Block size");
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Section4[] sections)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Section4?[]? sections)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Sections Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (sections == null || sections.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No sections");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < sections.Length; i++)
|
||||
{
|
||||
builder.AppendLine($" Section {i}");
|
||||
var section = sections[i];
|
||||
if (section == null)
|
||||
{
|
||||
builder.AppendLine(" [NULL]");
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.AppendLine(section.Alias, " Alias");
|
||||
builder.AppendLine(section.Name, " Name");
|
||||
builder.AppendLine(section.FolderStartIndex, " Folder start index");
|
||||
builder.AppendLine(section.FolderEndIndex, " Folder end index");
|
||||
builder.AppendLine(section.FileStartIndex, " File start index");
|
||||
builder.AppendLine(section.FileEndIndex, " File end index");
|
||||
builder.AppendLine(section.FolderRootIndex, " Folder root index");
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Section5[] sections)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Section5?[]? sections)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Sections Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (sections == null || sections.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No sections");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < sections.Length; i++)
|
||||
{
|
||||
builder.AppendLine($" Section {i}");
|
||||
var section = sections[i];
|
||||
if (section == null)
|
||||
{
|
||||
builder.AppendLine(" [NULL]");
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.AppendLine(section.Alias, " Alias");
|
||||
builder.AppendLine(section.Name, " Name");
|
||||
builder.AppendLine(section.FolderStartIndex, " Folder start index");
|
||||
builder.AppendLine(section.FolderEndIndex, " Folder end index");
|
||||
builder.AppendLine(section.FileStartIndex, " File start index");
|
||||
builder.AppendLine(section.FileEndIndex, " File end index");
|
||||
builder.AppendLine(section.FolderRootIndex, " Folder root index");
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Folder4[] folders)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Folder4?[]? folders)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Folders Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (folders == null || folders.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No folders");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < folders.Length; i++)
|
||||
{
|
||||
builder.AppendLine($" Folder {i}");
|
||||
var folder = folders[i];
|
||||
if (folder == null)
|
||||
{
|
||||
builder.AppendLine(" [NULL]");
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.AppendLine(folder.NameOffset, " Name offset");
|
||||
builder.AppendLine(folder.Name, " Name");
|
||||
builder.AppendLine(folder.FolderStartIndex, " Folder start index");
|
||||
builder.AppendLine(folder.FolderEndIndex, " Folder end index");
|
||||
builder.AppendLine(folder.FileStartIndex, " File start index");
|
||||
builder.AppendLine(folder.FileEndIndex, " File end index");
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Folder5[] folders)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Folder5?[]? folders)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Folders Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (folders == null || folders.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No folders");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < folders.Length; i++)
|
||||
{
|
||||
builder.AppendLine($" Folder {i}");
|
||||
var folder = folders[i] as Folder5;
|
||||
if (folder == null)
|
||||
{
|
||||
builder.AppendLine(" [NULL]");
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.AppendLine(folder.NameOffset, " Name offset");
|
||||
builder.AppendLine(folder.Name, " Name");
|
||||
builder.AppendLine(folder.FolderStartIndex, " Folder start index");
|
||||
builder.AppendLine(folder.FolderEndIndex, " Folder end index");
|
||||
builder.AppendLine(folder.FileStartIndex, " File start index");
|
||||
builder.AppendLine(folder.FileEndIndex, " File end index");
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, File4[] files)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, File4?[]? files)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Files Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (files == null || files.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No files");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < files.Length; i++)
|
||||
{
|
||||
builder.AppendLine($" File {i}");
|
||||
var file = files[i];
|
||||
if (file == null)
|
||||
{
|
||||
builder.AppendLine(" [NULL]");
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.AppendLine(file.NameOffset, " Name offset");
|
||||
builder.AppendLine(file.Name, " Name");
|
||||
builder.AppendLine(file.Offset, " Offset");
|
||||
builder.AppendLine(file.SizeOnDisk, " Size on disk");
|
||||
builder.AppendLine(file.Size, " Size");
|
||||
builder.AppendLine(file.TimeModified, " Time modified");
|
||||
builder.AppendLine(file.Dummy0, " Dummy 0");
|
||||
builder.AppendLine(file.Type, " Type");
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, File6[] files)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, File6?[]? files)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Files Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (files == null || files.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No files");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < files.Length; i++)
|
||||
{
|
||||
builder.AppendLine($" File {i}");
|
||||
var file = files[i];
|
||||
if (file == null)
|
||||
{
|
||||
builder.AppendLine(" [NULL]");
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.AppendLine(file.NameOffset, " Name offset");
|
||||
builder.AppendLine(file.Name, " Name");
|
||||
builder.AppendLine(file.Offset, " Offset");
|
||||
builder.AppendLine(file.SizeOnDisk, " Size on disk");
|
||||
builder.AppendLine(file.Size, " Size");
|
||||
builder.AppendLine(file.TimeModified, " Time modified");
|
||||
builder.AppendLine(file.Dummy0, " Dummy 0");
|
||||
builder.AppendLine(file.Type, " Type");
|
||||
builder.AppendLine(file.CRC32, " CRC32");
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, File7[] files)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, File7?[]? files)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Files Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (files == null || files.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No files");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < files.Length; i++)
|
||||
{
|
||||
builder.AppendLine($" File {i}");
|
||||
var file = files[i];
|
||||
if (file == null)
|
||||
{
|
||||
builder.AppendLine(" [NULL]");
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.AppendLine(file.NameOffset, " Name offset");
|
||||
builder.AppendLine(file.Name, " Name");
|
||||
builder.AppendLine(file.Offset, " Offset");
|
||||
builder.AppendLine(file.SizeOnDisk, " Size on disk");
|
||||
builder.AppendLine(file.Size, " Size");
|
||||
builder.AppendLine(file.TimeModified, " Time modified");
|
||||
builder.AppendLine(file.Dummy0, " Dummy 0");
|
||||
builder.AppendLine(file.Type, " Type");
|
||||
builder.AppendLine(file.CRC32, " CRC32");
|
||||
builder.AppendLine(file.HashOffset, " Hash offset");
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -478,273 +477,10 @@ namespace BinaryObjectScanner.Wrappers
|
||||
public override StringBuilder PrettyPrint()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.AppendLine("SGA Information:");
|
||||
builder.AppendLine("-------------------------");
|
||||
builder.AppendLine();
|
||||
|
||||
// Header
|
||||
PrintHeader(builder);
|
||||
|
||||
// Directory
|
||||
PrintDirectoryHeader(builder);
|
||||
PrintSections(builder);
|
||||
PrintFolders(builder);
|
||||
PrintFiles(builder);
|
||||
// TODO: Should we print the string table?
|
||||
|
||||
Printing.SGA.Print(builder, _model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Print header information
|
||||
/// </summary>
|
||||
/// <param name="builder">StringBuilder to append information to</param>
|
||||
private void PrintHeader(StringBuilder builder)
|
||||
{
|
||||
builder.AppendLine(" Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
builder.AppendLine($" Signature: {Signature}");
|
||||
builder.AppendLine($" Major version: {MajorVersion} (0x{MajorVersion:X})");
|
||||
builder.AppendLine($" Minor version: {MinorVersion} (0x{MinorVersion:X})");
|
||||
builder.AppendLine($" File MD5: {(FileMD5 == null ? "[NULL]" : BitConverter.ToString(FileMD5).Replace("-", string.Empty))}");
|
||||
builder.AppendLine($" Name: {Name ?? "[NULL]"}");
|
||||
builder.AppendLine($" Header MD5: {(HeaderMD5 == null ? "[NULL]" : BitConverter.ToString(HeaderMD5).Replace("-", string.Empty))}");
|
||||
builder.AppendLine($" Header length: {HeaderLength?.ToString() ?? "[NULL]"} (0x{HeaderLength?.ToString("X") ?? "[NULL]"})");
|
||||
builder.AppendLine($" File data offset: {FileDataOffset?.ToString() ?? "[NULL]"} (0x{FileDataOffset?.ToString("X") ?? "[NULL]"})");
|
||||
builder.AppendLine($" Dummy 0: {Dummy0?.ToString() ?? "[NULL]"} (0x{Dummy0?.ToString("X") ?? "[NULL]"})");
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Print directory header information
|
||||
/// </summary>
|
||||
/// <param name="builder">StringBuilder to append information to</param>
|
||||
private void PrintDirectoryHeader(StringBuilder builder)
|
||||
{
|
||||
builder.AppendLine(" Directory Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
builder.AppendLine($" Section offset: {SectionOffset?.ToString() ?? "[NULL]"} (0x{SectionOffset?.ToString("X") ?? "[NULL]"})");
|
||||
builder.AppendLine($" Section count: {SectionCount?.ToString() ?? "[NULL]"} (0x{SectionCount?.ToString("X") ?? "[NULL]"})");
|
||||
builder.AppendLine($" Folder offset: {FolderOffset?.ToString() ?? "[NULL]"} (0x{FolderOffset?.ToString("X") ?? "[NULL]"})");
|
||||
builder.AppendLine($" Folder count: {FolderCount?.ToString() ?? "[NULL]"} (0x{FolderCount?.ToString("X") ?? "[NULL]"})");
|
||||
builder.AppendLine($" File offset: {FileOffset?.ToString() ?? "[NULL]"} (0x{FileOffset?.ToString("X") ?? "[NULL]"})");
|
||||
builder.AppendLine($" File count: {FileCount?.ToString() ?? "[NULL]"} (0x{FileCount?.ToString("X") ?? "[NULL]"})");
|
||||
builder.AppendLine($" String table offset: {StringTableOffset?.ToString() ?? "[NULL]"} (0x{StringTableOffset?.ToString("X") ?? "[NULL]"})");
|
||||
builder.AppendLine($" String table count: {StringTableCount?.ToString() ?? "[NULL]"} (0x{StringTableCount?.ToString("X") ?? "[NULL]"})");
|
||||
builder.AppendLine($" Hash table offset: {HashTableOffset?.ToString() ?? "[NULL]"} (0x{HashTableOffset?.ToString("X") ?? "[NULL]"})");
|
||||
builder.AppendLine($" Block size: {BlockSize?.ToString() ?? "[NULL]"} (0x{BlockSize?.ToString("X") ?? "[NULL]"})");
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Print sections information
|
||||
/// </summary>
|
||||
/// <param name="builder">StringBuilder to append information to</param>
|
||||
private void PrintSections(StringBuilder builder)
|
||||
{
|
||||
builder.AppendLine(" Sections Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (Sections == null || Sections.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No sections");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < Sections.Length; i++)
|
||||
{
|
||||
builder.AppendLine($" Section {i}");
|
||||
switch (MajorVersion)
|
||||
{
|
||||
case 4:
|
||||
var section4 = Sections[i] as SabreTools.Models.SGA.Section4;
|
||||
if (section4 == null)
|
||||
{
|
||||
builder.AppendLine(" [NULL]");
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.AppendLine($" Alias: {section4.Alias ?? "[NULL]"}");
|
||||
builder.AppendLine($" Name: {section4.Name ?? "[NULL]"}");
|
||||
builder.AppendLine($" Folder start index: {section4.FolderStartIndex} (0x{section4.FolderStartIndex:X})");
|
||||
builder.AppendLine($" Folder end index: {section4.FolderEndIndex} (0x{section4.FolderEndIndex:X})");
|
||||
builder.AppendLine($" File start index: {section4.FileStartIndex} (0x{section4.FileStartIndex:X})");
|
||||
builder.AppendLine($" File end index: {section4.FileEndIndex} (0x{section4.FileEndIndex:X})");
|
||||
builder.AppendLine($" Folder root index: {section4.FolderRootIndex} (0x{section4.FolderRootIndex:X})");
|
||||
break;
|
||||
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
var section5 = Sections[i] as SabreTools.Models.SGA.Section5;
|
||||
if (section5 == null)
|
||||
{
|
||||
builder.AppendLine(" [NULL]");
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.AppendLine($" Alias: {section5.Alias ?? "[NULL]"}");
|
||||
builder.AppendLine($" Name: {section5.Name ?? "[NULL]"}");
|
||||
builder.AppendLine($" Folder start index: {section5.FolderStartIndex} (0x{section5.FolderStartIndex:X})");
|
||||
builder.AppendLine($" Folder end index: {section5.FolderEndIndex} (0x{section5.FolderEndIndex:X})");
|
||||
builder.AppendLine($" File start index: {section5.FileStartIndex} (0x{section5.FileStartIndex:X})");
|
||||
builder.AppendLine($" File end index: {section5.FileEndIndex} (0x{section5.FileEndIndex:X})");
|
||||
builder.AppendLine($" Folder root index: {section5.FolderRootIndex} (0x{section5.FolderRootIndex:X})");
|
||||
break;
|
||||
default:
|
||||
builder.AppendLine($" Unknown format for version {MajorVersion}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Print folders information
|
||||
/// </summary>
|
||||
/// <param name="builder">StringBuilder to append information to</param>
|
||||
private void PrintFolders(StringBuilder builder)
|
||||
{
|
||||
builder.AppendLine(" Folders Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (Folders == null || Folders.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No folders");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < Folders.Length; i++)
|
||||
{
|
||||
builder.AppendLine($" Folder {i}");
|
||||
switch (MajorVersion)
|
||||
{
|
||||
case 4:
|
||||
var folder4 = Folders[i] as SabreTools.Models.SGA.Folder4;
|
||||
if (folder4 == null)
|
||||
{
|
||||
builder.AppendLine(" [NULL]");
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.AppendLine($" Name offset: {folder4.NameOffset} (0x{folder4.NameOffset:X})");
|
||||
builder.AppendLine($" Name: {folder4.Name ?? "[NULL]"}");
|
||||
builder.AppendLine($" Folder start index: {folder4.FolderStartIndex} (0x{folder4.FolderStartIndex:X})");
|
||||
builder.AppendLine($" Folder end index: {folder4.FolderEndIndex} (0x{folder4.FolderEndIndex:X})");
|
||||
builder.AppendLine($" File start index: {folder4.FileStartIndex} (0x{folder4.FileStartIndex:X})");
|
||||
builder.AppendLine($" File end index: {folder4.FileEndIndex} (0x{folder4.FileEndIndex:X})");
|
||||
break;
|
||||
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
var folder5 = Folders[i] as SabreTools.Models.SGA.Folder5;
|
||||
if (folder5 == null)
|
||||
{
|
||||
builder.AppendLine(" [NULL]");
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.AppendLine($" Name offset: {folder5.NameOffset} (0x{folder5.NameOffset:X})");
|
||||
builder.AppendLine($" Name: {folder5.Name ?? "[NULL]"}");
|
||||
builder.AppendLine($" Folder start index: {folder5.FolderStartIndex} (0x{folder5.FolderStartIndex:X})");
|
||||
builder.AppendLine($" Folder end index: {folder5.FolderEndIndex} (0x{folder5.FolderEndIndex:X})");
|
||||
builder.AppendLine($" File start index: {folder5.FileStartIndex} (0x{folder5.FileStartIndex:X})");
|
||||
builder.AppendLine($" File end index: {folder5.FileEndIndex} (0x{folder5.FileEndIndex:X})");
|
||||
break;
|
||||
default:
|
||||
builder.AppendLine($" Unknown format for version {MajorVersion}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Print files information
|
||||
/// </summary>
|
||||
/// <param name="builder">StringBuilder to append information to</param>
|
||||
private void PrintFiles(StringBuilder builder)
|
||||
{
|
||||
builder.AppendLine(" Files Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (Files == null || Files.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No files");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < Files.Length; i++)
|
||||
{
|
||||
builder.AppendLine($" File {i}");
|
||||
switch (MajorVersion)
|
||||
{
|
||||
case 4:
|
||||
case 5:
|
||||
var file4 = Files[i] as SabreTools.Models.SGA.File4;
|
||||
if (file4 == null)
|
||||
{
|
||||
builder.AppendLine(" [NULL]");
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.AppendLine($" Name offset: {file4.NameOffset} (0x{file4.NameOffset:X})");
|
||||
builder.AppendLine($" Name: {file4.Name ?? "[NULL]"}");
|
||||
builder.AppendLine($" Offset: {file4.Offset} (0x{file4.Offset:X})");
|
||||
builder.AppendLine($" Size on disk: {file4.SizeOnDisk} (0x{file4.SizeOnDisk:X})");
|
||||
builder.AppendLine($" Size: {file4.Size} (0x{file4.Size:X})");
|
||||
builder.AppendLine($" Time modified: {file4.TimeModified} (0x{file4.TimeModified:X})");
|
||||
builder.AppendLine($" Dummy 0: {file4.Dummy0} (0x{file4.Dummy0:X})");
|
||||
builder.AppendLine($" Type: {file4.Type} (0x{file4.Type:X})");
|
||||
break;
|
||||
|
||||
case 6:
|
||||
var file6 = Files[i] as SabreTools.Models.SGA.File6;
|
||||
if (file6 == null)
|
||||
{
|
||||
builder.AppendLine(" [NULL]");
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.AppendLine($" Name offset: {file6.NameOffset} (0x{file6.NameOffset:X})");
|
||||
builder.AppendLine($" Name: {file6.Name ?? "[NULL]"}");
|
||||
builder.AppendLine($" Offset: {file6.Offset} (0x{file6.Offset:X})");
|
||||
builder.AppendLine($" Size on disk: {file6.SizeOnDisk} (0x{file6.SizeOnDisk:X})");
|
||||
builder.AppendLine($" Size: {file6.Size} (0x{file6.Size:X})");
|
||||
builder.AppendLine($" Time modified: {file6.TimeModified} (0x{file6.TimeModified:X})");
|
||||
builder.AppendLine($" Dummy 0: {file6.Dummy0} (0x{file6.Dummy0:X})");
|
||||
builder.AppendLine($" Type: {file6.Type} (0x{file6.Type:X})");
|
||||
builder.AppendLine($" CRC32: {file6.CRC32} (0x{file6.CRC32:X})");
|
||||
break;
|
||||
case 7:
|
||||
var file7 = Files[i] as SabreTools.Models.SGA.File7;
|
||||
if (file7 == null)
|
||||
{
|
||||
builder.AppendLine(" [NULL]");
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.AppendLine($" Name offset: {file7.NameOffset} (0x{file7.NameOffset:X})");
|
||||
builder.AppendLine($" Name: {file7.Name ?? "[NULL]"}");
|
||||
builder.AppendLine($" Offset: {file7.Offset} (0x{file7.Offset:X})");
|
||||
builder.AppendLine($" Size on disk: {file7.SizeOnDisk} (0x{file7.SizeOnDisk:X})");
|
||||
builder.AppendLine($" Size: {file7.Size} (0x{file7.Size:X})");
|
||||
builder.AppendLine($" Time modified: {file7.TimeModified} (0x{file7.TimeModified:X})");
|
||||
builder.AppendLine($" Dummy 0: {file7.Dummy0} (0x{file7.Dummy0:X})");
|
||||
builder.AppendLine($" Type: {file7.Type} (0x{file7.Type:X})");
|
||||
builder.AppendLine($" CRC32: {file7.CRC32} (0x{file7.CRC32:X})");
|
||||
builder.AppendLine($" Hash offset: {file7.HashOffset} (0x{file7.HashOffset:X})");
|
||||
break;
|
||||
default:
|
||||
builder.AppendLine($" Unknown format for version {MajorVersion}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
Reference in New Issue
Block a user