opendir() returns a directory stream, not a file descriptor
Co-authored-by: drkhsh <me@drkhsh.at>
Signed-off-by: drkhsh <me@drkhsh.at>
num_files(const char *path)
{
struct dirent *dp;
- DIR *fd;
+ DIR *dir;
int num;
- if (!(fd = opendir(path))) {
+ if (!(dir = opendir(path))) {
warn("opendir '%s':", path);
return NULL;
}
num = 0;
- while ((dp = readdir(fd))) {
+ while ((dp = readdir(dir))) {
if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, ".."))
continue; /* skip self and parent */
num++;
}
- closedir(fd);
+ closedir(dir);
return bprintf("%d", num);
}