MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / loadFile

Method loadFile

launcher/settings/INIFile.cpp:152–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150}
151
152bool INIFile::loadFile(QString fileName)
153{
154 QSettings _settings_obj{ fileName, QSettings::Format::IniFormat };
155 _settings_obj.setFallbacksEnabled(false);
156
157 if (auto status = _settings_obj.status(); status != QSettings::Status::NoError) {
158 if (status == QSettings::Status::AccessError)
159 qCritical() << "An access error occurred (e.g. trying to write to a read-only file).";
160 if (status == QSettings::Status::FormatError)
161 qCritical() << "A format error occurred (e.g. loading a malformed INI file).";
162 return false;
163 }
164 if (!_settings_obj.value("ConfigVersion").isValid()) {
165 QFile file(fileName);
166 if (!file.open(QIODevice::ReadOnly))
167 return false;
168 QSettings::SettingsMap map;
169 parseOldFileFormat(file, map);
170 file.close();
171 for (auto&& key : map.keys())
172 insert(key, map.value(key));
173 insert("ConfigVersion", "1.2");
174 } else if (_settings_obj.value("ConfigVersion").toString() == "1.1") {
175 for (auto&& key : _settings_obj.allKeys()) {
176 if (auto valueStr = _settings_obj.value(key).toString();
177 (valueStr.contains(QChar(';')) || valueStr.contains(QChar('=')) || valueStr.contains(QChar(','))) &&
178 valueStr.endsWith("\"") && valueStr.startsWith("\"")) {
179 insert(key, unquote(valueStr));
180 } else
181 insert(key, _settings_obj.value(key));
182 }
183 insert("ConfigVersion", "1.2");
184 } else
185 for (auto&& key : _settings_obj.allKeys())
186 insert(key, _settings_obj.value(key));
187 return true;
188}
189
190bool INIFile::loadFile(QByteArray data)
191{

Callers 9

runMethod · 0.80
INISettingsObjectMethod · 0.80
reloadMethod · 0.80
ReadForgeInfoFunction · 0.80
test_SaveLoadMethod · 0.80
test_SaveLoadListsMethod · 0.80

Calls 12

parseOldFileFormatFunction · 0.85
unquoteFunction · 0.85
valueMethod · 0.80
openMethod · 0.80
closeMethod · 0.80
statusMethod · 0.45
isValidMethod · 0.45
toStringMethod · 0.45
containsMethod · 0.45
writeMethod · 0.45
flushMethod · 0.45
removeMethod · 0.45