Xinqi Bao's Git
1 /* See LICENSE file for copyright and license details. */
10 num_files(const char *dir
)
16 if ((fd
= opendir(dir
)) == NULL
) {
17 warn("Failed to get number of files in directory %s", dir
);
21 while ((dp
= readdir(fd
)) != NULL
) {
22 if (!strcmp(dp
->d_name
, ".") || !strcmp(dp
->d_name
, ".."))
23 continue; /* skip self and parent */
29 return bprintf("%d", num
);