diff options
author | planet36 <planet36@users.noreply.github.com> | 2021-05-11 22:45:34 -0400 |
---|---|---|
committer | Rafael Marçalo <raroma09@gmail.com> | 2023-01-03 15:02:43 +0000 |
commit | 2e0c78c98deb3933ab89d7bb4065e51ed9765d93 (patch) | |
tree | 15d2ba12e925547cf43d60469972944873382252 | |
parent | 5755d838d13f587e549a4aecbb24940f3a407c46 (diff) |
num_files: opendir() returns a directory stream
opendir() returns a directory stream, not a file descriptor
Co-authored-by: drkhsh <me@drkhsh.at>
Signed-off-by: drkhsh <me@drkhsh.at>
-rw-r--r-- | components/num_files.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/components/num_files.c b/components/num_files.c index e4b4281..df0acd1 100644 --- a/components/num_files.c +++ b/components/num_files.c @@ -10,23 +10,23 @@ const char * 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); } |