SevenZipSharp/SevenZip/LzmaDecodeStream.cs
/// <summary>
/// Reads a sequence of bytes from the current stream and decompresses data if necessary.
/// </summary>
/// <param name="buffer">An array of bytes.</param>
/// <param name="offset">The zero-based byte offset in buffer at which to begin storing the data read from the current stream.</param>
/// <param name="count">The maximum number of bytes to be read from the current stream.</param>
/// <returns>The total number of bytes read into the buffer.</returns>        
Reads a sequence of bytes from the current stream and decompresses data if necessary.
Reads a sequence of bytes from the current stream and decompresses data if necessary .
public override int Read(byte[] buffer, int offset, int count)
        {
            if (_error)
            {
                return 0;
            }
            if (!_firstChunkRead)
            {
                ReadChunk();
                _firstChunkRead = true;
            }
            int readCount = 0;
            while (count > _buffer.Length - _buffer.Position && !_error)
            {
                var buf = new byte[_buffer.Length - _buffer.Position];
                _buffer.Read(buf, 0, buf.Length);
                buf.CopyTo(buffer, offset);
                offset += buf.Length;
                count -= buf.Length;
                readCount += buf.Length;
                ReadChunk();
            }
            if (!_error)
            {
                _buffer.Read(buffer, offset, count);
                readCount += count;
            }
            return readCount;
        }
public override int Read ( byte [ ] buffer , int offset , int count ) { if ( _error ) { return 0 ; } if ( ! _firstChunkRead ) { ReadChunk ( ) ; _firstChunkRead = true ; } int readCount = 0 ; while ( count > _buffer . Length - _buffer . Position && ! _error ) { var buf = new byte [ _buffer . Length - _buffer . Position ] ; _buffer . Read ( buf , 0 , buf . Length ) ; buf . CopyTo ( buffer , offset ) ; offset += buf . Length ; count -= buf . Length ; readCount += buf . Length ; ReadChunk ( ) ; } if ( ! _error ) { _buffer . Read ( buffer , offset , count ) ; readCount += count ; } return readCount ; }
Reads a sequence of bytes from the current stream and decompresses data if necessary.
Reads a sequence of bytes from the current stream and decompresses data if necessary .
The total number of bytes read into the buffer.
The total number of bytes read into the buffer .
buffer
byte[]
An array of bytes.
An array of bytes .
offset
int
The zero-based byte offset in buffer at which to begin storing the data read from the current stream.
The zero - based byte offset in buffer at which to begin storing the data read from the current stream .
count
int
The maximum number of bytes to be read from the current stream.
The maximum number of bytes to be read from the current stream .