public int GetCompressedOutput(byte[] outputBuffer) {
this.output.UpdateBuffer(outputBuffer);
if (this.usingGzip && !this.hasGzipHeader) {
this.output.WriteGzipHeader(3);
this.hasGzipHeader = true;
}
if (!this.hasBlockHeader) {
this.hasBlockHeader = true;
this.output.WritePreamble();
}
do {
int count = (this.inputBuffer.Count < this.inputWindow.FreeWindowSpace) ? this.inputBuffer.Count : this.inputWindow.FreeWindowSpace;
if (count > 0) {
this.inputWindow.CopyBytes(this.inputBuffer.Buffer, this.inputBuffer.StartIndex, count);
if (this.usingGzip) {
this.gzipCrc32 = DecodeHelper.UpdateCrc32(this.gzipCrc32, this.inputBuffer.Buffer, this.inputBuffer.StartIndex, count);
uint num2 = this.inputStreamSize + ((uint)count);
if (num2 < this.inputStreamSize) {
throw new InvalidDataException("The gzip stream can't contain more than 4GB data.");
}
this.inputStreamSize = num2;
}
this.inputBuffer.ConsumeBytes(count);
}
while ((this.inputWindow.BytesAvailable > 0) && this.output.SafeToWriteTo()) {
this.inputWindow.GetNextSymbolOrMatch(this.currentMatch);
if (this.currentMatch.State == MatchState.HasSymbol) {
this.output.WriteChar(this.currentMatch.Symbol);
}
else {
if (this.currentMatch.State == MatchState.HasMatch) {
this.output.WriteMatch(this.currentMatch.Length, this.currentMatch.Position);
continue;
}
this.output.WriteChar(this.currentMatch.Symbol);
this.output.WriteMatch(this.currentMatch.Length, this.currentMatch.Position);
}
}
}
while (this.output.SafeToWriteTo() && !this.NeedsInput());
this.needsEOB = true;
return this.output.BytesWritten;
}