Transfer 'vst_search_path()' into 'libs/ardour/search_paths.cc'
authorJohn Emmas <johne53@tiscali.co.uk>
Mon, 10 Mar 2014 15:37:23 +0000 (15:37 +0000)
committerJohn Emmas <johne53@tiscali.co.uk>
Mon, 10 Mar 2014 16:24:09 +0000 (16:24 +0000)
libs/ardour/ardour/search_paths.h
libs/ardour/ardour/vst_search_path.h [deleted file]
libs/ardour/plugin_manager.cc
libs/ardour/search_paths.cc
libs/ardour/vst_search_path.cc [deleted file]

index 6de5db3ef04b8394fc2326478a0f23f012c72d66..85ed2cbfd77f19e1f5dc39f14a0a6113e8cda90b 100644 (file)
@@ -25,6 +25,8 @@
 
 namespace ARDOUR {
 
+       LIBARDOUR_API const char *vst_search_path ();
+
        /**
         * return a SearchPath containing directories in which to look for
         * backend plugins.
diff --git a/libs/ardour/ardour/vst_search_path.h b/libs/ardour/ardour/vst_search_path.h
deleted file mode 100644 (file)
index b220cd0..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef __libardour_vst_search_path_h__
-#define __libardour_vst_search_path_h__
-
-namespace ARDOUR {
-       const char *vst_search_path ();
-};
-
-#endif /* __libardour_vst_path_h__ */
index 456cf42c9a52d8147415e6fc0394d571efeeb6fb..2db24ed269c6c4dc5aa690aba8dc76fbc5b3c8b5 100644 (file)
@@ -63,7 +63,6 @@
 #include "ardour/rc_configuration.h"
 
 #include "ardour/search_paths.h"
-#include "ardour/vst_search_path.h"
 
 #ifdef LV2_SUPPORT
 #include "ardour/lv2_plugin.h"
index 825a6c52b8998a6c2f8aa6e75fc4ae5af9cd9ad0..09227f6347a84e90e70c6714177bd4a9d5da4d11 100644 (file)
@@ -18,7 +18,9 @@
 
 */
 
-#include <glibmm/miscutils.h>
+#include <glib.h>
+#include <glibmm.h>
+#include <string.h>
 
 #include "pbd/pathexpand.h"
 
 #include "ardour/directory_names.h"
 #include "ardour/filesystem_paths.h"
 
+#ifdef PLATFORM_WINDOWS
+#include <windows.h>
+#include <shlobj.h> // 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";
@@ -139,4 +147,114 @@ panner_search_path ()
        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(), 0);
+
+               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(), 0);
+
+                       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", 0))
+                       {
+                               if (Glib::file_test (pVSTx86, Glib::FILE_TEST_EXISTS))
+                                       if (Glib::file_test (pVSTx86, Glib::FILE_TEST_IS_DIR))
+                                               p = g_build_filename (pVSTx86, 0);
+
+                               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", 0)) {
+                                       if (Glib::file_test (pVST, Glib::FILE_TEST_EXISTS))
+                                               if (Glib::file_test (pVST, Glib::FILE_TEST_IS_DIR))
+                                                       p = g_build_filename (pVST, 0);
+
+                                       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", 0);
+               } else {
+                       user_home = g_build_filename(g_get_home_dir(), "My Documents", 0);
+                       if (user_home)
+                               p = g_build_filename (user_home, "Plugins", "VST", 0);
+               }
+       } 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", 0), 0);
+               } else {
+                       user_home = g_build_filename(g_get_home_dir(), "My Documents", 0);
+
+                       if (user_home) {
+                               p = g_build_path (";", p, g_build_filename (user_home, "Plugins", "VST", 0), 0);
+                       }
+               }
+       }
+
+       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
diff --git a/libs/ardour/vst_search_path.cc b/libs/ardour/vst_search_path.cc
deleted file mode 100644 (file)
index c727b9b..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
-    Copyright (C) 2008 John Emmas
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#include <glib.h>
-#include <glibmm.h>
-#include <string.h>
-
-#include "ardour/vst_search_path.h"
-
-#ifdef PLATFORM_WINDOWS
-
-#include <windows.h>
-#include <shlobj.h> // CSIDL_*
-#include "pbd/windows_special_dirs.h"
-
-namespace ARDOUR {
-
-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(), 0);
-
-               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(), 0);
-
-                       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", 0))
-                       {
-                               if (Glib::file_test (pVSTx86, Glib::FILE_TEST_EXISTS))
-                                       if (Glib::file_test (pVSTx86, Glib::FILE_TEST_IS_DIR))
-                                               p = g_build_filename (pVSTx86, 0);
-
-                               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", 0)) {
-                                       if (Glib::file_test (pVST, Glib::FILE_TEST_EXISTS))
-                                               if (Glib::file_test (pVST, Glib::FILE_TEST_IS_DIR))
-                                                       p = g_build_filename (pVST, 0);
-
-                                       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", 0);
-               } else {
-                       user_home = g_build_filename(g_get_home_dir(), "My Documents", 0);
-                       if (user_home)
-                               p = g_build_filename (user_home, "Plugins", "VST", 0);
-               }
-       } 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", 0), 0);
-               } else {
-                       user_home = g_build_filename(g_get_home_dir(), "My Documents", 0);
-
-                       if (user_home) {
-                               p = g_build_path (";", p, g_build_filename (user_home, "Plugins", "VST", 0), 0);
-                       }
-               }
-       }
-
-       return p;
-}
-
-}  // namespace ARDOUR
-
-#else 
-
-/* Unix-like. Probably require some OS X specific breakdown if we ever add VST
- * support on that platform.
- */
-
-namespace ARDOUR {
-
-const char *
-vst_search_path ()
-{
-       return "/usr/local/lib/vst:/usr/lib/vst";
-}
-
-} // namespace ARDOUR
-
-#endif /* PLATFORM_WINDOWS */
-