Advertisement
Guest User

Untitled

a guest
Apr 1st, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <dirent.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <sys/types.h>
  5. #include <sys/stat.h>
  6. #include <fcntl.h>
  7.  
  8. int main ()
  9. {
  10. DIR * folder;
  11. struct dirent *entry;
  12. const char folder_name[] = ".";
  13.  
  14. folder = opendir (folder_name);
  15. if (folder == NULL)
  16. {
  17. perror ("Unable to read directory");
  18. exit (-1);
  19. }
  20.  
  21. while ((entry = readdir (folder)))
  22. {
  23. struct stat buffer;
  24. int status;
  25. status = lstat (entry->d_name, &buffer);
  26. if (S_ISREG(buffer.st_mode))
  27. printf ("Fichier %s\n", entry->d_name);
  28. }
  29.  
  30. closedir (folder);
  31.  
  32. return (0);
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement