本文整理汇总了C#中System.UInt32.SwapEndian方法的典型用法代码示例。如果您正苦于以下问题:C# UInt32.SwapEndian方法的具体用法?C# UInt32.SwapEndian怎么用?C# UInt32.SwapEndian使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.UInt32
的用法示例。
在下文中一共展示了UInt32.SwapEndian方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
private bool Load( System.IO.FileStream stream )
{
CreationTime = stream.ReadUInt64();
FileHashArrayOffset = stream.ReadUInt32();
// This should always be 0x20, so we can use it to detect endianness
if ( FileHashArrayOffset <= 0xFFFF ) {
Endian = Util.Endianness.LittleEndian;
} else {
Endian = Util.Endianness.BigEndian;
CreationTime = CreationTime.SwapEndian();
FileHashArrayOffset = FileHashArrayOffset.SwapEndian();
}
// We adjust the offsets to be from file start rather than from position, makes them easier to seek to.
FileHashArrayOffset += (uint)stream.Position - 4;
FileHashArraySize = stream.ReadUInt32().FromEndian( Endian );
VirtualHashArrayOffset = (uint)stream.Position;
VirtualHashArrayOffset += stream.ReadUInt32().FromEndian( Endian );
VirtualHashArraySize = stream.ReadUInt32().FromEndian( Endian );
FileArrayOffset = (uint)stream.Position;
FileArrayOffset += stream.ReadUInt32().FromEndian( Endian );
FileArraySize = stream.ReadUInt32().FromEndian( Endian );
VirtualPackArrayOffset = (uint)stream.Position;
VirtualPackArrayOffset += stream.ReadUInt32().FromEndian( Endian );
VirtualPackArraySize = stream.ReadUInt32().FromEndian( Endian );
// Hashes
stream.Position = FileHashArrayOffset;
FileHashArray = new List<TOFHDBhash>( (int)FileHashArraySize );
for ( UInt32 i = 0; i < FileHashArraySize; i++ ) {
FileHashArray.Add( new TOFHDBhash() {
Key = stream.ReadUInt32().FromEndian( Endian ),
Value = stream.ReadUInt32().FromEndian( Endian ),
} );
}
// Files
stream.Position = FileArrayOffset;
FileArray = new List<TOFHDBfile>( (int)FileArraySize );
for ( UInt32 i = 0; i < FileArraySize; i++ ) {
FileArray.Add( new TOFHDBfile() {
Filesize = stream.ReadUInt64().FromEndian( Endian ),
CompressedSize = stream.ReadUInt64().FromEndian( Endian ),
Offset = stream.ReadUInt64().FromEndian( Endian ),
Hash = stream.ReadUInt32().FromEndian( Endian ),
Extension = stream.ReadAscii( 0x0A ).TrimNull(),
Unknown = stream.ReadUInt16().FromEndian( Endian ),
} );
}
return true;
}