예제 #1
0
        private ExtentBlock LoadExtentBlock(ExtentIndex idxEntry)
        {
            uint blockSize = _context.SuperBlock.BlockSize;

            _context.RawStream.Position = idxEntry.LeafPhysicalBlock * blockSize;
            byte[]      buffer   = StreamUtilities.ReadFully(_context.RawStream, (int)blockSize);
            ExtentBlock subBlock = EndianUtilities.ToStruct <ExtentBlock>(buffer, 0);

            return(subBlock);
        }
예제 #2
0
        private Extent FindExtent(ExtentBlock node, uint logicalBlock)
        {
            if (node.Index != null)
            {
                ExtentIndex idxEntry = null;

                if (node.Index.Length == 0)
                {
                    return(null);
                }
                if (node.Index[0].FirstLogicalBlock >= logicalBlock)
                {
                    idxEntry = node.Index[0];
                }
                else
                {
                    for (int i = 0; i < node.Index.Length; ++i)
                    {
                        if (node.Index[i].FirstLogicalBlock > logicalBlock)
                        {
                            idxEntry = node.Index[i - 1];
                            break;
                        }
                    }
                }

                if (idxEntry == null)
                {
                    idxEntry = node.Index[node.Index.Length - 1];
                }

                ExtentBlock subBlock = LoadExtentBlock(idxEntry);
                return(FindExtent(subBlock, logicalBlock));
            }
            if (node.Extents != null)
            {
                Extent entry = null;

                if (node.Extents.Length == 0)
                {
                    return(null);
                }
                if (node.Extents[0].FirstLogicalBlock >= logicalBlock)
                {
                    return(node.Extents[0]);
                }
                for (int i = 0; i < node.Extents.Length; ++i)
                {
                    if (node.Extents[i].FirstLogicalBlock > logicalBlock)
                    {
                        entry = node.Extents[i - 1];
                        break;
                    }
                }

                if (entry == null)
                {
                    entry = node.Extents[node.Extents.Length - 1];
                }

                return(entry);
            }
            return(null);
        }
예제 #3
0
 private ExtentBlock LoadExtentBlock(ExtentIndex idxEntry)
 {
     uint blockSize = _context.SuperBlock.BlockSize;
     _context.RawStream.Position = idxEntry.LeafPhysicalBlock * blockSize;
     byte[] buffer = Utilities.ReadFully(_context.RawStream, (int)blockSize);
     ExtentBlock subBlock = Utilities.ToStruct<ExtentBlock>(buffer, 0);
     return subBlock;
 }