preparations for VST blacklist (paths)

This commit is contained in:
Robin Gareus 2014-02-24 21:11:22 +01:00
parent 6ee44cf377
commit adcb0faf6b
5 changed files with 130 additions and 14 deletions

View file

@ -33,6 +33,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.

View file

@ -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

View file

@ -83,6 +83,53 @@ user_config_directory ()
return p;
}
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 ()
{

View file

@ -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

View file

@ -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)