Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support added for TAR LZW compression (Unix 'compress' resulting in .… #819

Merged
merged 2 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/SharpCompress/Common/CompressionType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ public enum CompressionType
Xz,
Unknown,
Deflate64,
Shrink
Shrink,
Lzw
}
65 changes: 65 additions & 0 deletions src/SharpCompress/Compressors/Lzw/LzwConstants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
namespace SharpCompress.Compressors.Lzw
{
/// <summary>
/// This class contains constants used for LZW
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage(
"Naming",
"CA1707:Identifiers should not contain underscores",
Justification = "kept for backwards compatibility"
)]
public sealed class LzwConstants
{
/// <summary>
/// Magic number found at start of LZW header: 0x1f 0x9d
/// </summary>
public const int MAGIC = 0x1f9d;

/// <summary>
/// Maximum number of bits per code
/// </summary>
public const int MAX_BITS = 16;

/* 3rd header byte:
* bit 0..4 Number of compression bits
* bit 5 Extended header
* bit 6 Free
* bit 7 Block mode
*/

/// <summary>
/// Mask for 'number of compression bits'
/// </summary>
public const int BIT_MASK = 0x1f;

/// <summary>
/// Indicates the presence of a fourth header byte
/// </summary>
public const int EXTENDED_MASK = 0x20;

//public const int FREE_MASK = 0x40;

/// <summary>
/// Reserved bits
/// </summary>
public const int RESERVED_MASK = 0x60;

/// <summary>
/// Block compression: if table is full and compression rate is dropping,
/// clear the dictionary.
/// </summary>
public const int BLOCK_MODE_MASK = 0x80;

/// <summary>
/// LZW file header size (in bytes)
/// </summary>
public const int HDR_SIZE = 3;

/// <summary>
/// Initial number of bits per code
/// </summary>
public const int INIT_BITS = 9;

private LzwConstants() { }
}
}
Loading