System.IO.Compression.FastEncoder.GetCompressedOutput C# (CSharp) Méthode

GetCompressedOutput() public méthode

public GetCompressedOutput ( byte outputBuffer ) : int
outputBuffer byte
Résultat int
        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;
        }

Usage Example

 public int GetDeflateOutput(byte[] output)
 {
     Debug.Assert(output != null, "Can't pass in a null output buffer!");
     return(encoder.GetCompressedOutput(output));
 }