internal Steam3Manifest(DataStream data) { Deserialize(data); }
const uint ENTRY_SIZE = 28; // the size of a single node internal Steam2Manifest(byte[] manifestBlob) { this.Nodes = new List <Node>(); using (DataStream ds = new DataStream(manifestBlob)) { uint headerVersion = ds.ReadUInt32(); this.DepotID = ds.ReadUInt32(); this.DepotVersion = ds.ReadUInt32(); this.NodeCount = ds.ReadUInt32(); this.FileCount = ds.ReadUInt32(); this.BlockSize = ds.ReadUInt32(); // checksum is the last field in the header ds.Seek(HEADER_SIZE - 4, SeekOrigin.Begin); this.DepotChecksum = ds.ReadUInt32(); // the start of the names section is after the header and every node uint namesStart = HEADER_SIZE + (this.NodeCount * ENTRY_SIZE); for (int x = 0; x < this.NodeCount; ++x) { ds.Seek(HEADER_SIZE + (x * ENTRY_SIZE), SeekOrigin.Begin); // the first value within a node is the offset from the start of the names section uint nameOffset = namesStart + ds.ReadUInt32(); Node entry = new Node { SizeOrCount = ds.ReadUInt32(), FileID = ds.ReadInt32(), Attributes = (Node.Attribs)ds.ReadUInt32(), ParentIndex = ds.ReadInt32(), Parent = this, }; ds.Seek(nameOffset, SeekOrigin.Begin); entry.Name = ds.ReadNullTermString(Encoding.ASCII); this.Nodes.Add(entry); } } // now build full names for (int x = 0; x < this.NodeCount; ++x) { Node entry = this.Nodes[x]; string fullName = entry.Name; while (entry.ParentIndex != -1) { entry = this.Nodes[entry.ParentIndex]; fullName = Path.Combine(entry.Name, fullName); } entry = this.Nodes[x]; entry.FullName = fullName; } }
/// <summary> /// Deserialize a MicroTime from an input byte array /// </summary> public static MicroTime Deserialize(byte[] data) { DataStream ds = new DataStream(data); return(new MicroTime(ds.ReadUInt64())); }