uint8 CBMPFormat::detectBMPVersion(void) { CDataReader *pDataReader = CDataReader::getInstance(); uint8 uiBMPVersion = 0; pDataReader->setPeek(true); string strHeader = pDataReader->readString(2); if (strHeader.c_str()[0] == '\0' && strHeader.c_str()[1] == '\0') { // BMP version 1.x uiBMPVersion = 1; } else if (strHeader.c_str()[0] == 'B' && strHeader.c_str()[1] == 'M') { // BMP version 2.x, 3.x or 4.x pDataReader->setSeek(12); switch (pDataReader->readUint32()) { case 12: // BMP version 2.x uiBMPVersion = 2; break; case 40: // BMP version 3.x uiBMPVersion = 3; break; case 108: // BMP version 4.x uiBMPVersion = 4; } } pDataReader->setPeek(false); pDataReader->setSeek(0); return uiBMPVersion; }
eDATPathFormat CDATPathFormat::detectPathsFormat(void) { CDataReader *pDataReader = CDataReader::getInstance(); eDATPathFormat eDATPathFormatValue; uint32 uiPreviousSeek = pDataReader->getSeek(); pDataReader->setPeek(true); if (CStringUtility::unpackUint32(pDataReader->readString(4), false) == 0xFFFFFFFF && pDataReader->readString(4) == "FM92") { eDATPathFormatValue = DAT_PATH_FASTMAN92; } else { eDATPathFormatValue = DAT_PATH_DEFAULT; } pDataReader->setSeek(uiPreviousSeek); pDataReader->setPeek(false); return eDATPathFormatValue; }