void IEParamRegister::Init() { char path[_MAX_PATH]; wsprintf(path, "%s\\%s", m_IEStartDir.c_str(), m_IEParamRegisterDat.c_str()); //read dat file FILE* fp; if ((fp = fopen(path, "rb")) == NULL) { OutputError::PushLog(LOG_LEVEL::_WARN, "can't open param register dat file"); return; } try { uint32_t i,j; uint32_t num_of_section = Read4ByteLE(fp); for (i=0; i<num_of_section; i++) { //read section name uint16_t section_name_len = Read2ByteLE(fp); char* buf = new char[section_name_len + 1]; ReadString(fp, section_name_len, buf); //add section to map IEParamMap *pParamMap = new IEParamMap; m_ieSectionMap.insert(IESectionMap::value_type(buf, pParamMap)); delete[] buf; buf = NULL; //read param in section uint32_t section_size = Read4ByteLE(fp); for (j=0; j<section_size; j++) { uint16_t name_len = Read2ByteLE(fp); char* name = new char[name_len+1]; ReadString(fp, name_len, name); uint16_t val_len = Read2ByteLE(fp); char* val = new char[val_len+1]; ReadString(fp, val_len, val); pParamMap->insert(IEParamMap::value_type(name, val)); delete[] val; val = NULL; delete[] name; name = NULL; } } fclose(fp); } catch (std::ios_base::failure& e) { fclose(fp); OutputError::PushLog(LOG_LEVEL::_ERROR, "read param register file exception: ", e.what()); } }
void IEKeyMap::Init() { m_isChanged = false; 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, "rb")) == NULL) { m_isChanged = true; OutputError::PushLog(LOG_LEVEL::_INFO, "can't open keymap dat file. create default keymap"); MakeDefaultKeyMap(); return; } uint32_t i,j; uint32_t category_size = Read2ByteLE(fp); if (category_size != 2) { m_isChanged = true; OutputError::PushLog(LOG_LEVEL::_WARN, "invalid format keymap dat file"); return; } uint32_t shortcut_size = Read4ByteLE(fp); uint32_t toolshift_size = Read4ByteLE(fp); for (i=0; i<shortcut_size; i++) { uint32_t key_code = Read4ByteLE(fp); uint32_t cmd_length = Read2ByteLE(fp); char* cmd = new char[cmd_length+1]; ReadString(fp, cmd_length, cmd); m_ieShortCutMap.insert(IEShortCutMap::value_type(key_code, cmd)); delete[] cmd; } for (i=0; i<toolshift_size; i++) { uint32_t key_code = Read4ByteLE(fp); uint32_t name_length = Read2ByteLE(fp); char* tool_name = new char[name_length+1]; ReadString(fp, name_length, tool_name); m_ieToolShiftMap.insert(IEToolShiftMap::value_type(key_code, tool_name)); delete[] tool_name; } }