コード例 #1
0
        public TreeNode getDirectoryChildren(HFSPlusCatalogFolder folderRecord, catalogFile cf, extentsOverflowFile eof, attributesFile af)
        {
            TreeNode returnDir = new TreeNode();

            // get every file and directory inside the current one
            returnDir = cf.getDirectoryAndChildren(folderRecord, eof, this.partitionNo);

            foreach (TreeNode child in returnDir.Nodes)
            {
                // check if there are any alternate data streams for the files
                if (child.Tag is HFSPlusCatalogFile)
                {
                    HFSPlusCatalogFile data = (HFSPlusCatalogFile)child.Tag;

                    attributesFile.HFSPlusAttrKey attrKey = new attributesFile.HFSPlusAttrKey();

                    attrKey.fileID     = data.fileID;
                    attrKey.startBlock = 0;
                    attributesLeafNode.attributesDataForFile allAttributes = af.getAttrFileDataWithKey(attrKey);

                    foreach (attributesLeafNode.HFSPlusAttrForkData fork in allAttributes.forks)
                    {
                        TreeNode attribute = new TreeNode();

                        attributesLeafNode.HFSPlusAttrForkData tag = fork;
                        tag.partitionAssoc = folderRecord.partitionAssoc;

                        attribute.Text = child.Text + " > " + System.Text.Encoding.BigEndianUnicode.GetString(fork.key.attrName);
                        attribute.Tag  = tag;

                        returnDir.Nodes.Add(attribute);
                    }
                    foreach (attributesLeafNode.HFSPlusAttrInlineData inline in allAttributes.inline)
                    {
                        TreeNode attribute = new TreeNode();

                        attributesLeafNode.HFSPlusAttrInlineData tag = inline;
                        tag.partitionAssoc = folderRecord.partitionAssoc;

                        attribute.Text = child.Text + " > " + System.Text.Encoding.BigEndianUnicode.GetString(inline.key.attrName);
                        attribute.Tag  = tag;
                        returnDir.Nodes.Add(attribute);
                    }
                }
            }

            return(returnDir);
        }
コード例 #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;
        }