Advertisement
Al3XS0n

Untitled

Nov 24th, 2020
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <sys/types.h>
  2. #include <sys/stat.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6.  
  7. int main() {
  8. struct stat file;
  9. char buf[5000];
  10. off_t result = 0;
  11. while (1) {
  12. char* st = fgets(buf, sizeof(buf), stdin);
  13. if (st == NULL) {
  14. break;
  15. }
  16. int str_sz = strlen(buf);
  17. if (buf[str_sz - 1] == '\n') {
  18. buf[str_sz - 1] = '\0';
  19. }
  20. int status = lstat(buf, &file);
  21. if (status == 0 && S_ISREG(file.st_mode)) {
  22. result += file.st_size;
  23. }
  24. }
  25. printf("%ld", result);
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement