MCPcopy Create free account
hub / github.com/VCVRack/Rack / saveAutosave

Method saveAutosave

src/patch.cpp:237–257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

235
236
237void Manager::saveAutosave() {
238 std::string patchPath = system::join(autosavePath, "patch.json");
239 INFO("Saving autosave %s", patchPath.c_str());
240 json_t* rootJ = toJson();
241 if (!rootJ)
242 return;
243 DEFER({json_decref(rootJ);});
244
245 // Write to temporary path and then rename it to the correct path
246 system::createDirectories(autosavePath);
247 std::string tmpPath = patchPath + ".tmp";
248 FILE* file = std::fopen(tmpPath.c_str(), "w");
249 if (!file) {
250 // Fail silently
251 return;
252 }
253
254 json_dumpf(rootJ, file, JSON_INDENT(2));
255 std::fclose(file);
256 system::rename(tmpPath, patchPath);
257}
258
259
260void Manager::clearAutosave() {

Callers 2

~ManagerMethod · 0.80
stepMethod · 0.80

Calls 4

toJsonFunction · 0.85
createDirectoriesFunction · 0.85
renameFunction · 0.85
joinFunction · 0.70

Tested by

no test coverage detected