X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=libs%2Fardour%2Fsearch_paths.cc;h=6b54ff566cdf472418864f4da8074f2f8e6c709c;hb=87f1c66ba1d33903662d44dabed032272827e7fd;hp=ca489063d3478c1a2aadbc861b38bb93cea7f9a8;hpb=aa7c2ab5c23700b1ddc8bceec494dfe5393f0314;p=ardour.git diff --git a/libs/ardour/search_paths.cc b/libs/ardour/search_paths.cc index ca489063d3..6b54ff566c 100644 --- a/libs/ardour/search_paths.cc +++ b/libs/ardour/search_paths.cc @@ -18,7 +18,9 @@ */ -#include +#include +#include +#include #include "pbd/pathexpand.h" @@ -26,12 +28,19 @@ #include "ardour/directory_names.h" #include "ardour/filesystem_paths.h" +#ifdef PLATFORM_WINDOWS +#include +#include // CSIDL_* +#include "pbd/windows_special_dirs.h" +#endif + namespace { const char * const backend_env_variable_name = "ARDOUR_BACKEND_PATH"; const char * const surfaces_env_variable_name = "ARDOUR_SURFACES_PATH"; const char * const export_env_variable_name = "ARDOUR_EXPORT_FORMATS_PATH"; const char * const ladspa_env_variable_name = "LADSPA_PATH"; const char * const midi_patch_env_variable_name = "ARDOUR_MIDI_PATCH_PATH"; + const char * const panner_env_variable_name = "ARDOUR_PANNER_PATH"; } // anonymous using namespace PBD; @@ -126,4 +135,142 @@ midi_patch_search_path () return spath; } +Searchpath +panner_search_path () +{ + Searchpath spath(user_config_directory ()); + + spath += ardour_dll_directory (); + spath.add_subdirectory_to_paths(panner_dir_name); + spath += Searchpath(Glib::getenv(panner_env_variable_name)); + + return spath; +} + +Searchpath +template_search_path () +{ + Searchpath spath (ardour_data_search_path()); + spath.add_subdirectory_to_paths(templates_dir_name); + return spath; +} + +Searchpath +route_template_search_path () +{ + Searchpath spath (ardour_data_search_path()); + spath.add_subdirectory_to_paths(route_templates_dir_name); + return spath; +} + +#ifdef PLATFORM_WINDOWS + +const char* +vst_search_path () +{ + DWORD dwType = REG_SZ; + HKEY hKey; + DWORD dwSize = PATH_MAX; + char* p = 0; + char* user_home = 0; + char tmp[PATH_MAX+1]; + + if (ERROR_SUCCESS == RegOpenKeyExA (HKEY_CURRENT_USER, "Software\\VST", 0, KEY_READ, &hKey)) { + // Look for the user's VST Registry entry + if (ERROR_SUCCESS == RegQueryValueExA (hKey, "VSTPluginsPath", 0, &dwType, (LPBYTE)tmp, &dwSize)) + p = g_build_filename (Glib::locale_to_utf8(tmp).c_str(), NULL); + + RegCloseKey (hKey); + } + + if (p == 0) { + if (ERROR_SUCCESS == RegOpenKeyExA (HKEY_LOCAL_MACHINE, "Software\\VST", 0, KEY_READ, &hKey)) + { + // Look for a global VST Registry entry + if (ERROR_SUCCESS == RegQueryValueExA (hKey, "VSTPluginsPath", 0, &dwType, (LPBYTE)tmp, &dwSize)) + p = g_build_filename (Glib::locale_to_utf8(tmp).c_str(), NULL); + + RegCloseKey (hKey); + } + } + + if (p == 0) { + char *pVSTx86 = 0; + char *pProgFilesX86 = PBD::get_win_special_folder (CSIDL_PROGRAM_FILESX86); + + if (pProgFilesX86) { + // Look for a VST folder under C:\Program Files (x86) + if ((pVSTx86 = g_build_filename (pProgFilesX86, "Steinberg", "VSTPlugins", NULL))) + { + if (Glib::file_test (pVSTx86, Glib::FILE_TEST_EXISTS)) + if (Glib::file_test (pVSTx86, Glib::FILE_TEST_IS_DIR)) + p = g_build_filename (pVSTx86, NULL); + + g_free (pVSTx86); + } + + g_free (pProgFilesX86); + } + + if (p == 0) { + // Look for a VST folder under C:\Program Files + char *pVST = 0; + char *pProgFiles = PBD::get_win_special_folder (CSIDL_PROGRAM_FILES); + + if (pProgFiles) { + if ((pVST = g_build_filename (pProgFiles, "Steinberg", "VSTPlugins", NULL))) { + if (Glib::file_test (pVST, Glib::FILE_TEST_EXISTS)) + if (Glib::file_test (pVST, Glib::FILE_TEST_IS_DIR)) + p = g_build_filename (pVST, NULL); + + g_free (pVST); + } + + g_free (pProgFiles); + } + } + } + + if (p == 0) { + // If all else failed, assume the plugins are under "My Documents" + user_home = (char*) g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS); + if (user_home) { + p = g_build_filename (user_home, "Plugins", "VST", NULL); + } else { + user_home = g_build_filename(g_get_home_dir(), "My Documents", NULL); + if (user_home) + p = g_build_filename (user_home, "Plugins", "VST", NULL); + } + } else { + // Concatenate the registry path with the user's personal path + user_home = (char*) g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS); + + if (user_home) { + p = g_build_path (";", p, g_build_filename(user_home, "Plugins", "VST", NULL), NULL); + } else { + user_home = g_build_filename(g_get_home_dir(), "My Documents", NULL); + + if (user_home) { + p = g_build_path (";", p, g_build_filename (user_home, "Plugins", "VST", NULL), NULL); + } + } + } + + return p; +} + +#else + +/* Unix-like. Probably require some OS X specific breakdown if we ever add VST + * support on that platform. + */ + +const char * +vst_search_path () +{ + return "/usr/local/lib/vst:/usr/lib/vst"; +} + +#endif // PLATFORM_WINDOWS + } // namespace ARDOUR