-static int add_matching_files(struct udev *udev, struct udev_list *file_list, const char *dirname, const char *suffix)
-{
- DIR *dir;
- struct dirent *dent;
- char filename[UTIL_PATH_SIZE];
-
- dir = opendir(dirname);
- if (dir == NULL) {
- log_debug("unable to open '%s': %m\n", dirname);
- return -1;
- }
-
- for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
- if (dent->d_name[0] == '.')
- continue;
-
- /* look for file matching with specified suffix */
- if (suffix != NULL) {
- const char *ext;
-
- ext = strrchr(dent->d_name, '.');
- if (ext == NULL)
- continue;
- if (strcmp(ext, suffix) != 0)
- continue;
- }
- util_strscpyl(filename, sizeof(filename), dirname, "/", dent->d_name, NULL);
- /*
- * the basename is the key, the filename the value
- * identical basenames from different directories override each other
- * entries are sorted after basename
- */
- udev_list_entry_add(file_list, dent->d_name, filename);
- }
-
- closedir(dir);
- return 0;
-}
-