27 #include "../common/Translator.h"
33 #include <boost/filesystem.hpp>
34 #include <boost/format.hpp>
55 dirs.push_back( boost::filesystem::system_complete(
"." ).
string() );
67 char* e = getenv(TE_DIR_ENVIRONMENT_VARIABLE);
71 boost::filesystem::path p(e);
74 if(boost::filesystem::is_directory(p))
75 dirs.push_back( boost::filesystem::system_complete(p).
string() );
79 #ifdef TE_PLUGINS_INSTALL_PATH
81 boost::filesystem::path p(TE_PLUGINS_INSTALL_PATH);
83 if(boost::filesystem::is_directory(p))
84 dirs.push_back( boost::filesystem::system_complete(p).
string() );
91 if(!boost::filesystem::is_directory(path))
92 throw Exception((boost::format(
TR_PLUGIN(
"Default plugin directory is invalid: %1%.")) % path).str());
94 boost::filesystem::path p(boost::filesystem::system_complete(path));
96 std::string s(p.string());
98 if(std::find(m_pluginsDir.begin(), m_pluginsDir.end(), s) != m_pluginsDir.end())
101 m_pluginsDir.push_back(s);
112 std::size_t ndirs = m_pluginsDir.size();
115 for(std::size_t i = 0; i < ndirs; ++i)
117 if(!boost::filesystem::is_directory(m_pluginsDir[i]))
118 throw Exception((boost::format(
TR_PLUGIN(
"The base plugin directory is invalid: %1%.")) % m_pluginsDir[i]).str());
120 boost::filesystem::path path(m_pluginsDir[i]);
122 for(boost::filesystem::directory_iterator it(path), itEnd; it != itEnd; ++it)
125 if(boost::filesystem::is_directory(it->status()))
127 boost::filesystem::path foundPlugin = (*it);
131 if(boost::filesystem::is_regular_file(foundPlugin))
The basic information about a plugin.
#define TR_PLUGIN(message)
It marks a string in order to get translated. This is a special mark used in the Plugin module of Ter...
Utility functions for dealing with plugins.
TEPLUGINEXPORT PluginInfo * GetInstalledPlugin(const std::string &pluginFilePath)
It returns information about a given plugin provided its plugin configuration file name or dir...
std::vector< std::string > m_pluginsDir
The base list of directories to search for plugins.
~DefaultFinder()
Destructor.
void getDefaultDirs(std::vector< std::string > &dirs) const
It returns the default plugins directories.
#define TE_DEFAULT_PLUGINS_DIR
The default look up plugin dir.
A plugin finder that search for plugins in some special directories defined by compile time macros...
DefaultFinder()
Constructor.
void addPluginsDir(const std::string &path)
It adds a new base location where the finder will search for installed plugins.
const std::vector< std::string > & getPluginsDir() const
It returns the list of plugins base directories.
void getPlugins(boost::ptr_vector< PluginInfo > &plugins)
This method searches for installed plugins and output the plugins information in the PluginInfo vecto...
#define TE_DEFAULT_PLUGIN_FILE_NAME
The XML file name with plugin information.