Example #1
0
        public byte[] GetChunk(uint physicalPosition, VariableRange chunkParameter)
        {
            if (_positionBlock == null)
            {
                throw new InvalidOperationException();
            }
            int recieveLength = chunkParameter.Length;
            var sendLength    = 12 + (Resource.Is64bit ? 16 : 12);

            if (recieveLength > 0xfc00)
            {
                throw new ArgumentException();
            }
            var dataBufferLength = sendLength > recieveLength ? (ushort)sendLength : (ushort)recieveLength;
            var position         = 0;

            Array.Copy(BitConverter.GetBytes(physicalPosition), 0, this.TemporaryBuffer, position, 4);
            position += 4;
            Array.Copy(BitConverter.GetBytes(0x80000000), 0, this.TemporaryBuffer, position, 4);
            position += 4;
            Array.Copy(BitConverter.GetBytes(1), 0, this.TemporaryBuffer, position, 4);
            position += 4;
            Array.Copy(BitConverter.GetBytes(chunkParameter.Position), 0, this.TemporaryBuffer, position, 4);
            position += 4;
            Array.Copy(BitConverter.GetBytes(chunkParameter.Length), 0, this.TemporaryBuffer, position, 4);
            position += 4;
            if (Resource.Is64bit)
            {
                this.TemporaryBuffer[position++] = 0;
                this.TemporaryBuffer[position++] = 0;
                this.TemporaryBuffer[position++] = 0;
                this.TemporaryBuffer[position++] = 0;
                this.TemporaryBuffer[position++] = 0;
                this.TemporaryBuffer[position++] = 0;
                this.TemporaryBuffer[position++] = 0;
                this.TemporaryBuffer[position++] = 0;
            }
            else
            {
                this.TemporaryBuffer[position++] = 0;
                this.TemporaryBuffer[position++] = 0;
                this.TemporaryBuffer[position++] = 0;
                this.TemporaryBuffer[position++] = 0;
            }
            _nativeOperator.UpdateChunk(_positionBlock, this.TemporaryBuffer, ref dataBufferLength, null, -2);

            var result = new byte[chunkParameter.Length];

            Array.Copy(this.TemporaryBuffer, 0, result, 0, chunkParameter.Length);
            return(result);
        }
Example #2
0
 public UpdateChunkParameter(VariableRange range, byte[] data, int dataPosition = 0)
 {
     if (data == null)
     {
         throw new ArgumentNullException();
     }
     if (dataPosition < 0 || data.Length < range.Length)
     {
         throw new ArgumentOutOfRangeException();
     }
     this.Range        = range;
     this.Data         = data;
     this.DataPosition = dataPosition;
 }