Example #1
0
File: GZip.cs Project: Vita7y/GZip
        public GZipDecompress(Stream read, Stream write)
        {
            _streamRead  = read;
            _streamWrite = write;

            var header = FrameHelper.ReadWindowHeaderFromCompressedStream(_streamRead);

            FramesCount = header.FramesCount;
            _streamWrite.SetLength(header.SourceLength);
        }
Example #2
0
File: GZip.cs Project: Vita7y/GZip
        public GZipCompress(Stream toRead, Stream toWrite, int frameLength, int headerId)
        {
            _streamToRead  = toRead;
            _streamToWrite = toWrite;
            _frameLength   = frameLength;
            _headerId      = headerId;

            FramesCount = _streamToRead.Length / _frameLength + (_streamToRead.Length % _frameLength > 0 ? 1 : 0);
            var header = new WindowHeader(1, 1, _streamToRead.Length, FramesCount);

            FrameHelper.WriteWindowHeaderToStream(_streamToWrite, header);
        }
Example #3
0
File: GZip.cs Project: Vita7y/GZip
 public IEnumerable <Frame> Read()
 {
     while (_streamRead.Position < _streamRead.Length)
     {
         if (ReadFramesCount >= FramesCount)
         {
             break;
         }
         var frame = FrameHelper.ReadCompressedFrameFromStream(_streamRead);
         ReadFramesCount++;
         yield return(frame);
     }
 }
Example #4
0
File: GZip.cs Project: Vita7y/GZip
 public IEnumerable <Frame> Read()
 {
     while (_streamToRead.Position < _streamToRead.Length)
     {
         if (ReadFramesCount >= FramesCount)
         {
             break;
         }
         var needToRead = (int)(((_streamToRead.Length - _streamToRead.Position) > _frameLength)
             ? _frameLength
             : _streamToRead.Length - _streamToRead.Position);
         yield return(FrameHelper.CreateUncompressedFrameFromStream(_streamToRead, needToRead, _headerId, ReadFramesCount++));
     }
 }
Example #5
0
File: GZip.cs Project: Vita7y/GZip
 public void Write(Frame frame)
 {
     FrameHelper.WriteFrameToStream(_streamToWrite, frame);
 }