Introduction
Introduction Statistics Contact Development Disclaimer Help
num_files: opendir() returns a directory stream - slstatus - status monitor
git clone git://git.suckless.org/slstatus
Log
Files
Refs
README
LICENSE
---
commit 984f45719e8ac9f4451c2d009fb34e28afdfbdb6
parent c432c981df97f786c683435a4a06bd58fc9a7b18
Author: planet36 <[email protected]>
Date: Tue, 11 May 2021 22:45:34 -0400
num_files: opendir() returns a directory stream
opendir() returns a directory stream, not a file descriptor
Co-authored-by: drkhsh <[email protected]>
Signed-off-by: drkhsh <[email protected]>
Diffstat:
M components/num_files.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
---
diff --git 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);
}
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.