Guest User

Untitled

a guest
Jan 23rd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <dirent.h>
  3. #include <sys/stat.h>
  4.  
  5. main()
  6. {
  7. DIR *d;
  8. struct dirent *de;
  9. struct stat buf;
  10. int exists;
  11. int total_size;
  12.  
  13. d = opendir(".");
  14. if (d == NULL) {
  15. perror("prsize");
  16. exit(1); // **ОШИБКА**
  17. }
  18.  
  19. total_size = 0;
  20.  
  21. for (de = readdir(d); de != NULL; de = readdir(d)) {
  22. exists = stat(de->d_name, &buf);
  23. if (exists < 0) {
  24. fprintf(stderr, "Couldn't stat %sn", de->d_name);
  25. } else {
  26. total_size += buf.st_size;
  27. }
  28. }
  29. closedir(d);
  30. printf("%dn", total_size);
  31. }
  32.  
  33. #include <stdlib.h>
  34.  
  35. stat(pathname, &sb);
  36. if ((sb.st_mode & S_IFMT) == S_IFREG) {
  37. /* Handle regular file */
  38. }
Add Comment
Please, Sign In to add comment