本文整理汇总了C#中DataStream.ReadInt32方法的典型用法代码示例。如果您正苦于以下问题:C# DataStream.ReadInt32方法的具体用法?C# DataStream.ReadInt32怎么用?C# DataStream.ReadInt32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataStream
的用法示例。
在下文中一共展示了DataStream.ReadInt32方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Steam2Manifest
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;
}
}