void IEParamRegister::End() { uint32_t i,j; char path[_MAX_PATH]; wsprintf(path, "%s\\%s", m_IEStartDir.c_str(), m_IEParamRegisterDat.c_str()); //write dat file FILE* fp; if ((fp = fopen(path, "wb")) == NULL) { OutputError::PushLog(LOG_LEVEL::_WARN, "can't open param register dat file"); return; } try { uint32_t num_of_section = m_ieSectionMap.size(); Write4ByteLE(fp, num_of_section); //write section map IESectionMap::iterator itr = m_ieSectionMap.begin(); for (; itr != m_ieSectionMap.end(); itr++) { //write section name uint16_t section_name_len = (*itr).first.size(); Write2ByteLE(fp, section_name_len); WriteString(fp, section_name_len, (*itr).first.c_str()); //write param in section IEParamMap* pParamMap = (*itr).second; uint32_t section_size = pParamMap->size(); Write4ByteLE(fp, section_size); IEParamMap::iterator itr = pParamMap->begin(); for (; itr != pParamMap->end(); itr++) { //write name uint16_t name_len = (*itr).first.size(); Write2ByteLE(fp, name_len); WriteString(fp, name_len, (*itr).first.c_str()); //write value uint16_t val_len = (*itr).second.size(); Write2ByteLE(fp, val_len); WriteString(fp, val_len, (*itr).second.c_str()); } } fclose(fp); } catch (std::ios_base::failure& e) { fclose(fp); OutputError::PushLog(LOG_LEVEL::_ERROR, "write param register file exception: ", e.what()); } }
void IEKeyMap::End() { if (m_isChanged) { uint32_t i,j; char path[_MAX_PATH]; wsprintf(path, "%s\\%s", m_IEStartDir.c_str(), m_IEKeyMapDat.c_str()); //read dat file FILE* fp; if ((fp = fopen(path, "wb")) == NULL) { OutputError::PushLog(LOG_LEVEL::_WARN, "can't open keymap dat file"); return; } //write dat file Write2ByteLE(fp, 2); //category_size uint32_t shortcut_size = m_ieShortCutMap.size(); uint32_t toolshift_size = m_ieToolShiftMap.size(); Write4ByteLE(fp, shortcut_size); Write4ByteLE(fp, toolshift_size); //write shortcut key map IEShortCutMap::iterator itr = m_ieShortCutMap.begin(); for (; itr != m_ieShortCutMap.end(); itr++) { Write4ByteLE(fp, (*itr).first ); //keycode uint16_t cmd_length = (*itr).second.size(); Write2ByteLE(fp, cmd_length ); //cmd length WriteString(fp, cmd_length, (*itr).second.c_str()); } //write toolshift key map IEToolShiftMap::iterator itr_ts = m_ieToolShiftMap.begin(); for (; itr_ts != m_ieToolShiftMap.end(); itr_ts++) { Write4ByteLE(fp, (*itr_ts).first ); //keycode uint16_t name_length = (*itr_ts).second.size(); Write2ByteLE( fp, name_length ); WriteString(fp, name_length, (*itr_ts).second.c_str()); } } }