tst-scandir.c 356 B

1234567891011121314151617181920212223
  1. #include <dirent.h>
  2. #include <errno.h>
  3. #include <stdio.h> /* perror() */
  4. #include <stdlib.h>
  5. static int skip_all(const struct dirent *dirbuf)
  6. {
  7. errno = EBADF;
  8. return 0;
  9. }
  10. int main(void)
  11. {
  12. struct dirent **namelist;
  13. int n;
  14. n = scandir(".", &namelist, skip_all, 0);
  15. if (n < 0) {
  16. perror("scandir");
  17. return EXIT_FAILURE;
  18. }
  19. return EXIT_SUCCESS;
  20. }