Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifdef __cplusplus
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <string>
- #include <iostream>
- #include <algorithm>
- #include <vector>
- #include <set>
- #include <map>
- #include <cmath>
- // forprak
- #include <unistd.h>
- #include <fcntl.h>
- #include <climits>
- #include <elf.h>
- #include <sys/stat.h>
- #include <dirent.h>
- // endforprak
- using namespace std;
- #else
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <math.h>
- #include <unistd.h>
- #include <fcntl.h>
- #include <limits.h>
- #include <elf.h>
- #include <stdbool.h>
- #include <time.h>
- #include <sys/stat.h>
- #include <dirent.h>
- #endif
- typedef long long ll;
- typedef struct tm tm;
- #define sqrt(x) (sqrt(abs((x))))
- #define mp make_pair
- #define pb push_back
- #define sqr(o) ((o)*(o))
- int main(int argc, char ** argv)
- {
- //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout);
- //freopen("highways.in", "r", stdin);freopen("highways.out", "w", stdout);
- DIR * d;
- if (!(d = opendir(argv[1])))
- {
- return 0;
- }
- char path[PATH_MAX] = {0};
- strcpy(path, argv[1]);
- int l = strlen(path);
- path[l++] = '/';
- char * ppath = path + l;
- ll ans = 0;
- struct dirent *file;
- while ((file = readdir(d)))
- {
- struct stat s;
- strcpy(ppath, file->d_name);
- stat(path, &s);
- if (S_ISREG(s.st_mode) && !(S_ISLNK(s.st_mode)))
- {
- //printf("%s --> %d\n", path, s.st_size);
- ans += s.st_size;
- }
- }
- printf("%lld\n", ans);
- closedir(d);
- return 0;
- }
Add Comment
Please, Sign In to add comment