#include <attr/xattr.h>
#include <attr/attributes.h>
+int printsize = 0;
+int printnames = 1;
+long long tsize = 0;
+
int bkselect(char *path, int s)
{
DIR *d;
if(bkselect(pb, s))
r = 1;
} else if(S_ISREG(sb.st_mode) || S_ISLNK(sb.st_mode)) {
- if(s)
+ if(s && printnames)
printf("%s\n", pb);
+ tsize += sb.st_size;
}
}
return(r);
}
+void usage(void)
+{
+ fprintf(stderr, "usage: bkselect [-hsq] path...\n");
+}
+
int main(int argc, char **argv)
{
- int i, r;
+ int c, i, r;
- if(argc < 1) {
- fprintf(stderr, "usage: bkselect path...\n");
+ while((c = getopt(argc, argv, "hsq")) >= 0) {
+ switch(c) {
+ case 's':
+ printsize = 1;
+ break;
+ case 'q':
+ printnames = 0;
+ break;
+ case 'h':
+ default:
+ usage();
+ exit((c == 'h')?0:1);
+ }
+ }
+ if(argc - optind < 1) {
+ usage();
exit(1);
}
r = 0;
- for(i = 1; i < argc; i++) {
+ for(i = optind; i < argc; i++) {
if(bkselect(argv[i], 0))
r = 1;
}
+ if(printsize)
+ printf("%lli\n", tsize);
return(r);
}