void plugin_factory_collection::load_modules(const filesystem::path& Path, const bool Recursive, const load_proxy_t LoadProxies)
{
	m_implementation->m_message_signal.emit(string_cast(boost::format(_("Searching for plugins in %1%")) % Path.native_utf8_string().raw()));

	// Create a sorted list of files in this directory ...
	std::vector<filesystem::path> files;
	for(k3d::filesystem::directory_iterator path(Path); path != k3d::filesystem::directory_iterator(); ++path)
		files.push_back(*path);
	std::sort(files.begin(), files.end());

	// Load modules
	for(std::vector<filesystem::path>::const_iterator file = files.begin(); file != files.end(); ++file)
	{
		if(!filesystem::is_directory(*file))
			load_module(*file, LoadProxies);
	}

	// Optionally descend recursively into subdirectories ...
	if(Recursive)
	{
		for(std::vector<filesystem::path>::const_iterator file = files.begin(); file != files.end(); ++file)
		{
			if(filesystem::is_directory(*file))
				load_modules(*file, Recursive, LoadProxies);
		}
	}
}
Esempio n. 2
0
void set_path(const string_t& PathType, const filesystem::path& Path)
{
	detail::path_element(PathType).text = Path.native_utf8_string().raw();
}
void plugin_factory_collection::load_module(const filesystem::path& Path, const load_proxy_t LoadProxies)
{
	// K-3D modules now have the same extension on all platforms ...
	if(filesystem::extension(Path).lowercase().raw() != ".module")
		return;

	// If the module can be proxied for fast startup, do that and return ...
	if(LoadProxies == LOAD_PROXIES)
	{
		filesystem::path proxy_path = Path + ".proxy";
		if(filesystem::exists(proxy_path) && m_implementation->proxy_module(Path, proxy_path))
			return;
	}

	// OK, just load the module ...
	m_implementation->m_message_signal.emit(string_cast(boost::format(_("Loading plugin module %1%")) % Path.native_utf8_string().raw()));

	register_plugins_entry_point register_plugins = 0;
	os_load_module(Path, register_plugins);
	if(!register_plugins)
		return;

	// It's a K-3D module, all-right - give it a chance to register its plugins
	detail::plugin_registry registry(m_implementation->m_message_signal, m_implementation->m_factories);
	register_plugins(registry);
}