Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Rewindable stream Length and add GZip Reader tests #563

Merged
merged 3 commits into from Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/SharpCompress/IO/RewindableStream.cs
Expand Up @@ -84,11 +84,11 @@ public override void Flush()
throw new NotSupportedException();
}

public override long Length => throw new NotSupportedException();
public override long Length => stream.Length;

public override long Position
{
get { return stream.Position + bufferStream.Position - bufferStream.Length; }
get => stream.Position + bufferStream.Position - bufferStream.Length;
set
{
if (!isRewound)
Expand Down
6 changes: 3 additions & 3 deletions src/SharpCompress/SharpCompress.csproj
Expand Up @@ -2,9 +2,9 @@
<PropertyGroup>
<AssemblyTitle>SharpCompress - Pure C# Decompression/Compression</AssemblyTitle>
<NeutralLanguage>en-US</NeutralLanguage>
<VersionPrefix>0.27.0</VersionPrefix>
<AssemblyVersion>0.27.0</AssemblyVersion>
<FileVersion>0.27.0</FileVersion>
<VersionPrefix>0.27.1</VersionPrefix>
<AssemblyVersion>0.27.1</AssemblyVersion>
<FileVersion>0.27.1</FileVersion>
<Authors>Adam Hathcock</Authors>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand Down
37 changes: 37 additions & 0 deletions tests/SharpCompress.Test/GZip/GZipReaderTests.cs
@@ -0,0 +1,37 @@
using System.IO;
using SharpCompress.Common;
using SharpCompress.IO;
using Xunit;

namespace SharpCompress.Test.GZip
{
public class GZipReaderTests : ReaderTests
{
public GZipReaderTests()
{
UseExtensionInsteadOfNameToVerify = true;
}

[Fact]
public void GZip_Reader_Generic()
{
Read("Tar.tar.gz", CompressionType.GZip);
}


[Fact]
public void GZip_Reader_Generic2()
{
//read only as GZip itme
using (Stream stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "Tar.tar.gz")))
using (var reader = SharpCompress.Readers.GZip.GZipReader.Open(new RewindableStream(stream)))
{
while (reader.MoveToNextEntry()) // Crash here
{
Assert.NotEqual(0, reader.Entry.Size);
Assert.NotEqual(0, reader.Entry.Crc);
}
}
}
}
}