const char *plugin_name, enum bt_component_type type,
const char *component_name);
+/**
+ * Load and register Babeltrace plugins under a given path.
+ *
+ * Path will be traversed if it is a directory, otherwise only the provided file
+ * will be loaded.
+ *
+ * @param factory A component factory instance
+ * @param path A path to a file or directory
+ * @returns One of #bt_component_factory_status values
+ */
+extern enum bt_component_factory_status bt_component_factory_load(
+ struct bt_component_factory *factory, const char *path);
+
/**
* Recursively load and register Babeltrace plugins under a given path.
*
* @param path A path to a file or directory
* @returns One of #bt_component_factory_status values
*/
-extern enum bt_component_factory_status bt_component_factory_load(
+extern enum bt_component_factory_status bt_component_factory_load_recursive(
struct bt_component_factory *factory, const char *path);
extern enum bt_component_factory_status
static
enum bt_component_factory_status
-bt_component_factory_load_dir_recursive(struct bt_component_factory *factory,
- const char *path)
+bt_component_factory_load_dir(struct bt_component_factory *factory,
+ const char *path, bool recurse)
{
DIR *directory = NULL;
struct dirent *entry = NULL, *result = NULL;
continue;
}
- if (S_ISDIR(st.st_mode)) {
- ret = bt_component_factory_load_dir_recursive(factory,
- file_path);
+ if (S_ISDIR(st.st_mode) && recurse) {
+ ret = bt_component_factory_load_dir(factory,
+ file_path, true);
if (ret != BT_COMPONENT_FACTORY_STATUS_OK) {
goto end;
}
return bt_get(component_class);
}
-enum bt_component_factory_status bt_component_factory_load(
- struct bt_component_factory *factory, const char *path)
+static
+enum bt_component_factory_status _bt_component_factory_load(
+ struct bt_component_factory *factory, const char *path,
+ bool recursive)
{
enum bt_component_factory_status ret = BT_COMPONENT_FACTORY_STATUS_OK;
}
if (g_file_test(path, G_FILE_TEST_IS_DIR)) {
- ret = bt_component_factory_load_dir_recursive(factory, path);
+ ret = bt_component_factory_load_dir(factory, path, recursive);
} else if (g_file_test(path, G_FILE_TEST_IS_REGULAR) ||
g_file_test(path, G_FILE_TEST_IS_SYMLINK)) {
ret = bt_component_factory_load_file(factory, path);
return ret;
}
+enum bt_component_factory_status bt_component_factory_load_recursive(
+ struct bt_component_factory *factory, const char *path)
+{
+ return _bt_component_factory_load(factory, path, true);
+}
+
+enum bt_component_factory_status bt_component_factory_load(
+ struct bt_component_factory *factory, const char *path)
+{
+ return _bt_component_factory_load(factory, path, false);
+}
+
static
enum bt_component_factory_status
add_component_class(struct bt_component_factory *factory, const char *name,