public override void Write(byte[] buffer, int offset, int count)
 {
     if (buffer == null)
     {
         throw new ArgumentNullException("buffer");
     }
     if (offset < 0)
     {
         throw new ArgumentOutOfRangeException("offset", Messages.ArgumentNeedNonNegative);
     }
     if (count < 0)
     {
         throw new ArgumentOutOfRangeException("count", Messages.ArgumentNeedNonNegative);
     }
     if ((int)buffer.Length - offset < count)
     {
         throw new ArgumentException(Messages.OffsetLengthInvalid);
     }
     this.ThrowIfDisposed();
     if (count == 0)
     {
         return;
     }
     if (!this._everWritten)
     {
         this._initialPosition = this._baseBaseStream.Position;
         this._everWritten     = true;
     }
     this._checksum = Crc32Helper.UpdateCrc32(this._checksum, buffer, offset, count);
     this._baseStream.Write(buffer, offset, count);
     this._position += (long)count;
 }
        public void UpdateWithBytesRead(byte[] buffer, int offset, int bytesToCopy)
        {
            this._crc32 = Crc32Helper.UpdateCrc32(this._crc32, buffer, offset, bytesToCopy);
            long a = this._inputStreamSize + ((long)((ulong)bytesToCopy));

            if (a > 0x100000000L)
            {
                Math.DivRem(a, 0x100000000L, out a);
            }
            this._inputStreamSize = a;
        }
        public void UpdateWithBytesRead(byte[] buffer, int offset, int copied)
        {
            this.actualCrc32 = Crc32Helper.UpdateCrc32(this.actualCrc32, buffer, offset, copied);
            long a = this.actualStreamSize + ((long)((ulong)copied));

            if (a > 0x100000000L)
            {
                Math.DivRem(a, 0x100000000L, out a);
            }
            this.actualStreamSize = a;
        }
示例#4
0
        public void UpdateWithBytesRead(byte[] buffer, int offset, int bytesToCopy)
        {
            _crc32 = Crc32Helper.UpdateCrc32(_crc32, buffer, offset, bytesToCopy);

            long n = _inputStreamSizeModulo + (uint)bytesToCopy;

            if (n >= GZipConstants.FileLengthModulo)
            {
                n %= GZipConstants.FileLengthModulo;
            }
            _inputStreamSizeModulo = n;
        }
        public void UpdateWithBytesRead(byte[] buffer, int offset, int copied)
        {
            actualCrc32 = Crc32Helper.UpdateCrc32(actualCrc32, buffer, offset, copied);

            long n = actualStreamSizeModulo + (uint)copied;

            if (n >= GZipConstants.FileLengthModulo)
            {
                n %= GZipConstants.FileLengthModulo;
            }
            actualStreamSizeModulo = n;
        }
示例#6
0
        public override void Write(ReadOnlySpan <byte> source)
        {
            // if we're not actually writing anything, we don't want to trigger as if we did write something
            ThrowIfDisposed();
            Debug.Assert(CanWrite);

            if (source.Length == 0)
            {
                return;
            }

            if (!_everWritten)
            {
                _initialPosition = _baseBaseStream.Position;
                _everWritten     = true;
            }

            _checksum = Crc32Helper.UpdateCrc32(_checksum, source);
            _baseStream.Write(source);
            _position += source.Length;
        }
示例#7
0
        public override void Write(Byte[] buffer, Int32 offset, Int32 count)
        {
            //we can't pass the argument checking down a level
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }
            if (offset < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(offset), SR.ArgumentNeedNonNegative);
            }
            if (count < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentNeedNonNegative);
            }
            if ((buffer.Length - offset) < count)
            {
                throw new ArgumentException(SR.OffsetLengthInvalid);
            }
            Contract.EndContractBlock();

            //if we're not actually writing anything, we don't want to trigger as if we did write something
            ThrowIfDisposed();
            Debug.Assert(CanWrite);

            if (count == 0)
            {
                return;
            }

            if (!_everWritten)
            {
                _initialPosition = _baseBaseStream.Position;
                _everWritten     = true;
            }

            _checksum = Crc32Helper.UpdateCrc32(_checksum, buffer, offset, count);
            _baseStream.Write(buffer, offset, count);
            _position += count;
        }
        public override void Write(byte[] buffer, int offset, int count)
        {
            // we can't pass the argument checking down a level
            ValidateBufferArguments(buffer, offset, count);

            // if we're not actually writing anything, we don't want to trigger as if we did write something
            ThrowIfDisposed();
            Debug.Assert(CanWrite);

            if (count == 0)
            {
                return;
            }

            if (!_everWritten)
            {
                _initialPosition = _baseBaseStream.Position;
                _everWritten     = true;
            }

            _checksum = Crc32Helper.UpdateCrc32(_checksum, buffer, offset, count);
            _baseStream.Write(buffer, offset, count);
            _position += count;
        }