mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-02-04 05:36:12 +00:00
CFB model cleanup
This commit is contained in:
@@ -12,7 +12,7 @@ namespace SabreTools.Data.Models.CFB
|
||||
/// <summary>
|
||||
/// Compound file header
|
||||
/// </summary>
|
||||
public FileHeader? Header { get; set; }
|
||||
public FileHeader Header { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The FAT is the main allocator for space within a compound file.
|
||||
@@ -22,10 +22,10 @@ namespace SabreTools.Data.Models.CFB
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If Header Major Version is 3, there MUST be 128 fields specified to fill a 512-byte sector.
|
||||
///
|
||||
///
|
||||
/// If Header Major Version is 4, there MUST be 1,024 fields specified to fill a 4,096-byte sector
|
||||
/// </remarks>
|
||||
public SectorNumber[]? FATSectorNumbers { get; set; }
|
||||
public SectorNumber[] FATSectorNumbers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The mini FAT is used to allocate space in the mini stream.
|
||||
@@ -35,10 +35,10 @@ namespace SabreTools.Data.Models.CFB
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If Header Major Version is 3, there MUST be 128 fields specified to fill a 512-byte sector.
|
||||
///
|
||||
///
|
||||
/// If Header Major Version is 4, there MUST be 1,024 fields specified to fill a 4,096-byte sector
|
||||
/// </remarks>
|
||||
public SectorNumber[]? MiniFATSectorNumbers { get; set; }
|
||||
public SectorNumber[] MiniFATSectorNumbers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The DIFAT array is used to represent storage of the FAT sectors.
|
||||
@@ -51,11 +51,11 @@ namespace SabreTools.Data.Models.CFB
|
||||
/// <remarks>
|
||||
/// If Header Major Version is 3, there MUST be 127 fields specified to
|
||||
/// fill a 512-byte sector minus the "Next DIFAT Sector Location" field.
|
||||
///
|
||||
///
|
||||
/// If Header Major Version is 4, there MUST be 1,023 fields specified
|
||||
/// to fill a 4,096-byte sector minus the "Next DIFAT Sector Location" field.
|
||||
/// </remarks>
|
||||
public SectorNumber[]? DIFATSectorNumbers { get; set; }
|
||||
public SectorNumber[] DIFATSectorNumbers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The directory entry array is an array of directory entries that
|
||||
@@ -71,22 +71,22 @@ namespace SabreTools.Data.Models.CFB
|
||||
/// two purposes. First, it provides a root parent for all objects that
|
||||
/// are stationed at the root of the compound file. Second, its function
|
||||
/// is overloaded to store the size and starting sector for the mini stream.
|
||||
///
|
||||
///
|
||||
/// The root directory entry behaves as both a stream and a storage object.
|
||||
/// The root directory entry's Name field MUST contain the null-terminated
|
||||
/// string "Root Entry" in Unicode UTF-16.
|
||||
///
|
||||
///
|
||||
/// The object class GUID (CLSID) that is stored in the root directory
|
||||
/// entry can be used for COM activation of the document's application.
|
||||
///
|
||||
///
|
||||
/// The time stamps for the root storage are not maintained in the root
|
||||
/// directory entry. Rather, the root storage's creation and modification
|
||||
/// time stamps are normally stored on the file itself in the file system.
|
||||
///
|
||||
///
|
||||
/// The Creation Time field in the root storage directory entry MUST be
|
||||
/// all zeroes. The Modified Time field in the root storage directory
|
||||
/// entry MAY be all zeroes.
|
||||
/// <remarks>
|
||||
public DirectoryEntry[]? DirectoryEntries { get; set; }
|
||||
public DirectoryEntry[] DirectoryEntries { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@ namespace SabreTools.Data.Models.CFB
|
||||
public static class Constants
|
||||
{
|
||||
public static readonly byte[] SignatureBytes = [0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1];
|
||||
|
||||
|
||||
public const ulong SignatureUInt64 = 0xE11AB1A1E011CFD0;
|
||||
|
||||
|
||||
|
||||
/// <see href="https://devblogs.microsoft.com/setup/identifying-windows-installer-file-types/"/>
|
||||
#region Class IDs
|
||||
|
||||
@@ -36,12 +36,12 @@ namespace SabreTools.Data.Models.CFB
|
||||
/// The Summary Information Property Set
|
||||
/// </summary>
|
||||
public static readonly Guid FMTID_SummaryInformation = new("F29F85E0-4FF9-1068-AB91-08002B27B3D9");
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The DocumentSummaryInformation and UserDefined Property Sets
|
||||
/// </summary>
|
||||
public static readonly Guid FMTID_DocSummaryInformation = new("D5CDD502-2E9C-101B-9397-08002B2CF9AE");
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The DocumentSummaryInformation and UserDefined Property Sets
|
||||
/// </summary>
|
||||
@@ -49,4 +49,4 @@ namespace SabreTools.Data.Models.CFB
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace SabreTools.Data.Models.CFB
|
||||
/// </summary>
|
||||
/// <remarks>64 bytes</remarks>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
|
||||
public string? Name;
|
||||
public string Name;
|
||||
|
||||
/// <summary>
|
||||
/// This field MUST match the length of the Directory Entry Name Unicode
|
||||
@@ -139,4 +139,4 @@ namespace SabreTools.Data.Models.CFB
|
||||
/// </remarks>
|
||||
public ulong StreamSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -471,4 +471,4 @@ namespace SabreTools.Data.Models.CFB
|
||||
/// </summary>
|
||||
VT_BYREF = 0x4000
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,6 +128,6 @@ namespace SabreTools.Data.Models.CFB
|
||||
/// </summary>
|
||||
/// <remarks>109 entries</remarks>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 109)]
|
||||
public SectorNumber[]? DIFAT;
|
||||
public SectorNumber[] DIFAT = new SectorNumber[109];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace SabreTools.Data.Models.CFB
|
||||
/// Properties
|
||||
/// </summary>
|
||||
/// <remarks>Each Variant might be followed by an index and offset value</remarks>
|
||||
public Variant[]? Properties { get; set; }
|
||||
public Variant[] Properties { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -40,6 +40,6 @@ namespace SabreTools.Data.Models.CFB
|
||||
/// MUST contain an instance of the type, according to the value
|
||||
/// in the <see cref="VariantType"/> field.
|
||||
/// </summary>
|
||||
public object? Union { get; set; }
|
||||
public object Union { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
return false;
|
||||
|
||||
// Ensure the output filename is trimmed
|
||||
string filename = entry.Name ?? $"entry{index}";
|
||||
string filename = entry.Name.Length == 0 ? $"entry{index}" : entry.Name;
|
||||
byte[] nameBytes = Encoding.UTF8.GetBytes(filename);
|
||||
if (nameBytes[0] == 0xe4 && nameBytes[1] == 0xa1 && nameBytes[2] == 0x80)
|
||||
filename = Encoding.UTF8.GetString(nameBytes, 3, nameBytes.Length - 3);
|
||||
|
||||
@@ -26,16 +26,10 @@ namespace SabreTools.Serialization.Wrappers
|
||||
Print(builder, Model.DirectoryEntries);
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, FileHeader? header)
|
||||
private static void Print(StringBuilder builder, FileHeader header)
|
||||
{
|
||||
builder.AppendLine(" File Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (header == null)
|
||||
{
|
||||
builder.AppendLine(" No file header");
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendLine(header.Signature, " Signature");
|
||||
builder.AppendLine(header.CLSID, " CLSID");
|
||||
builder.AppendLine(header.MinorVersion, " Minor version");
|
||||
@@ -54,7 +48,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(header.FirstDIFATSectorLocation, " First DIFAT sector location");
|
||||
builder.AppendLine(header.NumberOfDIFATSectors, " Number of DIFAT sectors");
|
||||
builder.AppendLine(" DIFAT:");
|
||||
if (header.DIFAT == null || header.DIFAT.Length == 0)
|
||||
if (header.DIFAT.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No DIFAT entries");
|
||||
builder.AppendLine();
|
||||
@@ -69,11 +63,11 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, SectorNumber[]? entries, string name)
|
||||
private static void Print(StringBuilder builder, SectorNumber[] entries, string name)
|
||||
{
|
||||
builder.AppendLine($" {name} Sectors Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (entries == null || entries.Length == 0)
|
||||
if (entries.Length == 0)
|
||||
{
|
||||
builder.AppendLine($" No {name} sectors");
|
||||
builder.AppendLine();
|
||||
@@ -88,7 +82,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, DirectoryEntry[]? entries)
|
||||
private static void Print(StringBuilder builder, DirectoryEntry[] entries)
|
||||
{
|
||||
builder.AppendLine(" Directory Entries Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
|
||||
@@ -18,16 +18,16 @@ namespace SabreTools.Serialization.Wrappers
|
||||
#region Extension Properties
|
||||
|
||||
/// <inheritdoc cref="Binary.Header"/>
|
||||
public FileHeader? Header => Model.Header;
|
||||
public FileHeader Header => Model.Header;
|
||||
|
||||
/// <inheritdoc cref="Binary.DirectoryEntries"/>
|
||||
public DirectoryEntry[]? DirectoryEntries => Model.DirectoryEntries;
|
||||
public DirectoryEntry[] DirectoryEntries => Model.DirectoryEntries;
|
||||
|
||||
/// <inheritdoc cref="Binary.FATSectorNumbers"/>
|
||||
public SectorNumber[]? FATSectorNumbers => Model.FATSectorNumbers;
|
||||
public SectorNumber[] FATSectorNumbers => Model.FATSectorNumbers;
|
||||
|
||||
/// <inheritdoc cref="Binary.MiniFATSectorNumbers"/>
|
||||
public SectorNumber[]? MiniFATSectorNumbers => Model.MiniFATSectorNumbers;
|
||||
public SectorNumber[] MiniFATSectorNumbers => Model.MiniFATSectorNumbers;
|
||||
|
||||
/// <summary>
|
||||
/// Byte array representing the mini stream
|
||||
|
||||
Reference in New Issue
Block a user