| 194 | } |
| 195 | |
| 196 | bool ReadConfigFile(ConfigParam* configParam) { |
| 197 | if (!configParam) { |
| 198 | return false; |
| 199 | } |
| 200 | |
| 201 | const auto& configPath = GetConfigPath(); |
| 202 | if (configPath.empty()) { |
| 203 | return false; |
| 204 | } |
| 205 | |
| 206 | std::string filename = configPath + "PAGConfig.xml"; |
| 207 | if (!FileIsExist(filename)) { |
| 208 | WriteDefaultConfigFile(filename.c_str()); |
| 209 | return false; |
| 210 | } |
| 211 | |
| 212 | XMLDocument doc; |
| 213 | if (doc.LoadFile(filename.c_str()) != XML_SUCCESS) { |
| 214 | return false; |
| 215 | } |
| 216 | |
| 217 | XMLElement* rootElement = doc.FirstChildElement("pag-exporter"); |
| 218 | if (!rootElement) { |
| 219 | return false; |
| 220 | } |
| 221 | |
| 222 | XMLElement* commonElement = rootElement->FirstChildElement("common"); |
| 223 | XMLElement* bitmapElement = rootElement->FirstChildElement("bitmap"); |
| 224 | |
| 225 | if (!commonElement || !bitmapElement) { |
| 226 | return false; |
| 227 | } |
| 228 | |
| 229 | ReadCommonConfig(commonElement, configParam); |
| 230 | ReadBitmapConfig(bitmapElement, configParam); |
| 231 | |
| 232 | return true; |
| 233 | } |
| 234 | |
| 235 | void WriteConfigFile(ConfigParam* configParam) { |
| 236 | if (!configParam) { |
no test coverage detected