13
0

Modified nesting to ensure that 'vst_search_path()' shouldn't return NULL if the first test fails

This commit is contained in:
John Emmas 2014-03-09 11:48:09 +00:00
parent 611dc796de
commit fc94f71d5a

View File

@ -42,19 +42,22 @@ vst_search_path ()
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)) {
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)) {
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;
@ -62,7 +65,8 @@ vst_search_path ()
if (pProgFilesX86) {
// Look for a VST folder under C:\Program Files (x86)
if (pVSTx86 = g_build_filename (pProgFilesX86, "Steinberg", "VSTPlugins", 0)) {
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);
@ -72,7 +76,6 @@ vst_search_path ()
g_free (pProgFilesX86);
}
}
if (p == 0) {
// Look for a VST folder under C:\Program Files
@ -84,6 +87,7 @@ vst_search_path ()
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);
}
@ -104,19 +108,18 @@ vst_search_path ()
}
} 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;
}