Beispiel #1
0
 public BlockGZipStream(Stream stream, BlockGZipStreamMode mode)
 {
     if (mode == BlockGZipStreamMode.Compressing)
     {
         additionalInfo = new CompressedFileAdditionalInfo(1000);
         shouldWriteAdditionalInfoOnDisposing = true;
     }
     else
     {
         additionalInfo = CompressedFileAdditionalInfo.GetFrom(stream);
     }
     IsSupportedStream(stream, mode);
     this.stream = stream;
 }
Beispiel #2
0
 private void IsSupportedStream(Stream stream, BlockGZipStreamMode mode)
 {
     if (!stream.CanSeek)
     {
         throw new NotSupportedException("Stream must support Seek operations.");
     }
     if (mode == BlockGZipStreamMode.Compressing && !stream.CanWrite)
     {
         throw new NotSupportedException("Stream stream must support Write operations.");
     }
     if (mode == BlockGZipStreamMode.Decompressing && !stream.CanRead)
     {
         throw new NotSupportedException("Stream stream must support Read operations.");
     }
 }