Processed node information for a node in the LSF file
예제 #1
0
파일: LSFReader.cs 프로젝트: Norbyte/lslib
        private void ReadNode(NodeInfo defn, Node node, BinaryReader attributeReader)
        {
            node.Name = Names[defn.NameIndex][defn.NameOffset];
            
#if DEBUG_LSF_SERIALIZATION
            Console.WriteLine(String.Format("Begin node {0}", node.Name));
#endif

            if (defn.FirstAttributeIndex != -1)
            {
                var attribute = Attributes[defn.FirstAttributeIndex];
                while (true)
                {
                    Values.Position = attribute.DataOffset;
                    var value = ReadAttribute((NodeAttribute.DataType)attribute.TypeId, attributeReader, attribute.Length);
                    node.Attributes[Names[attribute.NameIndex][attribute.NameOffset]] = value;

#if DEBUG_LSF_SERIALIZATION
                    Console.WriteLine(String.Format("    {0:X}: {1} ({2})", attribute.DataOffset, Names[attribute.NameIndex][attribute.NameOffset], value));
#endif

                    if (attribute.NextAttributeIndex == -1)
                    {
                        break;
                    }
                    else
                    {
                        attribute = Attributes[attribute.NextAttributeIndex];
                    }
                }
            }
        }
예제 #2
0
파일: LSFReader.cs 프로젝트: Norbyte/lslib
        /// <summary>
        /// Reads the structure headers for the LSOF resource
        /// </summary>
        /// <param name="s">Stream to read the node headers from</param>
        /// <param name="longNodes">Use the long (V3) on-disk node format</param>
        private void ReadNodes(Stream s, bool longNodes)
        {
#if DEBUG_LSF_SERIALIZATION
            Console.WriteLine(" ----- DUMP OF NODE TABLE -----");
#endif

            Nodes = new List<NodeInfo>();
            using (var reader = new BinaryReader(s))
            {
                Int32 index = 0;
                while (s.Position < s.Length)
                {
                    var resolved = new NodeInfo();

                    if (longNodes)
                    {
                        var item = BinUtils.ReadStruct<NodeEntryV3>(reader);
                        resolved.ParentIndex = item.ParentIndex;
                        resolved.NameIndex = item.NameIndex;
                        resolved.NameOffset = item.NameOffset;
                        resolved.FirstAttributeIndex = item.FirstAttributeIndex;
                    }
                    else
                    {
                        var item = BinUtils.ReadStruct<NodeEntryV2>(reader);
                        resolved.ParentIndex = item.ParentIndex;
                        resolved.NameIndex = item.NameIndex;
                        resolved.NameOffset = item.NameOffset;
                        resolved.FirstAttributeIndex = item.FirstAttributeIndex;
                    }

#if DEBUG_LSF_SERIALIZATION
                    Console.WriteLine(String.Format(
                        "{0}: {1} (parent {2}, firstAttribute {3})", 
                        Nodes.Count, Names[resolved.NameIndex][resolved.NameOffset], resolved.ParentIndex, 
                        resolved.FirstAttributeIndex
                    ));
#endif

                    Nodes.Add(resolved);
                    index++;
                }
            }
        }