Discover plugins in converter.c
[babeltrace.git] / plugins / component-factory.c
index 03e0148595065ee1a14e4e2ce17673e9ed275ed9..28b1e10618a4bfd90372d7a1dde44210ec558f50 100644 (file)
@@ -170,11 +170,25 @@ bt_component_factory_load_dir_recursive(struct bt_component_factory *factory,
                file_path[path_len++] = '/';
        }
 
+       directory = opendir(file_path);
+       if (!directory) {
+               perror("Failed to open plug-in directory");
+               ret = BT_COMPONENT_FACTORY_STATUS_ERROR;
+               goto end;
+       }
+
        /* Recursively walk directory */
        while (!readdir_r(directory, entry, &result) && result) {
                struct stat st;
                int stat_ret;
-               size_t file_name_len = strlen(result->d_name);
+               size_t file_name_len;
+
+               if (result->d_name[0] == '.') {
+                       /* Skip hidden files, . and .. */
+                       continue;
+               }
+
+               file_name_len = strlen(result->d_name);
 
                if (path_len + file_name_len >= PATH_MAX) {
                        continue;
@@ -201,6 +215,15 @@ bt_component_factory_load_dir_recursive(struct bt_component_factory *factory,
                }
        }
 end:
+       if (directory) {
+               if (closedir(directory)) {
+                       /*
+                        * We don't want to override the error since there is
+                        * nothing could do.
+                        */
+                       perror("Failed to close plug-in directory");
+               }
+       }
        free(entry);
        free(file_path);
        return ret;
This page took 0.023161 seconds and 4 git commands to generate.