export ARDOUR_PATH=.:gtk2_ardour/icons:gtk2_ardour/pixmaps:gtk2_ardour
export GTK_PATH=libs/clearlooks
+export ARDOUR_SURFACES_PATH=libs/surfaces/frontier:libs/surfaces/generic_midi:libs/surfaces/mackie:libs/surfaces/tranzport
export LD_LIBRARY_PATH=libs/surfaces/control_protocol:libs/ardour:libs/midi++2:libs/pbd:libs/soundtouch:libs/gtkmm2ext:libs/sigc++2:libs/glibmm2:libs/gtkmm2/atk:libs/gtkmm2/pango:libs/gtkmm2/gdk:libs/gtkmm2/gtk:libs/libgnomecanvasmm:libs/libsndfile:libs/appleutility:$LD_LIBRARY_PATH
automation_event.cc
configuration.cc
control_protocol_manager.cc
+control_protocol_search_path.cc
crossfade.cc
curve.cc
cycle_timer.cc
std::string get_user_ardour_path ();
std::string get_system_data_path ();
- std::string get_system_module_path ();
std::string find_config_file (std::string name);
std::string find_data_file (std::string name, std::string subdir = "" );
static ControlProtocolManager& instance() { return *_instance; }
void set_session (Session&);
- void discover_control_protocols (std::string search_path);
+ void discover_control_protocols ();
void foreach_known_protocol (sigc::slot<void,const ControlProtocolInfo*>);
void load_mandatory_protocols ();
--- /dev/null
+/*
+ Copyright (C) 2007 Tim Mayberry
+
+ 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.
+
+*/
+
+#ifndef ARDOUR_CONTROL_PROTOCOL_SEARCH_PATH_INCLUDED
+#define ARDOUR_CONTROL_PROTOCOL_SEARCH_PATH_INCLUDED
+
+#include <pbd/search_path.h>
+
+namespace ARDOUR {
+
+ using PBD::SearchPath;
+
+ /**
+ * return a SearchPath containing directories in which to look for
+ * control surface plugins.
+ *
+ * If ARDOUR_SURFACES_PATH is defined then the SearchPath returned
+ * will contain only those directories specified in it, otherwise it will
+ * contain the user and system directories which may contain control
+ * surface plugins.
+ */
+ SearchPath control_protocol_search_path ();
+
+} // namespace ARDOUR
+
+#endif
*/
sys::path user_config_directory ();
+ /**
+ * @return the path to the directory that contains the system wide ardour
+ * modules.
+ */
+ sys::path system_module_directory ();
+
} // namespace ARDOUR
#endif
std::string automation_dir () const;
- static string suffixed_search_path (std::string suffix, bool data);
- static string control_protocol_path ();
-
static string change_audio_path_by_name (string oldpath, string oldname, string newname, bool destructive);
static string change_midi_path_by_name (string oldpath, string oldname, string newname, bool destructive);
#include <dlfcn.h>
#include <pbd/compose.h>
+#include <pbd/file_utils.h>
#include <pbd/error.h>
-#include <pbd/pathscanner.h>
#include <control_protocol/control_protocol.h>
#include <ardour/session.h>
#include <ardour/control_protocol_manager.h>
+#include <ardour/control_protocol_search_path.h>
using namespace ARDOUR;
using namespace std;
return 0;
}
-static bool protocol_filter (const string& str, void *arg)
-{
- /* Not a dotfile, has a prefix before a period, suffix is "so", or "dylib" */
-
- return str[0] != '.'
- && ((str.length() > 3 && str.find (".so") == (str.length() - 3))
- || (str.length() > 6 && str.find (".dylib") == (str.length() - 6)));
-}
-
void
ControlProtocolManager::load_mandatory_protocols ()
{
}
void
-ControlProtocolManager::discover_control_protocols (string path)
+ControlProtocolManager::discover_control_protocols ()
{
- vector<string *> *found;
- PathScanner scanner;
+ vector<sys::path> cp_modules;
- info << string_compose (_("looking for control protocols in %1"), path) << endmsg;
+ Glib::PatternSpec so_extension_pattern("*.so");
+ Glib::PatternSpec dylib_extension_pattern("*.dylib");
- found = scanner (path, protocol_filter, 0, false, true);
+ find_matching_files_in_search_path (control_protocol_search_path (),
+ so_extension_pattern, cp_modules);
- for (vector<string*>::iterator i = found->begin(); i != found->end(); ++i) {
- control_protocol_discover (**i);
- delete *i;
- }
+ find_matching_files_in_search_path (control_protocol_search_path (),
+ dylib_extension_pattern, cp_modules);
+
+ info << string_compose (_("looking for control protocols in %1"), control_protocol_search_path().get_string()) << endmsg;
- delete found;
+ for (vector<sys::path>::iterator i = cp_modules.begin(); i != cp_modules.end(); ++i) {
+ control_protocol_discover ((*i).to_string());
+ }
}
int
--- /dev/null
+/*
+ Copyright (C) 2007 Tim Mayberry
+
+ 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 <glibmm/miscutils.h>
+
+#include <ardour/control_protocol_search_path.h>
+#include <ardour/directory_names.h>
+#include <ardour/filesystem_paths.h>
+
+namespace {
+ const char * const surfaces_env_variable_name = "ARDOUR_SURFACES_PATH";
+} // anonymous
+
+namespace ARDOUR {
+
+SearchPath
+control_protocol_search_path ()
+{
+ bool surfaces_path_defined = false;
+ SearchPath spath_env(Glib::getenv(surfaces_env_variable_name, surfaces_path_defined));
+
+ if (surfaces_path_defined)
+ {
+ return spath_env;
+ }
+
+ SearchPath spath(user_config_directory ());
+
+ spath += system_module_directory ();
+
+ spath.add_subdirectory_to_paths(surfaces_dir_name);
+
+ return spath;
+}
+
+} // namespace ARDOUR
return p;
}
+sys::path
+system_module_directory ()
+{
+ sys::path module_directory(MODULE_DIR);
+ module_directory /= "ardour2";
+ return module_directory;
+}
+
} // namespace ARDOUR
/* singleton - first object is "it" */
new ControlProtocolManager ();
- ControlProtocolManager::instance().discover_control_protocols (Session::control_protocol_path());
+ ControlProtocolManager::instance().discover_control_protocols ();
XMLNode* node;
if ((node = Config->control_protocol_state()) != 0) {
return path;
}
-string
-ARDOUR::get_system_module_path ()
-{
- string path;
- char *envvar;
-
- if ((envvar = getenv ("ARDOUR_MODULE_PATH")) != 0) {
- path = envvar;
- } else {
- path += MODULE_DIR;
- path += "/ardour2/";
- }
-
- return path;
-}
-
static string
find_file (string name, string dir, string subdir = "")
{
#include <pbd/pathscanner.h>
#include <pbd/pthread_utils.h>
#include <pbd/search_path.h>
-#include <pbd/strsplit.h>
#include <pbd/stacktrace.h>
#include <pbd/copyfile.h>
return res;
}
-string
-Session::suffixed_search_path (string suffix, bool data)
-{
- string path;
-
- path += get_user_ardour_path();
- if (path[path.length()-1] != ':') {
- path += ':';
- }
-
- if (data) {
- path += get_system_data_path();
- } else {
- path += get_system_module_path();
- }
-
- vector<string> split_path;
-
- split (path, split_path, ':');
- path = "";
-
- for (vector<string>::iterator i = split_path.begin(); i != split_path.end(); ++i) {
- path += *i;
- path += suffix;
- path += '/';
-
- if (distance (i, split_path.end()) != 1) {
- path += ':';
- }
- }
-
- return path;
-}
-
-string
-Session::control_protocol_path ()
-{
- return suffixed_search_path (surfaces_dir_name, false);
-}
-
int
Session::load_bundles (const XMLNode& node)
{
dmalloc.cc
error.cc
filesystem.cc
+file_utils.cc
fpu.cc
id.cc
mountpoint.cc
--- /dev/null
+/*
+ Copyright (C) 2007 Tim Mayberry
+
+ 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 <algorithm>
+
+#include <glibmm/fileutils.h>
+#include <glibmm/pattern.h>
+
+#include <pbd/compose.h>
+#include <pbd/file_utils.h>
+
+#include <pbd/error.h>
+
+namespace PBD {
+
+void
+get_files_in_directory (const sys::path& directory_path, vector<string>& result)
+{
+ if (!is_directory(directory_path)) return;
+
+ try
+ {
+ Glib::Dir dir(directory_path.to_string());
+ std::copy(dir.begin(), dir.end(), std::back_inserter(result));
+ }
+ catch (Glib::FileError& err)
+ {
+ warning << err.what();
+ }
+}
+
+void
+find_matching_files_in_directory (const sys::path& directory,
+ const Glib::PatternSpec& pattern,
+ vector<sys::path>& result)
+{
+ vector<string> tmp_files;
+
+ get_files_in_directory (directory, tmp_files);
+
+ for (vector<string>::iterator file_iter = tmp_files.begin();
+ file_iter != tmp_files.end();
+ ++file_iter)
+ {
+ if (!pattern.match(*file_iter)) continue;
+
+ sys::path full_path(directory);
+ full_path /= *file_iter;
+
+ result.push_back(full_path);
+ }
+}
+
+void
+find_matching_files_in_directories (const vector<sys::path>& paths,
+ const Glib::PatternSpec& pattern,
+ vector<sys::path>& result)
+{
+ for (vector<sys::path>::const_iterator path_iter = paths.begin();
+ path_iter != paths.end();
+ ++path_iter)
+ {
+ find_matching_files_in_directory (*path_iter, pattern, result);
+ }
+}
+
+void
+find_matching_files_in_search_path (const SearchPath& search_path,
+ const Glib::PatternSpec& pattern,
+ vector<sys::path>& result)
+{
+ vector<sys::path> dirs;
+ std::copy(search_path.begin(), search_path.end(), std::back_inserter(dirs));
+ find_matching_files_in_directories (dirs, pattern, result);
+}
+
+bool
+find_file_in_search_path(const SearchPath& search_path,
+ const string& filename,
+ sys::path& result)
+{
+ vector<sys::path> tmp;
+ Glib::PatternSpec tmp_pattern(filename);
+
+ find_matching_files_in_search_path (search_path, tmp_pattern, tmp);
+
+ if (tmp.size() == 0)
+ {
+ info << string_compose
+ (
+ "Found no file named %1 in search path %2",
+ filename,
+ search_path.get_string ()
+ )
+ << endmsg;
+
+ return false;
+ }
+
+ if (tmp.size() != 1)
+ {
+ info << string_compose
+ (
+ "Found more than one file matching %1 in search path %2",
+ filename,
+ search_path.get_string ()
+ )
+ << endmsg;
+ }
+
+ result = tmp.front();
+
+ return true;
+}
+
+} // namespace PBD
--- /dev/null
+/*
+ Copyright (C) 2007 Tim Mayberry
+
+ 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.
+
+*/
+
+#ifndef PBD_FILE_UTILS_INCLUDED
+#define PBD_FILE_UTILS_INCLUDED
+
+#include <string>
+#include <vector>
+
+#include <glibmm/pattern.h>
+
+#include <pbd/search_path.h>
+
+namespace PBD {
+
+using std::string;
+using std::vector;
+
+/**
+ * Get a list of files in a directory.
+ * @note You must join path with result to get the absolute path
+ * to the file.
+ *
+ * @param path An Absolute path to a directory
+ * @param result A vector of filenames.
+ */
+void
+get_files_in_directory (const sys::path& path,
+ vector<string>& result);
+
+/**
+ * Takes a directory path and returns all the files in the directory
+ * matching a particular pattern.
+ *
+ * @param directory A directory path
+ * @param pattern A Glib::PatternSpec used to match the files.
+ * @param result A vector in which to place the resulting matches.
+ */
+void
+find_matching_files_in_directory (const sys::path& directory,
+ const Glib::PatternSpec& pattern,
+ vector<sys::path>& result);
+
+/**
+ * Takes a number of directory paths and returns all the files matching
+ * a particular pattern.
+ *
+ * @param paths A vector containing the Absolute paths
+ * @param pattern A Glib::PatternSpec used to match the files
+ * @param result A vector in which to place the resulting matches.
+ */
+void
+find_matching_files_in_directories (const vector<sys::path>& directory_paths,
+ const Glib::PatternSpec& pattern,
+ vector<sys::path>& result);
+
+/**
+ * Takes a SearchPath and puts a list of all the files in the search path
+ * that match pattern into the result vector.
+ *
+ * @param search_path A SearchPath
+ * @param pattern A Glib::PatternSpec used to match the files
+ * @param result A vector in which to place the resulting matches.
+ */
+void
+find_matching_files_in_search_path (const SearchPath& search_path,
+ const Glib::PatternSpec& pattern,
+ vector<sys::path>& result);
+
+/**
+ * Takes a search path and a file name and place the full path
+ * to that file in result if it is found within the search path.
+ *
+ * @return true If file is found within the search path.
+ */
+bool
+find_file_in_search_path (const SearchPath& search_path,
+ const string& filename,
+ sys::path& result);
+
+} // namespace PBD
+
+#endif
SearchPath ();
/**
- * Initialize SearchPath from a string each path may or may not
- * exist.
+ * Initialize SearchPath from a string where the string contains
+ * one or more absolute paths to directories which are delimited
+ * by a path separation character. The path delimeter is a
+ * colon(:) on unix and a semi-colon(;) on windows.
+ *
+ * Each path contained in the search path may or may not resolve to
+ * an existing directory in the filesystem.
*
* @param search_path A path string.
*/
SearchPath (const string& search_path);
+ /**
+ * Initialize SearchPath from a sys::path.
+ *
+ * @param directory_path A directory path.
+ */
+ SearchPath (const sys::path& directory_path);
+
/**
* Initialize SearchPath from a vector of paths that may or may
* not exist.
{
vector<sys::path> tmp;
- if(!tokenize ( path, string(path_delimiter), std::back_inserter (tmp)))
+ if(tokenize (path, string(path_delimiter), std::back_inserter (tmp)))
{
- // log warning(info perhaps?) that the path is empty
- warning << "SearchPath contains no tokens" << endmsg;
-
+ add_directories (tmp);
}
+}
- add_directories (tmp);
+SearchPath::SearchPath (const sys::path& directory_path)
+{
+ add_directory (directory_path);
}
SearchPath::SearchPath (const vector<sys::path>& paths)