| 118 | } |
| 119 | |
| 120 | void AppData::saveToFile(const std::filesystem::path& path) |
| 121 | { |
| 122 | auto getPathArray = [](const std::vector<std::filesystem::path>& paths) |
| 123 | { |
| 124 | std::vector<std::string> strings; |
| 125 | std::transform(paths.begin(), paths.end(), std::back_inserter(strings), [](const std::filesystem::path& path) { return path.string(); }); |
| 126 | return json(strings); |
| 127 | }; |
| 128 | |
| 129 | json j = json::object(); |
| 130 | j[kRecentScripts] = getPathArray(mRecentScripts); |
| 131 | j[kRecentScenes] = getPathArray(mRecentScenes); |
| 132 | |
| 133 | std::ofstream ofs(path); |
| 134 | if (!ofs.good()) return; |
| 135 | |
| 136 | ofs << j.dump(4); |
| 137 | } |
| 138 | } |