public override void Load(Stream fileStream) { // Header var reader = new BINAReader(fileStream); reader.ReadHeader(); //File related header stuff uint fileCount = reader.ReadUInt32(); uint fileEntriesPos = reader.ReadUInt32(); //Type related header stuff uint typeCount = reader.ReadUInt32(); uint typeEntriesPos = reader.ReadUInt32(); //Read Types reader.JumpTo(typeEntriesPos, false); for (uint i = 0; i < typeCount; ++i) { S06TypeEntry type = new S06TypeEntry(); uint namePos = reader.ReadUInt32(); uint typeFileCount = reader.ReadUInt32(); uint filesPos = reader.ReadUInt32(); long pos = reader.BaseStream.Position; reader.JumpTo(namePos, false); type.TypeName = reader.ReadNullTerminatedString(); reader.JumpTo(filesPos, false); //Read Objects for (uint f = 0; f < typeFileCount; ++f) { S06FileEntry file = new S06FileEntry(); uint friendlyNamePos = reader.ReadUInt32(); uint filePathPos = reader.ReadUInt32(); long curPos = reader.BaseStream.Position; reader.JumpTo(friendlyNamePos, false); file.FriendlyName = reader.ReadNullTerminatedString(); reader.JumpTo(filePathPos, false); file.FilePath = reader.ReadNullTerminatedString(); reader.JumpTo(curPos); type.Files.Add(file); } Types.Add(type); reader.JumpTo(pos, true); } }
public void ImportXML(string filepath) { var xml = XDocument.Load(filepath); foreach (var typeElem in xml.Root.Elements("Type")) { S06TypeEntry typeEntry = new S06TypeEntry(); typeEntry.TypeName = typeElem.Attribute("Name").Value; foreach (var fileElem in typeElem.Elements("File")) { S06FileEntry fileEntry = new S06FileEntry(); fileEntry.FriendlyName = fileElem.Attribute("FriendlyName").Value; fileEntry.FilePath = fileElem.Value; typeEntry.Files.Add(fileEntry); } Types.Add(typeEntry); } }