internal List <NameEntry> ParseNames(Slice <byte> nameSection) { var names = new List <NameEntry>(); log.Info("name section: start {0:x}, length {1:x}", nameSection.Offset, nameSection.Count); while (nameSection.Count > 0) { var name = new NameEntry(); var length = nameSection[0]; // Each blob of names ends with a NUL. if (length == 0) { break; } if ((length & 0x80) == 0x80) { length -= 0x80; } else { name.IsFile = true; } log.Info("name found! length {0}, is file {1}", length, name.IsFile); nameSection = nameSection.After(1); name.Name = nameSection.ReadString(0, length); nameSection = nameSection.After(length); if (!name.IsFile) { name.DirectoryId = nameSection.ReadUShort(0); nameSection = nameSection.After(2); } names.Add(name); } return(names); }
public void AfterWithinRange() { var after = target.After(3); Assert.That(after.Offset, Is.EqualTo(3)); Assert.That(after[0], Is.EqualTo(3)); after = after.After(5); Assert.That(after.Offset, Is.EqualTo(8)); Assert.That(after[0], Is.EqualTo(8)); }
public Section(Slice <byte> data) { // The header is constrained to <= 255 bytes. // The body must be a multiple of 256 bytes. var headerLength = data.ReadUInt(4); Data = data; Header = data.Until(headerLength); Body = data.After(headerLength); Magic = data.ReadString(0, 4); }
public override void Load(Slice <byte> allocTable, Slice <byte> nameTable, Slice <byte> data) { _numFiles = allocTable.ReadUInt(0); base.Load(allocTable.After(4), nameTable, data); }