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