comparison 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
comparison
equal deleted inserted replaced
1479:ba27edcd6102 1480:5ac102155409
37 37
38 #ifdef HAVE_LRDF 38 #ifdef HAVE_LRDF
39 #include "lrdf.h" 39 #include "lrdf.h"
40 #endif // HAVE_LRDF 40 #endif // HAVE_LRDF
41 41
42 using std::string;
42 43
43 DSSIPluginFactory::DSSIPluginFactory() : 44 DSSIPluginFactory::DSSIPluginFactory() :
44 LADSPAPluginFactory() 45 LADSPAPluginFactory()
45 { 46 {
46 m_hostDescriptor.DSSI_API_Version = 2; 47 m_hostDescriptor.DSSI_API_Version = 2;
204 205
205 std::vector<QString> 206 std::vector<QString>
206 DSSIPluginFactory::getPluginPath() 207 DSSIPluginFactory::getPluginPath()
207 { 208 {
208 std::vector<QString> pathList; 209 std::vector<QString> pathList;
209 std::string path; 210 string path;
210 211
211 char *cpath = getenv("DSSI_PATH"); 212 (void)getEnvUtf8("DSSI_PATH", path);
212 if (cpath) path = cpath;
213 213
214 if (path == "") { 214 if (path == "") {
215 215
216 path = DEFAULT_DSSI_PATH; 216 path = DEFAULT_DSSI_PATH;
217 217
218 char *home = getenv("HOME"); 218 string home;
219 if (home) { 219 if (getEnvUtf8("HOME", home)) {
220 std::string::size_type f; 220 string::size_type f;
221 while ((f = path.find("$HOME")) != std::string::npos && 221 while ((f = path.find("$HOME")) != string::npos &&
222 f < path.length()) { 222 f < path.length()) {
223 path.replace(f, 5, home); 223 path.replace(f, 5, home);
224 } 224 }
225 } 225 }
226 226
227 #ifdef _WIN32 227 #ifdef _WIN32
228 const char *pfiles = getenv("ProgramFiles"); 228 string pfiles;
229 if (!pfiles) pfiles = "C:\\Program Files"; 229 if (!getEnvUtf8("ProgramFiles", pfiles)) {
230 { 230 pfiles = "C:\\Program Files";
231 std::string::size_type f; 231 }
232 while ((f = path.find("%ProgramFiles%")) != std::string::npos && 232
233 string::size_type f;
234 while ((f = path.find("%ProgramFiles%")) != string::npos &&
233 f < path.length()) { 235 f < path.length()) {
234 path.replace(f, 14, pfiles); 236 path.replace(f, 14, pfiles);
235 } 237 }
236 }
237 #endif 238 #endif
238 } 239 }
239 240
240 std::string::size_type index = 0, newindex = 0; 241 string::size_type index = 0, newindex = 0;
241 242
242 while ((newindex = path.find(PATH_SEPARATOR, index)) < path.size()) { 243 while ((newindex = path.find(PATH_SEPARATOR, index)) < path.size()) {
243 pathList.push_back(path.substr(index, newindex - index).c_str()); 244 pathList.push_back(path.substr(index, newindex - index).c_str());
244 index = newindex + 1; 245 index = newindex + 1;
245 } 246 }
345 m_taxonomy[identifier] = m_lrdfTaxonomy[ladspaDescriptor->UniqueID]; 346 m_taxonomy[identifier] = m_lrdfTaxonomy[ladspaDescriptor->UniqueID];
346 category = m_taxonomy[identifier]; 347 category = m_taxonomy[identifier];
347 } 348 }
348 349
349 if (category == "") { 350 if (category == "") {
350 std::string name = rtd->name; 351 string name = rtd->name;
351 if (name.length() > 4 && 352 if (name.length() > 4 &&
352 name.substr(name.length() - 4) == " VST") { 353 name.substr(name.length() - 4) == " VST") {
353 if (descriptor->run_synth || descriptor->run_multiple_synths) { 354 if (descriptor->run_synth || descriptor->run_multiple_synths) {
354 category = "VST instruments"; 355 category = "VST instruments";
355 } else { 356 } else {