Exemple #1
0
static void
rb_plugins_engine_load_all (void)
{
	GList *paths;

	paths = rb_get_plugin_paths ();
	while (paths != NULL) {
		rb_plugins_engine_load_dir (paths->data);
		g_free (paths->data);
		paths = g_list_delete_link (paths, paths);
	}
}
Exemple #2
0
char *
rb_plugin_find_file (RBPlugin *plugin,
		     const char *file)
{
	RBPluginPrivate *priv = RB_PLUGIN_GET_PRIVATE (plugin);
	GList *paths;
	GList *l;
	char *ret = NULL;

	paths = rb_get_plugin_paths ();

	for (l = paths; l != NULL; l = l->next) {
		if (ret == NULL && priv->name) {
			char *tmp;

			tmp = g_build_filename (l->data, priv->name, file, NULL);

			if (g_file_test (tmp, G_FILE_TEST_EXISTS)) {
				ret = tmp;
				break;
			}
			g_free (tmp);
		}
	}

	g_list_foreach (paths, (GFunc)g_free, NULL);
	g_list_free (paths);

	/* global data files */
	if (ret == NULL) {
		const char *f;

		f = rb_file (file);
		if (f)
			ret = g_strdup (f);
	}

	rb_debug ("found '%s' when searching for file '%s' for plugin '%s'",
		  ret, file, priv->name);

	/* ensure it's an absolute path, so doesn't confuse rb_builder_load et al */
	if (ret != NULL && ret[0] != '/') {
		char *pwd = g_get_current_dir ();
		char *path = g_strconcat (pwd, G_DIR_SEPARATOR_S, ret, NULL);
		g_free (ret);
		g_free (pwd);
		ret = path;
	}
	return ret;
}