pipewire: impl-module: only stat if necessary

On some filesystems, the directory entry type is immediately
available, so use that to check if the entity is a directory,
and only use `stat()` when the entity type cannot be determined
from the directory entry.
This commit is contained in:
Barnabás Pőcze 2023-07-03 16:28:25 +02:00
parent f82f215bf7
commit f8344a3908

View file

@ -75,7 +75,8 @@ static char *find_module(const char *path, const char *name, int level)
if (newpath == NULL)
break;
if (stat(newpath, &s) == 0 && S_ISDIR(s.st_mode))
if (entry->d_type == DT_DIR ||
(entry->d_type == DT_UNKNOWN && stat(newpath, &s) == 0 && S_ISDIR(s.st_mode)))
filename = find_module(newpath, name, level - 1);
free(newpath);