System.IO.Compression.Inflater.SetInput C# (CSharp) Méthode

SetInput() public méthode

public SetInput ( byte inputBuffer, int startIndex, int count ) : void
inputBuffer byte
startIndex int
count int
Résultat void
        public void SetInput(byte[] inputBuffer, int startIndex, int count)
        {
            Debug.Assert(NeedsInput(), "We have something left in previous input!");
            Debug.Assert(inputBuffer != null);
            Debug.Assert(startIndex >= 0 && count >= 0 && count + startIndex <= inputBuffer.Length);
            Debug.Assert(!_inputBufferHandle.IsAllocated);

            if (0 == count)
                return;

            lock (SyncLock)
            {
                _inputBufferHandle = GCHandle.Alloc(inputBuffer, GCHandleType.Pinned);
                _zlibStream.NextIn = _inputBufferHandle.AddrOfPinnedObject() + startIndex;
                _zlibStream.AvailIn = (uint)count;
                _finished = false;
            }
        }

Usage Example

Exemple #1
0
        // Read data from this stream.
        public override int Read(byte[] buffer, int offset, int count)
        {
            int temp;

            if (stream == null)
            {
                throw new ObjectDisposedException
                          (S._("Exception_Disposed"));
            }
            if (mode != CompressionMode.Decompress)
            {
                throw new NotSupportedException(S._("IO_NotSupp_Read"));
            }
            DeflateStream.ValidateBuffer(buffer, offset, count);
            if (!headerDone)
            {
                ReadHeader();
            }
            if (endOfStream)
            {
                return(0);
            }
            for (;;)
            {
                temp = inflater.Inflate(buffer, offset, count);
                if (temp > 0)
                {
                    crc32.Update(buffer, offset, temp);
                    if (inflater.IsFinished)
                    {
                        ReadFooter();
                    }
                    return(temp);
                }
                if (inflater.IsNeedingDictionary)
                {
                    throw new IOException
                              (S._("IO_Decompress_NeedDict"));
                }
                else if (inflater.IsFinished)
                {
                    ReadFooter();
                    return(0);
                }
                else if (inflater.IsNeedingInput)
                {
                    temp = stream.Read(buf, 0, buf.Length);
                    if (temp <= 0)
                    {
                        throw new IOException
                                  (S._("IO_Decompress_Truncated"));
                    }
                    inflater.SetInput(buf, 0, temp);
                }
                else
                {
                    throw new IOException
                              (S._("IO_Decompress_Invalid"));
                }
            }
        }