Browse Source

Use patches/ directory as default patch location

tags/v0.6.1
Andrew Belt 7 years ago
parent
commit
da45a33ed3
4 changed files with 26 additions and 5 deletions
  1. +1
    -0
      include/util/common.hpp
  2. +16
    -2
      src/app/RackWidget.cpp
  3. +1
    -3
      src/asset.cpp
  4. +8
    -0
      src/util/system.cpp

+ 1
- 0
include/util/common.hpp View File

@@ -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.


+ 16
- 2
src/app/RackWidget.cpp View File

@@ -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) {


+ 1
- 3
src/asset.cpp View File

@@ -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


+ 8
- 0
src/util/system.cpp View File

@@ -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;


Loading…
Cancel
Save