Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <dirent.h>
- #include <sys/stat.h>
- main()
- {
- DIR *d;
- struct dirent *de;
- struct stat buf;
- int exists;
- int total_size;
- d = opendir(".");
- if (d == NULL) {
- perror("prsize");
- exit(1); // **ОШИБКА**
- }
- total_size = 0;
- for (de = readdir(d); de != NULL; de = readdir(d)) {
- exists = stat(de->d_name, &buf);
- if (exists < 0) {
- fprintf(stderr, "Couldn't stat %sn", de->d_name);
- } else {
- total_size += buf.st_size;
- }
- }
- closedir(d);
- printf("%dn", total_size);
- }
- #include <stdlib.h>
- stat(pathname, &sb);
- if ((sb.st_mode & S_IFMT) == S_IFREG) {
- /* Handle regular file */
- }
Add Comment
Please, Sign In to add comment