Пример #1
0
        public extentsOverflowLeafNode.extentsOverflowLeafRecord getExtentRecordWithKey(HFSPlusExtentKey recordKeyID)
        {
            extentsOverflowLeafNode.extentsOverflowLeafRecord result;

            byte[] nodeRawData       = new byte[this.nodeSize];
            uint   currentNodeNumber = this.header.headerInfo.rootNode;

            absNode.nodeType currentNodeType = getNodeType(currentNodeNumber);

            // until a leaf node is found
            while (currentNodeType != absNode.nodeType.leaf)
            {
                fs.Seek(currentNodeNumber * this.nodeSize, SeekOrigin.Begin);
                fs.Read(nodeRawData, 0, this.nodeSize);

                extentsOverflowIndexNode currentNode = new extentsOverflowIndexNode(ref nodeRawData);
                extentsOverflowIndexNode.extentsOverflowIndexRecord perhapsThisRecord = currentNode.records[0];

                // finds the subtree that contains the desired record and follows it
                foreach (extentsOverflowIndexNode.extentsOverflowIndexRecord record in currentNode.records)
                {
                    bool equalsSearch   = extentsOverflowKeyCompare(record.extentKey, recordKeyID) == dataOperations.keyCompareResult.equalsTrialKey;
                    bool lessThanSearch = extentsOverflowKeyCompare(record.extentKey, recordKeyID) == dataOperations.keyCompareResult.greaterThanTrialKey;
                    bool greaterThanOrEqualToBestKnown = extentsOverflowKeyCompare(record.extentKey, perhapsThisRecord.extentKey) == dataOperations.keyCompareResult.lessThanTrialKey ||
                                                         extentsOverflowKeyCompare(record.extentKey, perhapsThisRecord.extentKey) == dataOperations.keyCompareResult.equalsTrialKey;


                    if (lessThanSearch && greaterThanOrEqualToBestKnown || equalsSearch)
                    {
                        perhapsThisRecord = record;
                    }
                }

                currentNodeNumber = perhapsThisRecord.pointer;
                currentNodeType   = (absNode.nodeType)getNodeType(currentNodeNumber);
            }

            // once the leaf node is found, compile the data from it and return that node
            fs.Seek(currentNodeNumber * this.nodeSize, SeekOrigin.Begin);
            fs.Read(nodeRawData, 0, this.nodeSize);

            extentsOverflowLeafNode leafNode = new extentsOverflowLeafNode(ref nodeRawData);

            foreach (extentsOverflowLeafNode.extentsOverflowLeafRecord leafRecord in leafNode.records)
            {
                if (dataOperations.keyCompareResult.equalsTrialKey == extentsOverflowKeyCompare(leafRecord.key, recordKeyID))
                {
                    result = leafRecord;
                    return(result);
                }
            }

            throw new Exception("The specified search key was not found.");
        }
Пример #2
0
        public List <hfsPlusForkData.HFSPlusExtentRecord> getSelf(uint totalBlocks, uint knownBlocks)
        {
            // get any additional extents not defined in the volume header of the extents overflow file

            List <hfsPlusForkData.HFSPlusExtentRecord> result = new List <hfsPlusForkData.HFSPlusExtentRecord>();
            uint getNode = this.header.headerInfo.firstLeafNode;

            byte[] nodeRawData = new byte[this.nodeSize];

            fs.Seek(this.nodeSize * getNode, SeekOrigin.Begin);
            fs.Read(nodeRawData, 0, this.nodeSize);

            HFSPlusExtentKey theKey = new HFSPlusExtentKey();

            theKey.fileID     = 3;
            theKey.startBlock = knownBlocks;
            theKey.type       = forkType.data;

            // do this until all of the extents have been found
            while (knownBlocks < totalBlocks)
            {
                extentsOverflowLeafNode leaf = new extentsOverflowLeafNode(ref nodeRawData);

                foreach (extentsOverflowLeafNode.extentsOverflowLeafRecord record in leaf.records)
                {
                    dataOperations.keyCompareResult correctRecord = extentsOverflowKeyCompare(record.key, theKey);
                    if (correctRecord == dataOperations.keyCompareResult.equalsTrialKey)
                    {
                        // add all of the extents that contain any blocks
                        foreach (hfsPlusForkData.HFSPlusExtentRecord extent in record.extents)
                        {
                            if (extent.blockCount > 0)
                            {
                                result.Add(extent);
                                knownBlocks += extent.blockCount;
                            }
                        }
                    }
                }

                // prepare the next node's data in case extents go into following node
                getNode = leaf.BTNodeDescriptor.fLink;
                fs.Seek(this.nodeSize * getNode, SeekOrigin.Begin);
                fs.Read(nodeRawData, 0, this.nodeSize);
            }

            return(result);
        }
        public List<hfsPlusForkData.HFSPlusExtentRecord> getSelf(uint totalBlocks, uint knownBlocks)
        {
            // get any additional extents not defined in the volume header of the extents overflow file

            List<hfsPlusForkData.HFSPlusExtentRecord> result = new List<hfsPlusForkData.HFSPlusExtentRecord>();
            uint getNode = this.header.headerInfo.firstLeafNode;
            byte[] nodeRawData = new byte[this.nodeSize];

            fs.Seek(this.nodeSize * getNode, SeekOrigin.Begin);
            fs.Read(nodeRawData, 0, this.nodeSize);

            HFSPlusExtentKey theKey = new HFSPlusExtentKey();
            theKey.fileID = 3;
            theKey.startBlock = knownBlocks;
            theKey.type = forkType.data;

            // do this until all of the extents have been found
            while (knownBlocks < totalBlocks)
            {
                extentsOverflowLeafNode leaf = new extentsOverflowLeafNode(ref nodeRawData);

                foreach (extentsOverflowLeafNode.extentsOverflowLeafRecord record in leaf.records)
                {
                    dataOperations.keyCompareResult correctRecord = extentsOverflowKeyCompare(record.key, theKey);
                    if (correctRecord == dataOperations.keyCompareResult.equalsTrialKey)
                    {
                        // add all of the extents that contain any blocks
                        foreach (hfsPlusForkData.HFSPlusExtentRecord extent in record.extents)
                        {
                            if (extent.blockCount > 0)
                            {
                                result.Add(extent);
                                knownBlocks += extent.blockCount;
                            }
                        }
                    }
                }

                // prepare the next node's data in case extents go into following node
                getNode = leaf.BTNodeDescriptor.fLink;
                fs.Seek(this.nodeSize * getNode, SeekOrigin.Begin);
                fs.Read(nodeRawData, 0, this.nodeSize);
            }

            return result;
        }
        public extentsOverflowLeafNode.extentsOverflowLeafRecord getExtentRecordWithKey(HFSPlusExtentKey recordKeyID)
        {
            extentsOverflowLeafNode.extentsOverflowLeafRecord result;

            byte[] nodeRawData = new byte[this.nodeSize];
            uint currentNodeNumber = this.header.headerInfo.rootNode;

            absNode.nodeType currentNodeType = getNodeType(currentNodeNumber);

            // until a leaf node is found
            while (currentNodeType != absNode.nodeType.leaf)
            {
                fs.Seek(currentNodeNumber * this.nodeSize, SeekOrigin.Begin);
                fs.Read(nodeRawData, 0, this.nodeSize);

                extentsOverflowIndexNode currentNode = new extentsOverflowIndexNode(ref nodeRawData);
                extentsOverflowIndexNode.extentsOverflowIndexRecord perhapsThisRecord = currentNode.records[0];

                // finds the subtree that contains the desired record and follows it
                foreach (extentsOverflowIndexNode.extentsOverflowIndexRecord record in currentNode.records)
                {
                    bool equalsSearch = extentsOverflowKeyCompare(record.extentKey, recordKeyID) == dataOperations.keyCompareResult.equalsTrialKey;
                    bool lessThanSearch = extentsOverflowKeyCompare(record.extentKey, recordKeyID) == dataOperations.keyCompareResult.greaterThanTrialKey;
                    bool greaterThanOrEqualToBestKnown = extentsOverflowKeyCompare(record.extentKey, perhapsThisRecord.extentKey) == dataOperations.keyCompareResult.lessThanTrialKey
                        || extentsOverflowKeyCompare(record.extentKey, perhapsThisRecord.extentKey) == dataOperations.keyCompareResult.equalsTrialKey;

                    if (lessThanSearch && greaterThanOrEqualToBestKnown || equalsSearch)
                    {
                        perhapsThisRecord = record;
                    }
                }

                currentNodeNumber = perhapsThisRecord.pointer;
                currentNodeType = (absNode.nodeType)getNodeType(currentNodeNumber);
            }

            // once the leaf node is found, compile the data from it and return that node
            fs.Seek(currentNodeNumber * this.nodeSize, SeekOrigin.Begin);
            fs.Read(nodeRawData, 0, this.nodeSize);

            extentsOverflowLeafNode leafNode = new extentsOverflowLeafNode(ref nodeRawData);

            foreach (extentsOverflowLeafNode.extentsOverflowLeafRecord leafRecord in leafNode.records)
            {
                if (dataOperations.keyCompareResult.equalsTrialKey == extentsOverflowKeyCompare(leafRecord.key, recordKeyID))
                {
                    result = leafRecord;
                    return result;
                }
            }

            throw new Exception("The specified search key was not found.");
        }