// 检测两个区域是否有重叠
BOOL RegionsOverlap(uint64 iStart1, uint64 iEnd1, uint64 iStart2, uint64 iEnd2)
{
return ((iStart2 >= iStart1) && (iStart2 <= iEnd1)) || ((iStart1 >= iStart2) && (iStart1 <= iEnd2));
}
// 获取两个区域之间的交叉区域
BOOL GetIntersection(uint64 iStart1, uint32 iLength1, uint64 iStart2, uint64 iEnd2, uint64 *iIntersectStart, uint32 *iIntersectLength)
{
uint64 iEnd1 = iStart1 + iLength1 - 1;
uint64 iIntersectEnd = (iEnd1 <= iEnd2) ? iEnd1 : iEnd2;
*iIntersectStart = (iStart1 >= iStart2) ? iStart1 : iStart2;
*iIntersectLength = (uint32)((*iIntersectStart > iIntersectEnd) ? 0 : iIntersectEnd + 1 - *iIntersectStart);
if (*iIntersectLength == 0)
{
*iIntersectStart = iStart1;
}
return *iIntersectLength != 0;
}
CnCrypt代码 之 两个比较好用的磁盘边界检查函数
最新推荐文章于 2017-09-09 15:53:54 发布