MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / load

Function load

launcher/minecraft/gameoptions/GameOptions.cpp:7–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5
6namespace {
7bool load(const QString& path, std::vector<GameOptionItem> &contents, int & version)
8{
9 contents.clear();
10 QFile file(path);
11 if (!file.open(QFile::ReadOnly))
12 {
13 qWarning() << "Failed to read options file.";
14 return false;
15 }
16 version = 0;
17 while(!file.atEnd())
18 {
19 auto line = file.readLine();
20 if(line.endsWith('\n'))
21 {
22 line.chop(1);
23 }
24 auto separatorIndex = line.indexOf(':');
25 if(separatorIndex == -1)
26 {
27 continue;
28 }
29 auto key = QString::fromUtf8(line.data(), separatorIndex);
30 auto value = QString::fromUtf8(line.data() + separatorIndex + 1, line.size() - 1 - separatorIndex);
31 qDebug() << "!!" << key << "!!";
32 if(key == "version")
33 {
34 version = value.toInt();
35 continue;
36 }
37 contents.emplace_back(GameOptionItem{key, value});
38 }
39 qDebug() << "Loaded" << path << "with version:" << version;
40 return true;
41}
42bool save(const QString& path, std::vector<GameOptionItem> &mapping, int version)
43{
44 QSaveFile out(path);

Callers 6

getLoadTaskMethod · 0.85
observeMethod · 0.85
dirChangedMethod · 0.85
getLoadTaskMethod · 0.85
reloadMethod · 0.85
reloadMethod · 0.85

Calls 4

openMethod · 0.80
clearMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected