Start documenting BZip in code

This commit is contained in:
Matt Nadareski
2025-09-30 20:25:18 -04:00
parent e57ad65210
commit ac285c48fe
3 changed files with 63 additions and 3 deletions

View File

@@ -1,10 +1,18 @@
namespace SabreTools.Data.Models.BZip2
{
/// <summary>
/// This is a placeholder model for future work
/// </summary>
/// <see href="https://github.com/dsnet/compress/blob/master/doc/bzip2-format.pdf"/>
public class Archive
{
/// <summary>
/// Stream header
/// </summary>
public Header? Header { get; set; }
// TODO: Implement remaining structures
/// <summary>
/// Stream footer
/// </summary>
public Footer? Footer { get; set; }
}
}

View File

@@ -0,0 +1,27 @@
namespace SabreTools.Data.Models.BZip2
{
public class Footer
{
/// <summary>
/// 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.
/// </summary>
/// <remarks>This may not be byte-aligned</remarks>
public byte[]? Magic { get; set; }
/// <summary>
/// Contains a custom checksum computed using each of
/// the Block CRCs.
/// </summary>
/// <remarks>This may not be byte-aligned</remarks>
public uint Checksum { get; set; }
/// <summary>
/// Used to align the bit-stream to the next byte-aligned
/// edge and will contain between 0 and 7 bits.
/// </summary>
public byte Padding { get; set; }
}
}

View File

@@ -0,0 +1,25 @@
namespace SabreTools.Data.Models.BZip2
{
public class Header
{
/// <summary>
/// "BZ"
/// </summary>
public string? Signature { get; set; }
/// <summary>
/// Version byte
/// </summary>
/// <remarks>
/// '0' indicates a BZ1 file
/// 'h' indicates a BZ2 file
/// </remarks>
public byte Version { get; set; }
/// <summary>
/// ASCII value of the compression level
/// </summary>
/// <remarks>Valid values between '1' and '9'</remarks>
public byte Level { get; set; }
}
}