WriteEntryToDirectory with GZipReader fails
edwardmjackson opened this issue · 4 comments
edwardmjackson commented
The generic extraction mechanism implemented in ExtractionMethods.cs appears to fail for GZip files.
Path.Combine throws an exception at
due to fileName being null, which is set here
StackTrace:
at System.IO.Path.Combine(String path1, String path2) in System.IO\Path.cs:line 310
at SharpCompress.Common.ExtractionMethods.WriteEntryToDirectory(IEntry entry, String destinationDirectory, ExtractionOptions options, Action`2 write) in SharpCompress.Common\ExtractionMethods.cs:line 44
at SharpCompress.Readers.IReaderExtensions.WriteEntryToDirectory(IReader reader, String destinationDirectory, ExtractionOptions options) in SharpCompress.Readers\IReaderExtensions.cs:line 31
at SharpCompress.Readers.IReaderExtensions.WriteAllToDirectory(IReader reader, String destinationDirectory, ExtractionOptions options) in SharpCompress.Readers\IReaderExtensions.cs:line 22
edwardmjackson commented
As a follow up, this is probably a sketchy file header in the gzip file, looking at
Trivial workaround for now:
using IReader reader = ReaderFactory.Open(sourceStream);
while (reader.MoveToNextEntry())
{
if (!reader.Entry.IsDirectory)
{
reader.WriteEntryToFile(decompressedFileLocation, new ExtractionOptions { ExtractFullPath = false, Overwrite = true });
}
}
adamhathcock commented
you're saying the entry.Key can be null?
edwardmjackson commented
Correct. The ! on this line
is masking it, but it can be null (in possibly wierdly-formed files that open fine in 7Zip)
adamhathcock commented
0.37.0 has fixed null support so maybe this isn't an issue now?