public GZipDecompress(Stream read, Stream write) { _streamRead = read; _streamWrite = write; var header = FrameHelper.ReadWindowHeaderFromCompressedStream(_streamRead); FramesCount = header.FramesCount; _streamWrite.SetLength(header.SourceLength); }
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); }
public IEnumerable <Frame> Read() { while (_streamRead.Position < _streamRead.Length) { if (ReadFramesCount >= FramesCount) { break; } var frame = FrameHelper.ReadCompressedFrameFromStream(_streamRead); ReadFramesCount++; yield return(frame); } }
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++)); } }
public void Write(Frame frame) { FrameHelper.WriteFrameToStream(_streamToWrite, frame); }