MCPcopy Create free account
hub / github.com/MhmRdd/NoHello / loadFromFile

Method loadFromFile

module/src/main/cpp/PropertyManager.cpp:11–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9}
10
11bool PropertyManager::loadFromFile() {
12 orderedProps.clear();
13 keyIndex.clear();
14
15 std::ifstream file(filePath);
16 if (!file.is_open()) {
17 LOGW("PropertyManager: Could not open %s for loading.", filePath.c_str());
18 return false;
19 }
20
21 std::string line;
22 while (std::getline(file, line)) {
23 if (line.empty() || line[0] == '#')
24 continue;
25
26 auto pos = line.find('=');
27 if (pos == std::string::npos)
28 continue;
29
30 std::string key = line.substr(0, pos);
31 std::string val = line.substr(pos + 1);
32
33 size_t idx = orderedProps.size();
34 orderedProps.emplace_back(key, val);
35 keyIndex[key] = idx;
36 }
37
38 file.close();
39 return true;
40}
41
42bool PropertyManager::saveToFile() {
43 std::ofstream file(filePath, std::ios::trunc);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected