diff plugin/DSSIPluginFactory.cpp @ 1480:5ac102155409 plugin-path-config

Environment variable lookup fixes, & use this implementation throughout
author Chris Cannam
date Fri, 08 Jun 2018 11:27:40 +0100
parents 91bb68146dfc
children 70e172e6cc59
line wrap: on
line diff
--- a/plugin/DSSIPluginFactory.cpp	Thu Jun 07 16:49:09 2018 +0100
+++ b/plugin/DSSIPluginFactory.cpp	Fri Jun 08 11:27:40 2018 +0100
@@ -39,6 +39,7 @@
 #include "lrdf.h"
 #endif // HAVE_LRDF
 
+using std::string;
 
 DSSIPluginFactory::DSSIPluginFactory() :
     LADSPAPluginFactory()
@@ -206,38 +207,38 @@
 DSSIPluginFactory::getPluginPath()
 {
     std::vector<QString> pathList;
-    std::string path;
+    string path;
 
-    char *cpath = getenv("DSSI_PATH");
-    if (cpath) path = cpath;
+    (void)getEnvUtf8("DSSI_PATH", path);
 
     if (path == "") {
 
         path = DEFAULT_DSSI_PATH;
 
-        char *home = getenv("HOME");
-        if (home) {
-            std::string::size_type f;
-            while ((f = path.find("$HOME")) != std::string::npos &&
+        string home;
+        if (getEnvUtf8("HOME", home)) {
+            string::size_type f;
+            while ((f = path.find("$HOME")) != string::npos &&
                    f < path.length()) {
                 path.replace(f, 5, home);
             }
         }
 
 #ifdef _WIN32
-        const char *pfiles = getenv("ProgramFiles");
-        if (!pfiles) pfiles = "C:\\Program Files";
-        {
-        std::string::size_type f;
-        while ((f = path.find("%ProgramFiles%")) != std::string::npos &&
+        string pfiles;
+        if (!getEnvUtf8("ProgramFiles", pfiles)) {
+            pfiles = "C:\\Program Files";
+        }
+
+        string::size_type f;
+        while ((f = path.find("%ProgramFiles%")) != string::npos &&
                f < path.length()) {
             path.replace(f, 14, pfiles);
         }
-        }
 #endif
     }
 
-    std::string::size_type index = 0, newindex = 0;
+    string::size_type index = 0, newindex = 0;
 
     while ((newindex = path.find(PATH_SEPARATOR, index)) < path.size()) {
         pathList.push_back(path.substr(index, newindex - index).c_str());
@@ -347,7 +348,7 @@
         }
 
         if (category == "") {
-            std::string name = rtd->name;
+            string name = rtd->name;
             if (name.length() > 4 &&
                 name.substr(name.length() - 4) == " VST") {
                 if (descriptor->run_synth || descriptor->run_multiple_synths) {