Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<Compile Include="$(SharedOpenSourcePath)System\IO\Compression\ZipVersion.cs" />
<Compile Include="System\IO\Compression\DeflateManaged\BlockType.cs" />
<Compile Include="System\IO\Compression\DeflateManaged\DeflateManagedStream.cs" />
<Compile Include="System\IO\Compression\DeflateManaged\FileFormats.cs" />
<Compile Include="System\IO\Compression\DeflateManaged\HuffmanTree.cs" />
<Compile Include="System\IO\Compression\DeflateManaged\InflaterManaged.cs" />
<Compile Include="System\IO\Compression\DeflateManaged\InflaterState.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal DeflateManagedStream(Stream stream, ZipArchiveEntry.CompressionMethodVa

Debug.Assert(method == ZipArchiveEntry.CompressionMethodValues.Deflate64);

_inflater = new InflaterManaged(null, method == ZipArchiveEntry.CompressionMethodValues.Deflate64 ? true : false, uncompressedSize);
_inflater = new InflaterManaged(method == ZipArchiveEntry.CompressionMethodValues.Deflate64, uncompressedSize);

_stream = stream;
_buffer = new byte[DefaultBufferSize];
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ internal sealed class InflaterManaged
private HuffmanTree? _distanceTree;

private InflaterState _state;
private readonly bool _hasFormatReader;
private int _bfinal;
private BlockType _blockType;

Expand All @@ -75,9 +74,7 @@ internal sealed class InflaterManaged
private readonly long _uncompressedSize;
private long _currentInflatedCount;

private readonly IFileFormatReader? _formatReader; // class to decode header and footer (e.g. gzip)

internal InflaterManaged(IFileFormatReader? reader, bool deflate64, long uncompressedSize)
internal InflaterManaged(bool deflate64, long uncompressedSize)
{
_output = new OutputWindow();
_input = new InputBuffer();
Expand All @@ -86,19 +83,7 @@ internal InflaterManaged(IFileFormatReader? reader, bool deflate64, long uncompr
_codeLengthTreeCodeLength = new byte[HuffmanTree.NumberOfCodeLengthTreeElements];
_deflate64 = deflate64;
_uncompressedSize = uncompressedSize;
if (reader != null)
{
_formatReader = reader;
_hasFormatReader = true;
}
Reset();
}

private void Reset()
{
_state = _hasFormatReader ?
InflaterState.ReadingHeader : // start by reading Header info
InflaterState.ReadingBFinal; // start by reading BFinal bit
_state = InflaterState.ReadingBFinal; // start by reading BFinal bit
}

public void SetInput(byte[] inputBytes, int offset, int length) =>
Expand Down Expand Up @@ -137,12 +122,6 @@ public int Inflate(byte[] bytes, int offset, int length)
}
if (copied > 0)
{
if (_hasFormatReader)
{
Debug.Assert(_formatReader != null);
_formatReader.UpdateWithBytesRead(bytes, offset, copied);
}

offset += copied;
count += copied;
length -= copied;
Expand All @@ -155,17 +134,6 @@ public int Inflate(byte[] bytes, int offset, int length)
// Decode will return false when more input is needed
} while (!Finished() && Decode());

if (_state == InflaterState.VerifyingFooter)
{ // finished reading CRC
// In this case finished is true and output window has all the data.
// But some data in output window might not be copied out.
if (_output.AvailableBytes == 0)
{
Debug.Assert(_formatReader != null);
_formatReader.Validate();
}
}

return count;
}

Expand Down Expand Up @@ -200,27 +168,6 @@ private bool Decode()
return true;
}

if (_hasFormatReader)
{
Debug.Assert(_formatReader != null);
if (_state == InflaterState.ReadingHeader)
{
if (!_formatReader.ReadHeader(_input))
{
return false;
}
_state = InflaterState.ReadingBFinal;
}
else if (_state == InflaterState.StartReadingFooter || _state == InflaterState.ReadingFooter)
{
if (!_formatReader.ReadFooter(_input))
return false;

_state = InflaterState.VerifyingFooter;
return true;
}
}

if (_state == InflaterState.ReadingBFinal)
{
// reading bfinal bit
Expand Down Expand Up @@ -293,10 +240,7 @@ private bool Decode()
//
if (eob && (_bfinal != 0))
{
if (_hasFormatReader)
_state = InflaterState.StartReadingFooter;
else
_state = InflaterState.Done;
_state = InflaterState.Done;
}
return result;
}
Expand Down