Merge pull request #687 from Erior/feature/SourceStreamPositionCountingBug

SourceStream Position counting bug fix
This commit is contained in:
Adam Hathcock
2022-08-01 08:14:57 +01:00
committed by GitHub
2 changed files with 10 additions and 4 deletions

View File

@@ -143,9 +143,17 @@ namespace SharpCompress.IO
if (!IsVolumes && count != 0 && Current.Position == Current.Length)
{
_prevSize += Current.Length;
if (!SetStream(_stream + 1)) //will load next file if present
var length = Current.Length;
// Load next file if present
if (!SetStream(_stream + 1))
{
break;
}
// Current stream switched
// Add length of previous stream
_prevSize += length;
Current.Seek(0, SeekOrigin.Begin);
}
}

View File

@@ -170,10 +170,8 @@ namespace SharpCompress
byte[] buffer = GetTransferByteArray();
try
{
var pos = source.Position;
int count = 0;
var len = source.Read(buffer, 0, buffer.Length);
source.Position = pos + len;
do
{