|
|
@@ -24,12 +24,25 @@ static const char PATCH_FILTERS[] = "VCV Rack patch (.vcv):vcv"; |
|
|
|
|
|
|
|
Manager::Manager() { |
|
|
|
autosavePath = asset::user("autosave"); |
|
|
|
|
|
|
|
// Use a different temporary autosave dir when safe mode is enabled, to avoid altering normal autosave. |
|
|
|
if (settings::safeMode) { |
|
|
|
autosavePath = asset::user("autosave-safe"); |
|
|
|
clearAutosave(); |
|
|
|
} |
|
|
|
|
|
|
|
templatePath = asset::user("template.vcv"); |
|
|
|
factoryTemplatePath = asset::system("template.vcv"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Manager::~Manager() { |
|
|
|
// In safe mode, delete autosave dir. |
|
|
|
if (settings::safeMode) { |
|
|
|
clearAutosave(); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// Dispatch onSave to all Modules so they save their patch storage, etc. |
|
|
|
APP->engine->prepareSave(); |
|
|
|
// Save autosave if not headless |
|
|
@@ -41,19 +54,16 @@ Manager::~Manager() { |
|
|
|
|
|
|
|
|
|
|
|
void Manager::launch(std::string pathArg) { |
|
|
|
// Don't load any patches if safe mode is enabled |
|
|
|
if (settings::safeMode) |
|
|
|
return; |
|
|
|
|
|
|
|
// Load the argument if exists |
|
|
|
if (pathArg != "") { |
|
|
|
loadAction(pathArg); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// Don't load autosave or template if safe mode is enabled |
|
|
|
if (settings::safeMode) { |
|
|
|
clear(); |
|
|
|
clearAutosave(); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// Try loading the autosave patch |
|
|
|
if (hasAutosave()) { |
|
|
|
try { |
|
|
@@ -222,7 +232,6 @@ void Manager::saveAutosave() { |
|
|
|
|
|
|
|
void Manager::clearAutosave() { |
|
|
|
system::removeRecursively(autosavePath); |
|
|
|
system::createDirectories(autosavePath); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@@ -265,6 +274,7 @@ void Manager::load(std::string path) { |
|
|
|
|
|
|
|
clear(); |
|
|
|
clearAutosave(); |
|
|
|
system::createDirectories(autosavePath); |
|
|
|
|
|
|
|
if (isPatchLegacyV1(path)) { |
|
|
|
// Copy the .vcv file directly to "patch.json". |
|
|
@@ -316,7 +326,6 @@ void Manager::loadTemplateDialog() { |
|
|
|
|
|
|
|
bool Manager::hasAutosave() { |
|
|
|
std::string patchPath = system::join(autosavePath, "patch.json"); |
|
|
|
INFO("Loading autosave %s", patchPath.c_str()); |
|
|
|
FILE* file = std::fopen(patchPath.c_str(), "r"); |
|
|
|
if (!file) |
|
|
|
return false; |
|
|
|