summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/ardour/ardour/filesystem_paths.h8
-rw-r--r--libs/ardour/ardour/vst_info_file.h2
-rw-r--r--libs/ardour/filesystem_paths.cc47
-rw-r--r--libs/ardour/plugin_manager.cc49
-rw-r--r--libs/ardour/vst_info_file.cc38
5 files changed, 130 insertions, 14 deletions
diff --git a/libs/ardour/ardour/filesystem_paths.h b/libs/ardour/ardour/filesystem_paths.h
index 0bf25c5153..a398a917f2 100644
--- a/libs/ardour/ardour/filesystem_paths.h
+++ b/libs/ardour/ardour/filesystem_paths.h
@@ -34,6 +34,14 @@ namespace ARDOUR {
LIBARDOUR_API std::string user_config_directory ();
/**
+ * @return the path to the directory used to store user specific
+ * caches (e.g. plugin indices, blacklist/whitelist)
+ * it defaults to XDG_CACHE_HOME
+ */
+ LIBARDOUR_API std::string user_cache_directory ();
+
+
+ /**
* @return the path to the directory that contains the system wide ardour
* modules.
*/
diff --git a/libs/ardour/ardour/vst_info_file.h b/libs/ardour/ardour/vst_info_file.h
index 21e9d19c65..5f191faf25 100644
--- a/libs/ardour/ardour/vst_info_file.h
+++ b/libs/ardour/ardour/vst_info_file.h
@@ -25,6 +25,8 @@
#include "ardour/vst_types.h"
#include <vector>
+LIBARDOUR_API extern std::string get_personal_vst_info_cache_dir ();
+LIBARDOUR_API extern std::string get_personal_vst_blacklist_dir ();
LIBARDOUR_API extern void vstfx_free_info_list (std::vector<VSTInfo *> *infos);
#ifdef LXVST_SUPPORT
diff --git a/libs/ardour/filesystem_paths.cc b/libs/ardour/filesystem_paths.cc
index 54f7508b65..5228e85527 100644
--- a/libs/ardour/filesystem_paths.cc
+++ b/libs/ardour/filesystem_paths.cc
@@ -84,6 +84,53 @@ user_config_directory ()
}
std::string
+user_cache_directory ()
+{
+ static std::string p;
+
+ if (!p.empty()) return p;
+
+#ifdef __APPLE__
+ p = Glib::build_filename (Glib::get_home_dir(), "Library/Caches");
+#else
+ const char* c = 0;
+
+ /* adopt freedesktop standards, and put .ardour3 into $XDG_CONFIG_HOME or ~/.config
+ */
+
+ if ((c = getenv ("XDG_CACHE_HOME")) != 0) {
+ p = c;
+ } else {
+ const string home_dir = Glib::get_home_dir();
+
+ if (home_dir.empty ()) {
+ error << "Unable to determine home directory" << endmsg;
+ exit (1);
+ }
+
+ p = home_dir;
+ p = Glib::build_filename (p, ".cache");
+ }
+#endif
+
+ p = Glib::build_filename (p, user_config_dir_name);
+
+ if (!Glib::file_test (p, Glib::FILE_TEST_EXISTS)) {
+ if (g_mkdir_with_parents (p.c_str(), 0755)) {
+ error << string_compose (_("Cannot create cache directory %1 - cannot run"),
+ p) << endmsg;
+ exit (1);
+ }
+ } else if (!Glib::file_test (p, Glib::FILE_TEST_IS_DIR)) {
+ error << string_compose (_("Cache directory %1 already exists and is not a directory/folder - cannot run"),
+ p) << endmsg;
+ exit (1);
+ }
+
+ return p;
+}
+
+std::string
ardour_dll_directory ()
{
#ifdef PLATFORM_WINDOWS
diff --git a/libs/ardour/plugin_manager.cc b/libs/ardour/plugin_manager.cc
index 6a20191cf1..cfdfc6af7f 100644
--- a/libs/ardour/plugin_manager.cc
+++ b/libs/ardour/plugin_manager.cc
@@ -246,9 +246,7 @@ PluginManager::clear_vst_cache ()
#if (defined WINDOWS_VST_SUPPORT || defined LXVST_SUPPORT)
{
- string personal;
- personal = Glib::build_filename (Glib::get_home_dir (), ".fst");
-
+ string personal = get_personal_vst_info_cache_dir();
PathScanner scanner;
vector<string *> *fsi_files;
fsi_files = scanner (personal, "\\.fsi$", true, true, -1, false);
@@ -265,7 +263,50 @@ PluginManager::clear_vst_cache ()
void
PluginManager::clear_vst_blacklist ()
{
- // TODO -> libs/ardour/vst_info_file.cc
+#ifdef WINDOWS_VST_SUPPORT
+ {
+ PathScanner scanner;
+ vector<string *> *fsi_files;
+
+ fsi_files = scanner (windows_vst_path, "\\.fsb$", true, true, -1, false);
+ if (fsi_files) {
+ for (vector<string *>::iterator i = fsi_files->begin(); i != fsi_files->end (); ++i) {
+ ::g_unlink((*i)->c_str());
+ }
+ }
+ vector_delete(fsi_files);
+ }
+#endif
+
+#ifdef LXVST_SUPPORT
+ {
+ PathScanner scanner;
+ vector<string *> *fsi_files;
+ fsi_files = scanner (lxvst_path, "\\.fsb$", true, true, -1, false);
+ if (fsi_files) {
+ for (vector<string *>::iterator i = fsi_files->begin(); i != fsi_files->end (); ++i) {
+ ::g_unlink((*i)->c_str());
+ }
+ }
+ vector_delete(fsi_files);
+ }
+#endif
+
+#if (defined WINDOWS_VST_SUPPORT || defined LXVST_SUPPORT)
+ {
+ string personal = get_personal_vst_blacklist_dir();
+
+ PathScanner scanner;
+ vector<string *> *fsi_files;
+ fsi_files = scanner (personal, "\\.fsb$", true, true, -1, false);
+ if (fsi_files) {
+ for (vector<string *>::iterator i = fsi_files->begin(); i != fsi_files->end (); ++i) {
+ ::g_unlink((*i)->c_str());
+ }
+ }
+ vector_delete(fsi_files);
+ }
+#endif
}
void
diff --git a/libs/ardour/vst_info_file.cc b/libs/ardour/vst_info_file.cc
index 67117b2a6a..a0dffd0165 100644
--- a/libs/ardour/vst_info_file.cc
+++ b/libs/ardour/vst_info_file.cc
@@ -42,6 +42,7 @@
#include "pbd/error.h"
+#include "ardour/filesystem_paths.h"
#include "ardour/linux_vst_support.h"
#include "ardour/vst_info_file.h"
@@ -254,16 +255,7 @@ vstfx_infofile_path (const char* dllpath, int personal)
{
string dir;
if (personal) {
- // TODO use XDG_CACHE_HOME
- dir = Glib::build_filename (Glib::get_home_dir (), ".fst");
-
- /* If the directory doesn't exist, try to create it */
- if (!Glib::file_test (dir, Glib::FILE_TEST_IS_DIR)) {
- if (g_mkdir (dir.c_str (), 0700)) {
- return 0;
- }
- }
-
+ dir = get_personal_vst_info_cache_dir();
} else {
dir = Glib::path_get_dirname (std::string(dllpath));
}
@@ -685,6 +677,32 @@ vstfx_free_info_list (vector<VSTInfo *> *infos)
delete infos;
}
+string
+get_personal_vst_blacklist_dir() {
+ string dir = Glib::build_filename (ARDOUR::user_cache_directory(), "fst_blacklist");
+ /* if the directory doesn't exist, try to create it */
+ if (!Glib::file_test (dir, Glib::FILE_TEST_IS_DIR)) {
+ if (g_mkdir (dir.c_str (), 0700)) {
+ PBD::error << "Cannt create VST cache folder '" << dir << "'" << endmsg;
+ //exit(1);
+ }
+ }
+ return dir;
+}
+
+string
+get_personal_vst_info_cache_dir() {
+ string dir = Glib::build_filename (ARDOUR::user_cache_directory(), "fst_info");
+ /* if the directory doesn't exist, try to create it */
+ if (!Glib::file_test (dir, Glib::FILE_TEST_IS_DIR)) {
+ if (g_mkdir (dir.c_str (), 0700)) {
+ PBD::error << "Cannt create VST info folder '" << dir << "'" << endmsg;
+ //exit(1);
+ }
+ }
+ return dir;
+}
+
#ifdef LXVST_SUPPORT
vector<VSTInfo *> *
vstfx_get_info_lx (char* dllpath)