Skip to content

[Bug] CompressionType.None should be supported for uncompressed 7z files #944

@arcastro

Description

@arcastro

What is the bug?

Uncompressed files within 7z archives already seem to be supported, in that they already "extract" correctly.
However, when reading the CompressionType field within the Entry, it currently throws an InvalidFormatException

Proposed Solution

I believe the fix should be simple enough.
Within the following block,

private const uint K_LZMA2 = 0x21;
private const uint K_LZMA = 0x030101;
private const uint K_PPMD = 0x030401;
private const uint K_B_ZIP2 = 0x040202;
private CompressionType GetCompression()
{
if (Header.IsDir)
{
return CompressionType.None;
}
var coder = Folder.NotNull()._coders.First();
return coder._methodId._id switch
{
K_LZMA or K_LZMA2 => CompressionType.LZMA,
K_PPMD => CompressionType.PPMd,
K_B_ZIP2 => CompressionType.BZip2,
_ => throw new InvalidFormatException(),
};
}

We could add:

private const uint K_COPY = 0x0;

and

K_COPY => CompressionType.None, 

If you agree, I'd be happy to open a pull-request, but I figured I'd open an issue first, in case you have different thoughts.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions