本文整理汇总了C++中BinaryFile::ReadUnsignedShort方法的典型用法代码示例。如果您正苦于以下问题:C++ BinaryFile::ReadUnsignedShort方法的具体用法?C++ BinaryFile::ReadUnsignedShort怎么用?C++ BinaryFile::ReadUnsignedShort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryFile
的用法示例。
在下文中一共展示了BinaryFile::ReadUnsignedShort方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ValidateFile
/**
*
* @author OLiver
*/
bool SavedFile::ValidateFile(BinaryFile& file, unsigned int signature_length, const char* signature, unsigned short version)
{
char read_signature[32];
file.ReadRawData(read_signature, signature_length);
// Signatur überprüfen
if(memcmp(read_signature, signature, signature_length))
{
// unterscheiden sich! --> raus
LOG.lprintf("SavedFile::Load: ERROR: Not a valid file!\n");
return false;
}
// Programmversion überspringen
file.Seek(8, SEEK_CUR);
// Version überprüfen
unsigned short read_version = file.ReadUnsignedShort();
if(read_version != version)
{
// anderes Dateiformat --> raus
LOG.lprintf("SavedFile::Load: ERROR: Old file version (version: %u; expected: %u)!\n", read_version, version);
return false;
}
return true;
}
示例2: ValidateFile
bool SavedFile::ValidateFile(BinaryFile& file, unsigned int signature_length, const char* signature, unsigned short version)
{
char read_signature[32];
file.ReadRawData(read_signature, signature_length);
// Signatur überprüfen
if(memcmp(read_signature, signature, signature_length) != 0)
{
// unterscheiden sich! --> raus
LOG.lprintf("Error: File is not in a valid format! File path: %s\n", file.getFilePath().c_str());
return false;
}
// Programmversion überspringen
file.Seek(8, SEEK_CUR);
// Version überprüfen
unsigned short read_version = file.ReadUnsignedShort();
if(read_version != version)
{
// anderes Dateiformat --> raus
LOG.lprintf("Warning: File has an old version and cannot be used (version: %u; expected: %u, file path: %s)!\n", read_version, version, file.getFilePath().c_str());
return false;
}
return true;
}