MCPcopy Create free account
hub / github.com/REGoth-project/REGoth / writeConfigFile

Method writeConfigFile

src/utils/cli.cpp:267–290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

265}
266
267void ::Cli::writeConfigFile()
268{
269 json j = json::object();
270
271 // Write each flag
272 for (Flag* f : Global::getFlagList())
273 f->writeToConfig(j);
274
275 // Dump using specified indentation. This is important for comments, since they use the same indentation!
276 std::string dumped = j.dump(JSON_DUMP_INDENTATION);
277
278 // Another pass, to insert the comments
279 for (Flag* f : Global::getFlagList())
280 dumped = f->documentConfigText(dumped);
281
282 // Write that one to disk now. Ensure the userdata-folder exists first, though
283 std::string userdata = Utils::getUserDataLocation();
284 if (!Utils::mkdir(userdata))
285 LogError() << "Failed to create userdata-directory at: " << userdata;
286
287 // Now create the file
288 if (!Utils::writeFile("config.json", userdata, dumped))
289 LogError() << "Failed to write config-file to: " << userdata << "/config.json";
290}

Callers

nothing calls this directly

Calls 3

writeToConfigMethod · 0.80
dumpMethod · 0.80
documentConfigTextMethod · 0.80

Tested by

no test coverage detected