Wrote function to extract all tarball content, simplified GetTarballContentNames

This commit is contained in:
Ella Hathaway 2023-08-17 17:56:59 +00:00
parent 4ccce78877
commit 3c5a161bbb

View file

@ -48,6 +48,14 @@ public static class Utilities
} }
public static IEnumerable<string> GetTarballContentNames(string tarballPath) public static IEnumerable<string> GetTarballContentNames(string tarballPath)
{
foreach (var entry in GetTarballContent(tarballPath))
{
yield return entry.Name;
}
}
public static IEnumerable<TarEntry> GetTarballContent(string tarballPath)
{ {
using FileStream fileStream = File.OpenRead(tarballPath); using FileStream fileStream = File.OpenRead(tarballPath);
using GZipStream decompressorStream = new(fileStream, CompressionMode.Decompress); using GZipStream decompressorStream = new(fileStream, CompressionMode.Decompress);
@ -56,7 +64,7 @@ public static class Utilities
TarEntry entry; TarEntry entry;
while ((entry = reader.GetNextEntry()) is not null) while ((entry = reader.GetNextEntry()) is not null)
{ {
yield return entry.Name; yield return entry;
} }
} }