Refs #248. Refs #132. Added a test case of a tar containing symlinks

This is a source archive of the MoltenVK project from github, which is my use-case for SharpCompress.
I added a test case in the project, which should extract the tar, and validate any symlink targets with what the tar thinks it ought to be.
This commit is contained in:
Mark Final 2018-11-01 21:51:11 +00:00
parent 192b9c1e8b
commit d91e58f2cc
2 changed files with 37 additions and 0 deletions

View file

@ -186,5 +186,42 @@ namespace SharpCompress.Test.Tar
}
}
}
[Fact]
public void Tar_GZip_With_Symlink_Entries()
{
using (Stream stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "TarWithSymlink.tar.gz")))
using (var reader = TarReader.Open(stream))
{
List<string> names = new List<string>();
while (reader.MoveToNextEntry())
{
if (reader.Entry.IsDirectory)
{
continue;
}
reader.WriteEntryToDirectory(SCRATCH_FILES_PATH,
new ExtractionOptions()
{
ExtractFullPath = true,
Overwrite = true
});
if (reader.Entry.LinkTarget != null)
{
#if NETSTANDARD2_0
var link = new Mono.Unix.UnixSymbolicLinkInfo(reader.Entry.Key);
if (link.HasContents)
{
Assert.Equal(link.GetContents(), reader.Entry.LinkTarget);
}
else
{
Assert.True(false);
}
#endif
}
}
}
}
}
}

Binary file not shown.