/// <summary>
/// Makes a shadow copy of an index indirect block and updates a remote address.
/// </summary>
/// <param name="sourceBlockAddress">the address of the source.</param>
/// <param name="destinationBlockAddress">the address of the destination. This can be the same as the source.</param>
/// <param name="indexValue">the index value that goes in the footer of the file.</param>
/// <param name="blockType">Gets the expected block type</param>
/// <param name="remoteAddressOffset">the offset of the remote address that needs to be updated.</param>
/// <param name="remoteBlockAddress">the value of the remote address.</param>
private void ReadThenWriteIndexIndirectBlock(uint sourceBlockAddress, uint destinationBlockAddress, uint indexValue, BlockType blockType, int remoteAddressOffset, uint remoteBlockAddress)
{
DiskIoSession bufferSource = m_ioSessions.SourceIndex;
if (sourceBlockAddress == destinationBlockAddress)
{
if (*(int *)(bufferSource.Pointer + (remoteAddressOffset << 2)) != remoteBlockAddress)
{
bufferSource.WriteToExistingBlock(destinationBlockAddress, blockType, indexValue);
WriteIndexIndirectBlock(bufferSource.Pointer, remoteAddressOffset, remoteBlockAddress);
}
}
else
{
bufferSource.ReadOld(sourceBlockAddress, blockType, indexValue);
DiskIoSession destination = m_ioSessions.DestinationIndex;
destination.WriteToNewBlock(destinationBlockAddress, blockType, indexValue);
Memory.Copy(bufferSource.Pointer, destination.Pointer, destination.Length);
WriteIndexIndirectBlock(destination.Pointer, remoteAddressOffset, remoteBlockAddress);
m_ioSessions.SwapIndex();
}
}