public override Block Create(uint block) { if (!vhdFile.BlockAllocationTable.HasData(block)) { if (cachedBlock == null || cachedBlock.BlockIndex != block) { cachedBlock = new Block(this) { BlockIndex = block, VhdUniqueId = this.vhdFile.Footer.UniqueId, LogicalRange = IndexRange.FromLength(block * GetBlockSize(), vhdFile.Header.BlockSize), BitMap = null, Empty = true }; } return(cachedBlock); } if (cachedBlock == null || cachedBlock.BlockIndex != block) { cachedBlock = new Block(this) { BlockIndex = block, VhdUniqueId = this.vhdFile.Footer.UniqueId, LogicalRange = IndexRange.FromLength(block * GetBlockSize(), vhdFile.Header.BlockSize), BitMap = bitMapFactory.Create(block), Empty = false }; } return(cachedBlock); }
public override Block Create(uint block) { if (!vhdFile.BlockAllocationTable.HasData(block)) { if (cachedBlock == null || cachedBlock.BlockIndex != block) { IndexRange logicalRange = IndexRange.FromLength(block * GetBlockSize(), this.GetBlockSize()); if (ExtraBlockIndex.HasValue && block == ExtraBlockIndex) { long startIndex = block * GetBlockSize(); long size = vhdFile.Footer.CurrentSize - startIndex; logicalRange = IndexRange.FromLength(startIndex, size); } cachedBlock = new Block(this) { BlockIndex = block, VhdUniqueId = this.vhdFile.Footer.UniqueId, LogicalRange = logicalRange, BitMap = null, Empty = true }; } return(cachedBlock); } if (cachedBlock == null || cachedBlock.BlockIndex != block) { IndexRange logicalRange = IndexRange.FromLength(block * GetBlockSize(), this.GetBlockSize()); if (ExtraBlockIndex.HasValue && block == ExtraBlockIndex) { long startIndex = block * GetBlockSize(); long size = vhdFile.Footer.CurrentSize - startIndex; logicalRange = IndexRange.FromLength(startIndex, size); } cachedBlock = new Block(this) { BlockIndex = block, VhdUniqueId = this.vhdFile.Footer.UniqueId, LogicalRange = logicalRange, BitMap = bitMapFactory.Create(block), Empty = false }; } return(cachedBlock); }