public PSSGNode(EndianBinaryReader br, PSSG _pssgFile) { pssgFile = _pssgFile; ID = br.ReadInt32(); int size = br.ReadInt32(); long end = br.BaseStream.Position + size; int attributeSize = br.ReadInt32(); long attributeEnd = br.BaseStream.Position + attributeSize; /* read in the attributes */ Attributes = new Dictionary <string, PSSGAttribute>(); while (br.BaseStream.Position < attributeEnd) { PSSGAttribute attr = new PSSGAttribute(br, pssgFile); Attributes.Add(attr.Name, attr); } if (IsDataNode) { Data = br.ReadBytes((int)(end - br.BaseStream.Position)); } else { List <PSSGNode> tempSubNodes = new List <PSSGNode>(); while (br.BaseStream.Position < end) { tempSubNodes.Add(new PSSGNode(br, pssgFile)); } SubNodes = tempSubNodes.ToArray(); } }
public PSSGAttribute(EndianBinaryReader br, PSSG _pssgFile) { int size; /* to get the name of the attribute we need the global attribute info table */ pssgFile = _pssgFile; ID = br.ReadInt32(); size = br.ReadInt32(); if (size == 4) { Data = br.ReadInt32(); return; } else if (size > 4) { int len = br.ReadInt32(); if (size - 4 == len) { Data = Encoding.ASCII.GetString(br.ReadBytes(len)); return; } else { br.BaseStream.Seek(-4, SeekOrigin.Current); } } Data = br.ReadBytes(size); }