Fixed defects after review.

This commit is contained in:
Vladimir Demidov
2016-11-24 18:01:49 +03:00
parent e181fa8c4a
commit 031286c5eb
2 changed files with 14 additions and 1 deletions

View File

@@ -126,7 +126,7 @@ namespace SharpCompress.Common.Zip
protected Stream GetCryptoStream(Stream plainStream)
{
if ((Header.CompressedSize == 0) && !string.IsNullOrEmpty(Header.Password))
if (Header.CompressedSize == 0)
{
throw new NotSupportedException("Cannot encrypt file with unknown size at start.");
}
@@ -151,9 +151,12 @@ namespace SharpCompress.Common.Zip
case ZipCompressionMethod.BZip2:
case ZipCompressionMethod.LZMA:
case ZipCompressionMethod.PPMd:
{
return new PkwareTraditionalCryptoStream(plainStream, Header.ComposeEncryptionData(plainStream), CryptoMode.Decrypt);
}
case ZipCompressionMethod.WinzipAes:
{
#if !NO_FILE
if (Header.WinzipAesEncryptionData != null)
{
@@ -161,9 +164,13 @@ namespace SharpCompress.Common.Zip
}
#endif
return plainStream;
}
default:
{
throw new ArgumentOutOfRangeException();
}
}
}

View File

@@ -162,16 +162,22 @@ namespace SharpCompress.Common.Zip
switch (mode)
{
case StreamingMode.Seekable:
{
entryHeader.DataStartPosition = stream.Position;
stream.Position += entryHeader.CompressedSize;
break;
}
case StreamingMode.Streaming:
{
entryHeader.PackedStream = stream;
break;
}
default:
{
throw new InvalidFormatException("Invalid StreamingMode");
}
}
//}