-
Notifications
You must be signed in to change notification settings - Fork 509
Closed
Labels
Description
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,
sharpcompress/src/SharpCompress/Common/SevenZip/SevenZipFilePart.cs
Lines 70 to 90 in 45de87c
| 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.
Reactions are currently unavailable