| @@ -148,6 +148,7 @@ std::vector<std::string> systemListEntries(std::string path); | |||||
| bool systemIsFile(std::string path); | bool systemIsFile(std::string path); | ||||
| bool systemIsDirectory(std::string path); | bool systemIsDirectory(std::string path); | ||||
| void systemCopy(std::string srcPath, std::string destPath); | void systemCopy(std::string srcPath, std::string destPath); | ||||
| void systemCreateDirectory(std::string path); | |||||
| /** Opens a URL, also happens to work with PDFs and folders. | /** Opens a URL, also happens to work with PDFs and folders. | ||||
| Shell injection is possible, so make sure the URL is trusted or hard coded. | Shell injection is possible, so make sure the URL is trusted or hard coded. | ||||
| @@ -69,7 +69,14 @@ void RackWidget::reset() { | |||||
| } | } | ||||
| void RackWidget::openDialog() { | void RackWidget::openDialog() { | ||||
| std::string dir = lastPath.empty() ? assetLocal("") : stringDirectory(lastPath); | |||||
| std::string dir; | |||||
| if (lastPath.empty()) { | |||||
| dir = assetLocal("patches"); | |||||
| systemCreateDirectory(dir); | |||||
| } | |||||
| else { | |||||
| dir = stringDirectory(lastPath); | |||||
| } | |||||
| char *path = osdialog_file(OSDIALOG_OPEN, dir.c_str(), NULL, NULL); | char *path = osdialog_file(OSDIALOG_OPEN, dir.c_str(), NULL, NULL); | ||||
| if (path) { | if (path) { | ||||
| loadPatch(path); | loadPatch(path); | ||||
| @@ -88,7 +95,14 @@ void RackWidget::saveDialog() { | |||||
| } | } | ||||
| void RackWidget::saveAsDialog() { | void RackWidget::saveAsDialog() { | ||||
| std::string dir = lastPath.empty() ? assetLocal("") : stringDirectory(lastPath); | |||||
| std::string dir; | |||||
| if (lastPath.empty()) { | |||||
| dir = assetLocal("patches"); | |||||
| systemCreateDirectory(dir); | |||||
| } | |||||
| else { | |||||
| dir = stringDirectory(lastPath); | |||||
| } | |||||
| char *path = osdialog_file(OSDIALOG_SAVE, dir.c_str(), "Untitled.vcv", NULL); | char *path = osdialog_file(OSDIALOG_SAVE, dir.c_str(), "Untitled.vcv", NULL); | ||||
| if (path) { | if (path) { | ||||
| @@ -64,7 +64,6 @@ std::string assetLocal(std::string filename) { | |||||
| assert(pw); | assert(pw); | ||||
| dir = pw->pw_dir; | dir = pw->pw_dir; | ||||
| dir += "/Documents/Rack"; | dir += "/Documents/Rack"; | ||||
| mkdir(dir.c_str(), 0755); | |||||
| #endif | #endif | ||||
| #if ARCH_WIN | #if ARCH_WIN | ||||
| // Get "My Documents" folder | // Get "My Documents" folder | ||||
| @@ -73,7 +72,6 @@ std::string assetLocal(std::string filename) { | |||||
| assert(result == S_OK); | assert(result == S_OK); | ||||
| dir = buf; | dir = buf; | ||||
| dir += "/Rack"; | dir += "/Rack"; | ||||
| CreateDirectory(dir.c_str(), NULL); | |||||
| #endif | #endif | ||||
| #if ARCH_LIN | #if ARCH_LIN | ||||
| const char *home = getenv("HOME"); | const char *home = getenv("HOME"); | ||||
| @@ -84,8 +82,8 @@ std::string assetLocal(std::string filename) { | |||||
| } | } | ||||
| dir = home; | dir = home; | ||||
| dir += "/.Rack"; | dir += "/.Rack"; | ||||
| mkdir(dir.c_str(), 0755); | |||||
| #endif | #endif | ||||
| systemCreateDirectory(dir); | |||||
| #else // RELEASE | #else // RELEASE | ||||
| dir = "."; | dir = "."; | ||||
| #endif // RELEASE | #endif // RELEASE | ||||
| @@ -72,6 +72,14 @@ void systemCopy(std::string srcPath, std::string destPath) { | |||||
| } | } | ||||
| } | } | ||||
| void systemCreateDirectory(std::string path) { | |||||
| #if ARCH_WIN | |||||
| CreateDirectory(path.c_str(), NULL); | |||||
| #else | |||||
| mkdir(path.c_str(), 0755); | |||||
| #endif | |||||
| } | |||||
| void systemOpenBrowser(std::string url) { | void systemOpenBrowser(std::string url) { | ||||
| #if ARCH_LIN | #if ARCH_LIN | ||||
| std::string command = "xdg-open " + url; | std::string command = "xdg-open " + url; | ||||