private void UpdateBlockInformation()
{
int lowestChange;
if (m_oldFirstOffset != FirstIndirectOffset)
lowestChange = 1;
else if (m_oldSecondOffset != SecondIndirectOffset)
lowestChange = 2;
else if (m_oldThirdOffset != ThirdIndirectOffset)
lowestChange = 3;
else if (m_oldFourthOffset != FourthIndirectOffset)
lowestChange = 4;
else
{
lowestChange = 5;
//DataClusterAddress = m_subFile.DirectBlock;
return;
}
m_oldFirstOffset = FirstIndirectOffset;
m_oldSecondOffset = SecondIndirectOffset;
m_oldThirdOffset = ThirdIndirectOffset;
m_oldFourthOffset = FourthIndirectOffset;
if (FirstIndirectOffset != 0) //Quadruple Indirect
{
FirstIndirectBlockAddress = m_subFile.QuadrupleIndirectBlock;
if (lowestChange <= 1)
SecondIndirectBlockAddress = GetBlockIndexValue(FirstIndirectBlockAddress, FirstIndirectOffset, BlockType.IndexIndirect1, FirstIndirectBaseIndex);
if (lowestChange <= 2)
ThirdIndirectBlockAddress = GetBlockIndexValue(SecondIndirectBlockAddress, SecondIndirectOffset, BlockType.IndexIndirect2, SecondIndirectBaseIndex);
if (lowestChange <= 3)
FourthIndirectBlockAddress = GetBlockIndexValue(ThirdIndirectBlockAddress, ThirdIndirectOffset, BlockType.IndexIndirect3, ThirdIndirectBaseIndex);
if (lowestChange <= 4)
DataClusterAddress = GetBlockIndexValue(FourthIndirectBlockAddress, FourthIndirectOffset, BlockType.IndexIndirect4, FourthIndirectBaseIndex);
}
else if (SecondIndirectOffset != 0) //Triple Indirect
{
FirstIndirectBlockAddress = 0;
SecondIndirectBlockAddress = m_subFile.TripleIndirectBlock;
if (lowestChange <= 2)
ThirdIndirectBlockAddress = GetBlockIndexValue(SecondIndirectBlockAddress, SecondIndirectOffset, BlockType.IndexIndirect2, SecondIndirectBaseIndex);
if (lowestChange <= 3)
FourthIndirectBlockAddress = GetBlockIndexValue(ThirdIndirectBlockAddress, ThirdIndirectOffset, BlockType.IndexIndirect3, ThirdIndirectBaseIndex);
if (lowestChange <= 4)
DataClusterAddress = GetBlockIndexValue(FourthIndirectBlockAddress, FourthIndirectOffset, BlockType.IndexIndirect4, FourthIndirectBaseIndex);
}
else if (ThirdIndirectOffset != 0) //Double Indirect
{
FirstIndirectBlockAddress = 0;
SecondIndirectBlockAddress = 0;
ThirdIndirectBlockAddress = m_subFile.DoubleIndirectBlock;
if (lowestChange <= 3)
FourthIndirectBlockAddress = GetBlockIndexValue(ThirdIndirectBlockAddress, ThirdIndirectOffset, BlockType.IndexIndirect3, ThirdIndirectBaseIndex);
if (lowestChange <= 4)
DataClusterAddress = GetBlockIndexValue(FourthIndirectBlockAddress, FourthIndirectOffset, BlockType.IndexIndirect4, FourthIndirectBaseIndex);
}
else if (FourthIndirectOffset != 0) //Single Indirect
{
FirstIndirectBlockAddress = 0;
SecondIndirectBlockAddress = 0;
ThirdIndirectBlockAddress = 0;
FourthIndirectBlockAddress = m_subFile.SingleIndirectBlock;
if (lowestChange <= 4)
DataClusterAddress = GetBlockIndexValue(FourthIndirectBlockAddress, FourthIndirectOffset, BlockType.IndexIndirect4, FourthIndirectBaseIndex);
}
else //Immediate
{
FirstIndirectBlockAddress = 0;
SecondIndirectBlockAddress = 0;
ThirdIndirectBlockAddress = 0;
FourthIndirectBlockAddress = 0;
DataClusterAddress = m_subFile.DirectBlock;
}
}