MCPcopy Create free account
hub / github.com/DFHack/dfhack / loadScriptPaths

Function loadScriptPaths

library/Core.cpp:541–573  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

539}
540
541bool loadScriptPaths(color_ostream &out, bool silent = false)
542{
543 std::filesystem::path filename{ getConfigPath() / "script-paths.txt" };
544 std::ifstream file(filename);
545 if (!file)
546 {
547 if (!silent)
548 out.printerr("Could not load {}\n", filename);
549 return false;
550 }
551 std::string raw;
552 int line = 0;
553 while (getline(file, raw))
554 {
555 ++line;
556 std::istringstream ss(raw);
557 char ch;
558 ss >> std::skipws;
559 if (!(ss >> ch) || ch == '#')
560 continue;
561 ss >> std::ws; // discard whitespace
562 std::string path;
563 getline(ss, path);
564 if (ch == '+' || ch == '-')
565 {
566 if (!Core::getInstance().addScriptPath(path, ch == '+') && !silent)
567 out.printerr("{}:{}: Failed to add path: {}\n", filename, line, path);
568 }
569 else if (!silent)
570 out.printerr("{}:{}: Illegal character: {}\n", filename, line, ch);
571 }
572 return true;
573}
574
575static void loadModScriptPaths(color_ostream &out) {
576 std::vector<std::string> mod_script_paths_str;

Callers 1

InitSimulationThreadMethod · 0.85

Calls 2

getConfigPathFunction · 0.85
addScriptPathMethod · 0.80

Tested by

no test coverage detected