Dolda2000 GitWeb
/
utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Allow printing of total size.
[utils.git]
/
bkselect.c
diff --git
a/bkselect.c
b/bkselect.c
index
6227a5b
..
7912898
100644
(file)
--- a/
bkselect.c
+++ b/
bkselect.c
@@
-8,6
+8,10
@@
#include <attr/xattr.h>
#include <attr/attributes.h>
#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;
int bkselect(char *path, int s)
{
DIR *d;
@@
-66,8
+70,9
@@
int bkselect(char *path, int s)
if(bkselect(pb, s))
r = 1;
} else if(S_ISREG(sb.st_mode) || S_ISLNK(sb.st_mode)) {
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);
printf("%s\n", pb);
+ tsize += sb.st_size;
}
}
}
}
@@
-75,18
+80,39
@@
int bkselect(char *path, int s)
return(r);
}
return(r);
}
+void usage(void)
+{
+ fprintf(stderr, "usage: bkselect [-hsq] path...\n");
+}
+
int main(int argc, char **argv)
{
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;
exit(1);
}
r = 0;
- for(i =
1
; i < argc; i++) {
+ for(i =
optind
; i < argc; i++) {
if(bkselect(argv[i], 0))
r = 1;
}
if(bkselect(argv[i], 0))
r = 1;
}
+ if(printsize)
+ printf("%lli\n", tsize);
return(r);
}
return(r);
}