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

Function parseOldFileFormat

launcher/settings/INIFile.cpp:116–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114}
115
116bool parseOldFileFormat(QIODevice& device, QSettings::SettingsMap& map)
117{
118 QTextStream in(device.readAll());
119#if QT_VERSION <= QT_VERSION_CHECK(6, 0, 0)
120 in.setCodec("UTF-8");
121#endif
122
123 QStringList lines = in.readAll().split('\n');
124 for (int i = 0; i < lines.count(); i++) {
125 QString& lineRaw = lines[i];
126 // Ignore comments.
127 int commentIndex = 0;
128 QString line = lineRaw;
129 // Search for comments until no more escaped # are available
130 while ((commentIndex = line.indexOf('#', commentIndex + 1)) != -1) {
131 if (commentIndex > 0 && line.at(commentIndex - 1) == '\\') {
132 continue;
133 }
134 line = line.left(lineRaw.indexOf('#')).trimmed();
135 }
136
137 int eqPos = line.indexOf('=');
138 if (eqPos == -1)
139 continue;
140 QString key = line.left(eqPos).trimmed();
141 QString valueStr = line.right(line.length() - eqPos - 1).trimmed();
142
143 valueStr = unquote(unescape(valueStr));
144
145 QVariant value(valueStr);
146 map.insert(key, value);
147 }
148
149 return true;
150}
151
152bool INIFile::loadFile(QString fileName)
153{

Callers 1

loadFileMethod · 0.85

Calls 5

unquoteFunction · 0.85
unescapeFunction · 0.85
insertMethod · 0.80
countMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected