示例#1
0
        public attributesLeafNode.HFSPlusAttrInlineData getAttriInlineDataWithKey(HFSPlusAttrKey recordKeyID, bool caseSensitiveCompare = false)
        {
            byte[] nodeRawData = new byte[this.nodeSize];

            attributesLeafNode.HFSPlusAttrInlineData result = new attributesLeafNode.HFSPlusAttrInlineData();

            // find the root node
            uint currentNodeNumber = this.header.headerInfo.rootNode;

            fs.Seek(currentNodeNumber * this.nodeSize, SeekOrigin.Begin);
            fs.Read(nodeRawData, 0, this.nodeSize);
            absNode.nodeType currentNodeType = getNodeType(currentNodeNumber);

            bool found = false;

            // get the leaf
            if (this.header.headerInfo.rootNode > 0)
            {
                uint leafRecordNumber = getLeafNodeContainingRecord(recordKeyID);
                fs.Seek(leafRecordNumber * this.nodeSize, SeekOrigin.Begin);
                fs.Read(nodeRawData, 0, this.nodeSize);
                attributesLeafNode leafNode = new attributesLeafNode(ref nodeRawData);

                foreach (attributesLeafNode.HFSPlusAttrInlineData leafRecord in leafNode.inlineRecords)
                {
                    if (dataOperations.keyCompareResult.equalsTrialKey == attrKeyCompare(leafRecord.key, recordKeyID, caseSensitiveCompare) && found == false)
                    {
                        result = leafRecord;
                        found  = true;
                    }
                }
            }

            if (found)
            {
                return(result);
            }
            else
            {
                throw new KeyNotFoundException();
            }
        }
示例#2
0
        public attributesLeafNode.attributesDataForFile getAttrFileDataWithKey(HFSPlusAttrKey recordKeyID, bool caseSensitiveCompare = false)
        {
            byte[] nodeRawData = new byte[this.nodeSize];
            attributesLeafNode.attributesDataForFile allAttributes = new attributesLeafNode.attributesDataForFile();
            allAttributes.inline = new List <attributesLeafNode.HFSPlusAttrInlineData>();
            allAttributes.forks  = new List <attributesLeafNode.HFSPlusAttrForkData>();

            // find the root node
            uint currentNodeNumber = this.header.headerInfo.rootNode;

            fs.Seek(currentNodeNumber * this.nodeSize, SeekOrigin.Begin);
            fs.Read(nodeRawData, 0, this.nodeSize);
            absNode.nodeType currentNodeType = getNodeType(currentNodeNumber);

            // find the leaf where records matching this key start
            if (this.header.headerInfo.rootNode > 0)
            {
                uint leafRecordNumber = getLeafNodeContainingRecord(recordKeyID);
                fs.Seek(leafRecordNumber * this.nodeSize, SeekOrigin.Begin);
                fs.Read(nodeRawData, 0, this.nodeSize);
                attributesLeafNode leafNode = new attributesLeafNode(ref nodeRawData);


                bool allDataFound = false;
                while (!allDataFound)
                {
                    int recordsAdded = 0;
                    foreach (attributesLeafNode.HFSPlusAttrForkData leafRecord in leafNode.forkDataRecords)
                    {
                        if (dataOperations.keyCompareResult.equalsTrialKey == attrKeyCompare(leafRecord.key, recordKeyID, caseSensitiveCompare))
                        {
                            allAttributes.forks.Add(leafRecord);
                            recordsAdded++;
                        }
                    }
                    foreach (attributesLeafNode.HFSPlusAttrExtents leafRecord in leafNode.extentsRecords)
                    {
                        if (dataOperations.keyCompareResult.equalsTrialKey == attrKeyCompare(leafRecord.key, recordKeyID, caseSensitiveCompare))
                        {
                            // find out which forkdata record to add the extent to
                            foreach (attributesLeafNode.HFSPlusAttrForkData fork in allAttributes.forks)
                            {
                                if (fork.key.fileID == leafRecord.key.fileID && fork.key.attrName == leafRecord.key.attrName)
                                {
                                    // then add all the extents in the record
                                    for (int i = 0; i < leafRecord.extents.Count(); i++)
                                    {
                                        fork.theFork.forkDataValues.extents.Add(leafRecord.extents[i]);
                                    }
                                }
                            }
                            recordsAdded++;
                        }
                    }
                    foreach (attributesLeafNode.HFSPlusAttrInlineData leafRecord in leafNode.inlineRecords)
                    {
                        if (dataOperations.keyCompareResult.equalsTrialKey == attrKeyCompare(leafRecord.key, recordKeyID, caseSensitiveCompare))
                        {
                            allAttributes.inline.Add(leafRecord);
                            recordsAdded++;
                        }
                    }

                    // if the last record in the node matches the search key, there may be more matching records in the next node
                    // if the node is the last leaf node, its flink will be 0
                    if (attrKeyCompare(buildAttrTrialKey(leafNode.rawRecords[leafNode.rawRecords.Count() - 1]), recordKeyID, caseSensitiveCompare) == dataOperations.keyCompareResult.equalsTrialKey &&
                        leafNode.BTNodeDescriptor.fLink > 0)
                    {
                        uint nextNode = leafNode.BTNodeDescriptor.fLink;

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

                        leafNode = new attributesLeafNode(ref nodeRawData);
                    }
                    else
                    {
                        allDataFound = true;
                    }

                    //if (!allDataFound && recordsAdded == 0)
                    //{
                    //    throw new Exception("The specified search key was not found.");
                    //}
                }
            }

            return(allAttributes);
        }
示例#3
0
        public attributesLeafNode.attributesDataForFile getAttrFileDataWithKey(HFSPlusAttrKey recordKeyID, bool caseSensitiveCompare = false)
        {
            byte[] nodeRawData = new byte[this.nodeSize];
            attributesLeafNode.attributesDataForFile allAttributes = new attributesLeafNode.attributesDataForFile();
            allAttributes.inline = new List<attributesLeafNode.HFSPlusAttrInlineData>();
            allAttributes.forks = new List<attributesLeafNode.HFSPlusAttrForkData>();

            // find the root node
            uint currentNodeNumber = this.header.headerInfo.rootNode;
            fs.Seek(currentNodeNumber * this.nodeSize, SeekOrigin.Begin);
            fs.Read(nodeRawData, 0, this.nodeSize);
            absNode.nodeType currentNodeType = getNodeType(currentNodeNumber);

            // find the leaf where records matching this key start
            if(this.header.headerInfo.rootNode > 0)
            {
                uint leafRecordNumber = getLeafNodeContainingRecord(recordKeyID);
                fs.Seek(leafRecordNumber * this.nodeSize, SeekOrigin.Begin);
                fs.Read(nodeRawData, 0, this.nodeSize);
                attributesLeafNode leafNode = new attributesLeafNode(ref nodeRawData);

                bool allDataFound = false;
                while (!allDataFound)
                {
                    int recordsAdded = 0;
                    foreach (attributesLeafNode.HFSPlusAttrForkData leafRecord in leafNode.forkDataRecords)
                    {
                        if (dataOperations.keyCompareResult.equalsTrialKey == attrKeyCompare(leafRecord.key, recordKeyID, caseSensitiveCompare))
                        {
                            allAttributes.forks.Add(leafRecord);
                            recordsAdded++;
                        }
                    }
                    foreach (attributesLeafNode.HFSPlusAttrExtents leafRecord in leafNode.extentsRecords)
                    {
                        if (dataOperations.keyCompareResult.equalsTrialKey == attrKeyCompare(leafRecord.key, recordKeyID, caseSensitiveCompare))
                        {
                            // find out which forkdata record to add the extent to
                            foreach (attributesLeafNode.HFSPlusAttrForkData fork in allAttributes.forks)
                            {
                                if (fork.key.fileID == leafRecord.key.fileID && fork.key.attrName == leafRecord.key.attrName)
                                {
                                    // then add all the extents in the record
                                    for (int i = 0; i < leafRecord.extents.Count(); i++)
                                    {
                                        fork.theFork.forkDataValues.extents.Add(leafRecord.extents[i]);
                                    }
                                }
                            }
                            recordsAdded++;
                        }
                    }
                    foreach (attributesLeafNode.HFSPlusAttrInlineData leafRecord in leafNode.inlineRecords)
                    {
                        if (dataOperations.keyCompareResult.equalsTrialKey == attrKeyCompare(leafRecord.key, recordKeyID, caseSensitiveCompare))
                        {
                            allAttributes.inline.Add(leafRecord);
                            recordsAdded++;
                        }
                    }

                    // if the last record in the node matches the search key, there may be more matching records in the next node
                    // if the node is the last leaf node, its flink will be 0
                    if (attrKeyCompare(buildAttrTrialKey(leafNode.rawRecords[leafNode.rawRecords.Count() - 1]), recordKeyID, caseSensitiveCompare) == dataOperations.keyCompareResult.equalsTrialKey
                        && leafNode.BTNodeDescriptor.fLink > 0)
                    {
                        uint nextNode = leafNode.BTNodeDescriptor.fLink;

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

                        leafNode = new attributesLeafNode(ref nodeRawData);
                    }
                    else
                    {
                        allDataFound = true;
                    }

                    //if (!allDataFound && recordsAdded == 0)
                    //{
                    //    throw new Exception("The specified search key was not found.");
                    //}
                }
            }

            return allAttributes;
        }
示例#4
0
        public attributesLeafNode.HFSPlusAttrInlineData getAttriInlineDataWithKey(HFSPlusAttrKey recordKeyID, bool caseSensitiveCompare = false)
        {
            byte[] nodeRawData = new byte[this.nodeSize];

            attributesLeafNode.HFSPlusAttrInlineData result = new attributesLeafNode.HFSPlusAttrInlineData();

            // find the root node
            uint currentNodeNumber = this.header.headerInfo.rootNode;
            fs.Seek(currentNodeNumber * this.nodeSize, SeekOrigin.Begin);
            fs.Read(nodeRawData, 0, this.nodeSize);
            absNode.nodeType currentNodeType = getNodeType(currentNodeNumber);

            bool found = false;

            // get the leaf
            if (this.header.headerInfo.rootNode > 0)
            {
                uint leafRecordNumber = getLeafNodeContainingRecord(recordKeyID);
                fs.Seek(leafRecordNumber * this.nodeSize, SeekOrigin.Begin);
                fs.Read(nodeRawData, 0, this.nodeSize);
                attributesLeafNode leafNode = new attributesLeafNode(ref nodeRawData);

                foreach (attributesLeafNode.HFSPlusAttrInlineData leafRecord in leafNode.inlineRecords)
                {
                    if (dataOperations.keyCompareResult.equalsTrialKey == attrKeyCompare(leafRecord.key, recordKeyID, caseSensitiveCompare) && found == false)
                    {
                        result = leafRecord;
                        found = true;
                    }
                }
            }

            if (found)
            {
                return result;
            }
            else
            {
                throw new KeyNotFoundException();
            }
        }
 public void showInlineAttrData(attributesLeafNode.HFSPlusAttrInlineData entry)
 {
     rawDataDisplay(entry.otherData);
 }