8 changed files with 123 additions and 132 deletions
@ -1,17 +0,0 @@
|
||||
diff --git a/src/Misc/Bank.cpp b/src/Misc/Bank.cpp
|
||||
index 1a673da..e23cecc 100644
|
||||
--- a/src/Misc/Bank.cpp
|
||||
+++ b/src/Misc/Bank.cpp
|
||||
@@ -349,6 +349,12 @@ void Bank::rescanforbanks()
|
||||
|
||||
void Bank::scanrootdir(string rootdir)
|
||||
{
|
||||
+ if(rootdir[0] == '~') {
|
||||
+ const char *home;
|
||||
+ if((home = getenv("HOME")))
|
||||
+ rootdir.replace(0, 1, home);
|
||||
+ }
|
||||
+
|
||||
DIR *dir = opendir(rootdir.c_str());
|
||||
if(dir == NULL)
|
||||
return;
|
@ -1,82 +0,0 @@
|
||||
diff --git a/src/Misc/Config.cpp b/src/Misc/Config.cpp
|
||||
index 9e2a430..34bd0ef 100644
|
||||
--- a/src/Misc/Config.cpp
|
||||
+++ b/src/Misc/Config.cpp
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "Config.h"
|
||||
#include "XMLwrapper.h"
|
||||
+#include "Util.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -235,6 +236,8 @@ void Config::readConfig(const char *filename)
|
||||
|
||||
void Config::saveConfig(const char *filename)
|
||||
{
|
||||
+ makedir(filename, 0700);
|
||||
+
|
||||
XMLwrapper *xmlcfg = new XMLwrapper();
|
||||
|
||||
xmlcfg->beginbranch("CONFIGURATION");
|
||||
@@ -295,6 +298,11 @@ void Config::saveConfig(const char *filename)
|
||||
|
||||
void Config::getConfigFileName(char *name, int namesize)
|
||||
{
|
||||
+ const char *cfg_dir;
|
||||
+
|
||||
name[0] = 0;
|
||||
- snprintf(name, namesize, "%s%s", getenv("HOME"), "/.zynaddsubfxXML.cfg");
|
||||
+ if((cfg_dir = getenv("XDG_CONFIG_HOME")))
|
||||
+ snprintf(name, namesize, "%s/zynaddsubfx/zynaddsubfxXML.cfg", cfg_dir);
|
||||
+ else
|
||||
+ snprintf(name, namesize, "%s/.config/zynaddsubfx/zynaddsubfxXML.cfg", getenv("HOME"));
|
||||
}
|
||||
diff --git a/src/Misc/Util.cpp b/src/Misc/Util.cpp
|
||||
index d75ab2f..66d6b29 100644
|
||||
--- a/src/Misc/Util.cpp
|
||||
+++ b/src/Misc/Util.cpp
|
||||
@@ -117,6 +117,30 @@ bool fileexists(const char *filename)
|
||||
return false;
|
||||
}
|
||||
|
||||
+int makedir(const char *path, int mode)
|
||||
+{
|
||||
+ char *p;
|
||||
+ int ret;
|
||||
+ struct stat st_buf;
|
||||
+
|
||||
+ for(p = (char *)(path + 1), ret = 0; *(p - 1) && ret == 0; ++p) {
|
||||
+ if(*p == '/' ) {
|
||||
+ *p = '\0';
|
||||
+
|
||||
+ if(stat(path, &st_buf) == -1)
|
||||
+ ret = mkdir(path, mode);
|
||||
+ else if(!S_ISDIR(st_buf.st_mode)) {
|
||||
+ errno = ENOTDIR;
|
||||
+ ret = -1;
|
||||
+ }
|
||||
+
|
||||
+ *p = '/';
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
void set_realtime()
|
||||
{
|
||||
sched_param sc;
|
||||
diff --git a/src/Misc/Util.h b/src/Misc/Util.h
|
||||
index 1c1545d..4d79dc7 100644
|
||||
--- a/src/Misc/Util.h
|
||||
+++ b/src/Misc/Util.h
|
||||
@@ -34,6 +34,8 @@ extern float VelF(float velocity, unsigned char scaling);
|
||||
|
||||
bool fileexists(const char *filename);
|
||||
|
||||
+int makedir(const char *path, int mode);
|
||||
+
|
||||
#define N_DETUNE_TYPES 4 //the number of detune types
|
||||
extern float getdetune(unsigned char type,
|
||||
unsigned short int coarsedetune,
|
@ -1 +0,0 @@
|
||||
af375f51093fecc9c80064295b3938b9e70b2edf ZynAddSubFX-2.4.3.tar.bz2 |
@ -0,0 +1,115 @@
|
||||
diff --git a/src/Misc/Config.cpp b/src/Misc/Config.cpp
|
||||
index 0819d12..937cf87 100644
|
||||
--- a/src/Misc/Config.cpp
|
||||
+++ b/src/Misc/Config.cpp
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "Config.h"
|
||||
#include "../src/globals.h"
|
||||
#include "XMLwrapper.h"
|
||||
+#include "Util.h"
|
||||
|
||||
#define rStdString(name, len, ...) \
|
||||
{STRINGIFY(name) "::s", rMap(length, len) rProp(parameter) DOC(__VA_ARGS__), NULL, rStringCb(name,len)}
|
||||
@@ -186,6 +187,7 @@ void Config::init()
|
||||
|
||||
char filename[MAX_STRING_SIZE];
|
||||
getConfigFileName(filename, MAX_STRING_SIZE);
|
||||
+ migrateOldConfig(filename);
|
||||
readConfig(filename);
|
||||
|
||||
if(cfg.bankRootDirList[0].empty()) {
|
||||
@@ -346,6 +348,8 @@ void Config::readConfig(const char *filename)
|
||||
|
||||
void Config::saveConfig(const char *filename) const
|
||||
{
|
||||
+ makedir(filename, 0700);
|
||||
+
|
||||
XMLwrapper *xmlcfg = new XMLwrapper();
|
||||
|
||||
xmlcfg->beginbranch("CONFIGURATION");
|
||||
@@ -401,6 +405,25 @@ void Config::saveConfig(const char *filename) const
|
||||
|
||||
void Config::getConfigFileName(char *name, int namesize) const
|
||||
{
|
||||
+ const char *cfg_dir;
|
||||
+
|
||||
name[0] = 0;
|
||||
- snprintf(name, namesize, "%s%s", getenv("HOME"), "/.zynaddsubfxXML.cfg");
|
||||
+ if((cfg_dir = getenv("XDG_CONFIG_HOME")))
|
||||
+ snprintf(name, namesize, "%s/zynaddsubfx/zynaddsubfxXML.cfg", cfg_dir);
|
||||
+ else
|
||||
+ snprintf(name, namesize, "%s/.config/zynaddsubfx/zynaddsubfxXML.cfg", getenv("HOME"));
|
||||
+}
|
||||
+
|
||||
+void Config::migrateOldConfig(const char *new_cfg_file)
|
||||
+{
|
||||
+ char old_cfg_file[MAX_STRING_SIZE];
|
||||
+
|
||||
+ if(!fileexists(new_cfg_file)) {
|
||||
+ snprintf(old_cfg_file, sizeof(old_cfg_file), "%s/.zynaddsubfxXML.cfg", getenv("HOME"));
|
||||
+
|
||||
+ if(fileexists(old_cfg_file)) {
|
||||
+ makedir(new_cfg_file, 0700);
|
||||
+ rename(old_cfg_file, new_cfg_file);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/Misc/Config.h b/src/Misc/Config.h
|
||||
index 3f453dc..0fb8054 100644
|
||||
--- a/src/Misc/Config.h
|
||||
+++ b/src/Misc/Config.h
|
||||
@@ -71,5 +71,6 @@ class Config
|
||||
void readConfig(const char *filename);
|
||||
void saveConfig(const char *filename) const;
|
||||
void getConfigFileName(char *name, int namesize) const;
|
||||
+ void migrateOldConfig(const char *new_cfg_file);
|
||||
};
|
||||
#endif
|
||||
diff --git a/src/Misc/Util.cpp b/src/Misc/Util.cpp
|
||||
index 626920b..7782810 100644
|
||||
--- a/src/Misc/Util.cpp
|
||||
+++ b/src/Misc/Util.cpp
|
||||
@@ -114,6 +114,30 @@ bool fileexists(const char *filename)
|
||||
return false;
|
||||
}
|
||||
|
||||
+int makedir(const char *path, int mode)
|
||||
+{
|
||||
+ char *p;
|
||||
+ int ret;
|
||||
+ struct stat st_buf;
|
||||
+
|
||||
+ for(p = (char *)(path + 1), ret = 0; *(p - 1) && ret == 0; ++p) {
|
||||
+ if(*p == '/' ) {
|
||||
+ *p = '\0';
|
||||
+
|
||||
+ if(stat(path, &st_buf) == -1)
|
||||
+ ret = mkdir(path, mode);
|
||||
+ else if(!S_ISDIR(st_buf.st_mode)) {
|
||||
+ errno = ENOTDIR;
|
||||
+ ret = -1;
|
||||
+ }
|
||||
+
|
||||
+ *p = '/';
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
void set_realtime()
|
||||
{
|
||||
#ifdef HAVE_SCHEDULER
|
||||
diff --git a/src/Misc/Util.h b/src/Misc/Util.h
|
||||
index 9bd424a..2629801 100644
|
||||
--- a/src/Misc/Util.h
|
||||
+++ b/src/Misc/Util.h
|
||||
@@ -30,6 +30,8 @@ extern bool isPlugin;
|
||||
|
||||
bool fileexists(const char *filename);
|
||||
|
||||
+int makedir(const char *path, int mode);
|
||||
+
|
||||
#define N_DETUNE_TYPES 4 //the number of detune types
|
||||
extern float getdetune(unsigned char type,
|
||||
unsigned short int coarsedetune,
|
@ -0,0 +1 @@
|
||||
48ace6b5996103b6889db96a5201eb5c2c1b62bc zynaddsubfx-2.5.4.tar.bz2 |
@ -1,11 +0,0 @@
|
||||
[Desktop Entry] |
||||
Name=ZynAddSubFX |
||||
Comment=Software Synthesizer |
||||
Exec=zynaddsubfx |
||||
Icon=/usr/share/pixmaps/zynaddsubfx.png |
||||
Terminal=false |
||||
Type=Application |
||||
Categories=AudioVideo;Audio; |
||||
StartupNotify=false |
||||
X-KDE-StartupNotify=false |
||||
X-DCOP-ServiceType=Multi |
Before Width: | Height: | Size: 5.3 KiB |
Loading…
Reference in new issue