UInt32 GetPresetCrc(PresetElement* pPreset) { Crc32 crc; Int32 l, lCount; UpdateCRC(crc, pPreset->strOrigin); UpdateCRC(crc, pPreset->strDestination); UpdateCRC(crc, pPreset->strName); UpdateCRC(crc, pPreset->strPassword); crc.Update(&pPreset->bCreateZipFile, sizeof(pPreset->bCreateZipFile)); crc.Update(&pPreset->lCreateZipCompressionLevel, sizeof(pPreset->lCreateZipCompressionLevel)); crc.Update(&pPreset->bCheckVersion, sizeof(pPreset->bCheckVersion)); crc.Update(&pPreset->bParseSymbols, sizeof(pPreset->bParseSymbols)); crc.Update(&pPreset->bWriteBuildInfo, sizeof(pPreset->bWriteBuildInfo)); crc.Update(&pPreset->bBatch, sizeof(pPreset->bBatch)); crc.Update(&pPreset->bRemoveSCC, sizeof(pPreset->bRemoveSCC)); lCount = pPreset->arFilters.GetElementCount(); for (l = 0; l < lCount; l++) { FilterElement* pFilter = pPreset->arFilters[l]; if (!pFilter) continue; crc.Update(&pFilter->lCondition, sizeof(pFilter->lCondition)); crc.Update(&pFilter->lAction, sizeof(pFilter->lAction)); UpdateCRC(crc, pFilter->str); UpdateCRC(crc, pFilter->strRename); crc.Update(&pFilter->bSetXBit, sizeof(pFilter->bSetXBit)); } return crc.GetCrc(); }
void UpdateCRC(Crc32 &crc, const String &str) { Int32 lLen = str.GetCStringLen(); Char* pchString = NewMem(Char,lLen + 2); if (!pchString) return; str.GetCString(pchString, lLen + 1); crc.Update(pchString, lLen); DeleteMem(pchString); }