MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / loadFromFile

Method loadFromFile

Source/Mogwai/AppData.cpp:92–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90 }
91
92 void AppData::loadFromFile(const std::filesystem::path& path)
93 {
94 std::ifstream ifs(path);
95 if (!ifs.good()) return;
96
97 auto readPathArray = [](const json& j)
98 {
99 std::vector<std::string> strings = j.get<std::vector<std::string>>();
100 std::vector<std::filesystem::path> paths;
101 std::transform(strings.begin(), strings.end(), std::back_inserter(paths), [](const std::string& str) { return str; });
102 return paths;
103 };
104
105 try
106 {
107 const json j = json::parse(ifs);
108 mRecentScripts = readPathArray(j[kRecentScripts]);
109 mRecentScenes = readPathArray(j[kRecentScenes]);
110 }
111 catch (const std::exception& e)
112 {
113 logWarning("Failed to parse Mogwai settings file '{}': {}", path, e.what());
114 }
115
116 removeNonExistingPaths(mRecentScripts);
117 removeNonExistingPaths(mRecentScenes);
118 }
119
120 void AppData::saveToFile(const std::filesystem::path& path)
121 {

Callers

nothing calls this directly

Calls 5

whatMethod · 0.80
parseFunction · 0.50
logWarningFunction · 0.50
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected