private void ReadBlorb() { foreach (var chunk in this.reader.GetChunks(0)) { var node = new IffInfoNode(null, chunk); this.HandleIffInfoNode(node, 0); } }
public IffInfoNode(IffInfoNode parent, IffInfo info) : this(parent, info.Offset, info.TypeId, info.Length) { }
public IffInfoNode(IffInfoNode parent, uint offset, string typeId, uint length) : base(offset, typeId, length) { this.Parent = parent; }
private void HandleIffInfoNode(IffInfoNode info, int depth) { this.infoNodes.Add(info); switch (info.TypeId) { case "FORM": var formType = this.reader.ReadTypeId(info.ContentOffset); if (depth == 0 && formType != "IFRS") { Console.WriteLine("Unexpected FORM subtype!"); } // ignore sounds! if (formType != "AIFF") { foreach (var chunk in this.reader.GetChunks(info.ContentOffset + 4)) { var node = new IffInfoNode(info, chunk); this.HandleIffInfoNode(node, depth + 1); } } break; case "RIdx": if (this.sawResources) { Console.WriteLine(" - already saw resource index! Unexpected!"); } else { Console.WriteLine(); var count = this.reader.ReadUint(info.Offset + 8); uint expectedCount = (info.Length - 4) / 12; System.Diagnostics.Debug.Assert(count == expectedCount); for (uint i = 0; i < expectedCount; ++i) { var indexType = this.reader.ReadTypeId(); var indexId = this.reader.ReadUint(); var indexOffset = this.reader.ReadUint(); switch (indexType) { case "Pict": this.UpdateResourceIndex(ref this.pictResources, indexId, indexOffset); break; case "Snd ": this.UpdateResourceIndex(ref this.sndResources, indexId, indexOffset); break; case "Data": this.UpdateResourceIndex(ref this.dataResources, indexId, indexOffset); break; case "Exec": this.UpdateResourceIndex(ref this.execResources, indexId, indexOffset); break; default: Console.WriteLine("* unknown resource type {0}", indexType); break; } } this.sawResources = true; } break; case "IFmd": if (this.metadataInfo != null) { Console.WriteLine(" - extra ID metadata? This is unexpected!"); } else { this.metadataInfo = info; } break; case "Fspc": if (this.coverImage.HasValue) { Console.WriteLine(" - already have a Frontspiece! Unexpected!"); } else { this.coverImage = this.reader.ReadUint(info.Offset + 8); } break; default: break; } }