| 140 | |
| 141 | |
| 142 | void CfgFile::UpdateOrCreateEntry( const char *inszSection, const char *inszKey, const char *inszValue ) |
| 143 | { |
| 144 | Section *sec = FindSection( inszSection ); assert(sec); |
| 145 | |
| 146 | for(std::list<Entry>::iterator it = sec->entries.begin(); it != sec->entries.end(); ++it) |
| 147 | { |
| 148 | if(stricmp(it->key.GetString(),inszKey) == 0) // Key found |
| 149 | if(!it->IsComment()) // update key |
| 150 | { |
| 151 | if(it->value==inszValue) |
| 152 | return; |
| 153 | |
| 154 | it->value=inszValue; |
| 155 | m_modified=true; |
| 156 | return; |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | // Create new key |
| 161 | Entry entry; |
| 162 | entry.key = inszKey; |
| 163 | entry.value = inszValue; |
| 164 | |
| 165 | sec->entries.push_back(entry); |
| 166 | m_modified=true; |
| 167 | } |
| 168 | |
| 169 | |
| 170 | |