当前位置: 首页>>代码示例>>C#>>正文


C# DataStream.ReadNullTermString方法代码示例

本文整理汇总了C#中DataStream.ReadNullTermString方法的典型用法代码示例。如果您正苦于以下问题:C# DataStream.ReadNullTermString方法的具体用法?C# DataStream.ReadNullTermString怎么用?C# DataStream.ReadNullTermString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataStream的用法示例。


在下文中一共展示了DataStream.ReadNullTermString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Deserialize

            internal void Deserialize( DataStream ds )
            {
                FileName = ds.ReadNullTermString( Encoding.ASCII );

                TotalSize = ds.ReadUInt64();

                Flags = (EDepotFileFlag)ds.ReadUInt32();

                HashFileName = ds.ReadBytes( 20 );
                HashContent = ds.ReadBytes( 20 );

                NumChunks = ds.ReadUInt32();

                Chunks = new Chunk[ NumChunks ];

                for ( int x = 0 ; x < Chunks.Length ; ++x )
                {
                    Chunks[ x ] = new Chunk();
                    Chunks[ x ].Deserialize( ds );
                }
            }
开发者ID:KimimaroTsukimiya,项目名称:SteamBot-1,代码行数:21,代码来源:Manifest.cs

示例2: 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;
            }
        }
开发者ID:KimimaroTsukimiya,项目名称:SteamBot-1,代码行数:68,代码来源:Manifest.cs


注:本文中的DataStream.ReadNullTermString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。