Test with ForwardOnlyStream. RewindableStream shouldn't corrupt a ForwardOnlyStream (#161)

This commit is contained in:
Adam Hathcock
2016-08-12 11:56:49 +01:00
committed by GitHub
parent 3a52c68270
commit bd8ba7b854
4 changed files with 71 additions and 7 deletions

View File

@@ -31,7 +31,7 @@ namespace SharpCompress.Common.Zip
FlagUtility.HasFlag(lastEntryHeader.Flags, HeaderFlags.UsePostDataDescriptor))
{
reader = (lastEntryHeader.Part as StreamingZipFilePart).FixStreamedFileLocation(ref rewindableStream);
long pos = rewindableStream.Position;
long? pos = rewindableStream.CanSeek ? (long?)rewindableStream.Position : null;
uint crc = reader.ReadUInt32();
if (crc == POST_DATA_DESCRIPTOR)
{
@@ -40,7 +40,10 @@ namespace SharpCompress.Common.Zip
lastEntryHeader.Crc = crc;
lastEntryHeader.CompressedSize = reader.ReadUInt32();
lastEntryHeader.UncompressedSize = reader.ReadUInt32();
lastEntryHeader.DataStartPosition = pos - lastEntryHeader.CompressedSize;
if (pos.HasValue)
{
lastEntryHeader.DataStartPosition = pos - lastEntryHeader.CompressedSize;
}
}
lastEntryHeader = null;
uint headerBytes = reader.ReadUInt32();

View File

@@ -72,10 +72,7 @@ namespace SharpCompress.IO
get { return true; }
}
public override bool CanSeek
{
get { return false; }
}
public override bool CanSeek => stream.CanSeek;
public override bool CanWrite
{