Commit: 9215292438722ebe405b827c8a298e0228df8c13
Parent: b55afce255da7509c2c8c90caf24ebaef85608cb
Author: 0x766F6964
Date: Sun, 3 May 2020 15:58:21 -0600
use stat(2) to determine subdirs
Diffstat:
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/mpvdir2list.c b/mpvdir2list.c
@@ -4,6 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/stat.h>
#include <time.h>
#include "config.h"
@@ -101,8 +102,9 @@ addfile(struct node *node, struct list *list, const char *file)
static struct node *
subdir(struct node *node)
{
- DIR *dir, *tmpdir;
+ DIR *dir;
struct dirent *ent;
+ struct stat sb;
char *s, *t;
if (!(dir = opendir(node->path)))
@@ -120,9 +122,8 @@ subdir(struct node *node)
xstrcat(t, s, PATH_MAX);
xstrcat(t, ent->d_name, PATH_MAX);
- if ((tmpdir = opendir(t))) {
- closedir(tmpdir);
-
+ stat(t, &sb);
+ if (S_ISDIR(sb.st_mode)) {
if (!valid_dir(ent->d_name)) {
free(t);
continue;