MCPcopy Create free account
hub / github.com/PenguLoader/PenguLoader / get_config_map

Function get_config_map

core/src/config.cc:101–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101static auto get_config_map()
102{
103 static bool cached = false;
104 static std::unordered_map<std::string, std::string> map;
105
106 if (!cached)
107 {
108 auto path = config::loader_dir() / "config";
109 std::ifstream file(path);
110
111 if (file.is_open())
112 {
113 std::string line;
114 while (std::getline(file, line))
115 {
116 // ignore empty line or comment
117 if (line.empty() || line[0] == ';' || line[0] == '#')
118 continue;
119
120 size_t pos = line.find('=');
121 if (pos != std::string::npos)
122 {
123 std::string key = line.substr(0, pos);
124 std::string value = line.substr(pos + 1);
125
126 trim_tring(key);
127 trim_tring(value);
128
129 map[key] = value;
130 }
131 }
132 file.close();
133 }
134
135 cached = true;
136 }
137
138 return map;
139}
140
141static std::string get_config_value(const char *key, const char *fallback)
142{

Callers 3

get_config_valueFunction · 0.85
get_config_value_boolFunction · 0.85
get_config_value_intFunction · 0.85

Calls 2

trim_tringFunction · 0.85
emptyMethod · 0.80

Tested by

no test coverage detected