diff options
author | Andrew Belt <andrewpbelt@gmail.com> | 2024-04-22 02:28:59 -0400 |
---|---|---|
committer | Andrew Belt <andrewpbelt@gmail.com> | 2024-04-22 02:28:59 -0400 |
commit | 7545ada7e3d71cec04e3165511aad132ec299129 (patch) | |
tree | fc01f2adacc7f08bd12dca4c8c5260f80499cb3c | |
parent | 5ea08323e421f6e1dbbf3154f3a0baa2e4ffbd21 (diff) |
Use default patch dir in open/save dialogs if current patch dir doesn't exist.
-rw-r--r-- | src/patch.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/patch.cpp b/src/patch.cpp index 861e0aa4..ec468e6a 100644 --- a/src/patch.cpp +++ b/src/patch.cpp @@ -155,14 +155,19 @@ void Manager::saveDialog() { void Manager::saveAsDialog(bool setPath) { std::string dir; std::string filename; - if (this->path == "") { + if (this->path != "") { + dir = system::getDirectory(this->path); + filename = system::getFilename(this->path); + } + + // Default to <Rack user dir>/patches + if (dir == "" || !system::isDirectory(dir)) { dir = asset::user("patches"); system::createDirectories(dir); - filename = "Untitled.vcv"; } - else { - dir = system::getDirectory(this->path); - filename = system::getFilename(this->path); + + if (filename == "") { + filename = "Untitled.vcv"; } osdialog_filters* filters = osdialog_filters_parse(PATCH_FILTERS); @@ -384,13 +389,15 @@ void Manager::loadDialog() { return; std::string dir; - if (this->path == "") { + if (this->path != "") { + dir = system::getDirectory(this->path); + } + + // Default to <Rack user dir>/patches + if (dir == "" || !system::isDirectory(dir)) { dir = asset::user("patches"); system::createDirectory(dir); } - else { - dir = system::getDirectory(this->path); - } osdialog_filters* filters = osdialog_filters_parse(PATCH_FILTERS); DEFER({osdialog_filters_free(filters);}); |