Skip to content

Commit

Permalink
Merge pull request tomap#13 from squid-box/tomapGH-12
Browse files Browse the repository at this point in the history
Potential fix for tomap#12
  • Loading branch information
squid-box committed Jul 27, 2018
2 parents 7e4df6e + baeca6b commit ed45736
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions SevenZip/ArchiveOpenCallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ public ArchiveOpenCallback(string fileName, string password) : base(password)

public int GetProperty(ItemPropId propId, ref PropVariant value)
{
if (_fileInfo == null)
{
// We are likely opening an archive from a Stream, and no file or _fileInfo exists.
return 0;
}

switch (propId)
{
case ItemPropId.Name:
Expand Down Expand Up @@ -111,6 +117,7 @@ public int GetProperty(ItemPropId propId, ref PropVariant value)
value.Int64Value = _fileInfo.LastWriteTime.ToFileTime();
break;
}

return 0;
}

Expand Down
3 changes: 2 additions & 1 deletion SevenZipTests/SevenZipExtractorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ public void ExtractionWithCancellationTest()
[Test]
public void ExtractionFromStreamTest()
{
// TODO: Rewrite this to test against more/all TestData archives.

using (var tmp = new SevenZipExtractor(File.OpenRead(@"TestData\multiple_files.7z")))
{
tmp.ExtractArchive(OutputDirectory);

Assert.AreEqual(3, Directory.GetFiles(OutputDirectory).Length);
}
}
Expand Down

0 comments on commit ed45736

Please sign in to comment.