From ac285c48fe88fba474e8c9f06662421e8a14097d Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 30 Sep 2025 20:25:18 -0400 Subject: [PATCH] Start documenting BZip in code --- .../Models/BZip2/Archive.cs | 14 +++++++--- .../Models/BZip2/Footer.cs | 27 +++++++++++++++++++ .../Models/BZip2/Header.cs | 25 +++++++++++++++++ 3 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 SabreTools.Serialization/Models/BZip2/Footer.cs create mode 100644 SabreTools.Serialization/Models/BZip2/Header.cs diff --git a/SabreTools.Serialization/Models/BZip2/Archive.cs b/SabreTools.Serialization/Models/BZip2/Archive.cs index 3678a4df..ffacc92f 100644 --- a/SabreTools.Serialization/Models/BZip2/Archive.cs +++ b/SabreTools.Serialization/Models/BZip2/Archive.cs @@ -1,10 +1,18 @@ namespace SabreTools.Data.Models.BZip2 { - /// - /// This is a placeholder model for future work - /// + /// public class Archive { + /// + /// Stream header + /// + public Header? Header { get; set; } + // TODO: Implement remaining structures + + /// + /// Stream footer + /// + public Footer? Footer { get; set; } } } diff --git a/SabreTools.Serialization/Models/BZip2/Footer.cs b/SabreTools.Serialization/Models/BZip2/Footer.cs new file mode 100644 index 00000000..0bfdcee2 --- /dev/null +++ b/SabreTools.Serialization/Models/BZip2/Footer.cs @@ -0,0 +1,27 @@ +namespace SabreTools.Data.Models.BZip2 +{ + public class Footer + { + /// + /// A 48-bit integer value 17 72 45 38 50 90, which + /// is the binary-coded decimal representation of + /// sqrt(pi). It is used to differentiate the block + /// from the footer. + /// + /// This may not be byte-aligned + public byte[]? Magic { get; set; } + + /// + /// Contains a custom checksum computed using each of + /// the Block CRCs. + /// + /// This may not be byte-aligned + public uint Checksum { get; set; } + + /// + /// Used to align the bit-stream to the next byte-aligned + /// edge and will contain between 0 and 7 bits. + /// + public byte Padding { get; set; } + } +} diff --git a/SabreTools.Serialization/Models/BZip2/Header.cs b/SabreTools.Serialization/Models/BZip2/Header.cs new file mode 100644 index 00000000..49b27941 --- /dev/null +++ b/SabreTools.Serialization/Models/BZip2/Header.cs @@ -0,0 +1,25 @@ +namespace SabreTools.Data.Models.BZip2 +{ + public class Header + { + /// + /// "BZ" + /// + public string? Signature { get; set; } + + /// + /// Version byte + /// + /// + /// '0' indicates a BZ1 file + /// 'h' indicates a BZ2 file + /// + public byte Version { get; set; } + + /// + /// ASCII value of the compression level + /// + /// Valid values between '1' and '9' + public byte Level { get; set; } + } +}