/// <summary>
        /// Copy the current contents of this buffer to the named output.
        /// </summary>
        public virtual void WriteTo(IndexOutput other)
        {
            Flush();
            long num1 = file.Length;
            long num2 = 0L;
            int  num3 = 0;
            long num4;

            for (; num2 < num1; num2 = num4)
            {
                int length = 1024;
                num4 = num2 + length;
                if (num4 > num1)
                {
                    length = (int)(num1 - num2);
                }
                other.WriteBytes(file.GetBuffer(num3++), length);
            }
        }
 private void SwitchCurrentBuffer(bool enforceEOF)
 {
     if (currentBufferIndex >= file.NumBuffers())
     {
         if (enforceEOF)
         {
             throw new IOException("Read past EOF");
         }
         --currentBufferIndex;
         bufferPosition = BUFFER_SIZE;
     }
     else
     {
         currentBuffer  = file.GetBuffer(currentBufferIndex);
         bufferPosition = 0;
         bufferStart    = BUFFER_SIZE * (long)currentBufferIndex;
         long num = length - bufferStart;
         bufferLength = num > (long)BUFFER_SIZE ? BUFFER_SIZE : (int)num;
     }
 }