Exemplo n.º 1
0
        public override void  FlushBuffer(byte[] src, int len)
        {
            byte[] buffer;
            int    bufferPos = 0;

            while (bufferPos != len)
            {
                int bufferNumber      = (int)(pointer / BUFFER_SIZE);
                int bufferOffset      = (int)(pointer % BUFFER_SIZE);
                int bytesInBuffer     = BUFFER_SIZE - bufferOffset;
                int remainInSrcBuffer = len - bufferPos;
                int bytesToCopy       = bytesInBuffer >= remainInSrcBuffer ? remainInSrcBuffer : bytesInBuffer;

                if (bufferNumber == file.buffers.Count)
                {
                    buffer = file.AddBuffer(BUFFER_SIZE);
                }
                else
                {
                    buffer = (byte[])file.buffers[bufferNumber];
                }

                Array.Copy(src, bufferPos, buffer, bufferOffset, bytesToCopy);
                bufferPos += bytesToCopy;
                pointer   += bytesToCopy;
            }

            if (pointer > file.length)
            {
                file.SetLength(pointer);
            }

            file.SetLastModified(System.DateTime.Now.Ticks);
        }
Exemplo n.º 2
0
 private void SwitchCurrentBuffer()
 {
     if (CurrentBufferIndex == File.NumBuffers())
     {
         CurrentBuffer = File.AddBuffer(BUFFER_SIZE);
     }
     else
     {
         CurrentBuffer = File.GetBuffer(CurrentBufferIndex);
     }
     BufferPosition = 0;
     BufferStart    = (long)BUFFER_SIZE * (long)CurrentBufferIndex;
     BufferLength   = CurrentBuffer.Length;
 }
Exemplo n.º 3
0
 private void  SwitchCurrentBuffer()
 {
     if (currentBufferIndex == file.NumBuffers())
     {
         currentBuffer = file.AddBuffer(BUFFER_SIZE);
     }
     else
     {
         currentBuffer = (byte[])file.GetBuffer(currentBufferIndex);
     }
     bufferPosition = 0;
     bufferStart    = (long)BUFFER_SIZE * (long)currentBufferIndex;
     bufferLength   = currentBuffer.Length;
 }