84f50bed8c9078f4678c9be92a76f5a762ee6185
2 #include "git-compat-util.h"
5 #include "dir-iterator.h"
7 /* Argument is a directory path to iterate over */
8 int cmd__dir_iterator(int argc
, const char **argv
)
10 struct strbuf path
= STRBUF_INIT
;
11 struct dir_iterator
*diter
;
14 die("BUG: test-dir-iterator needs one argument");
16 strbuf_add(&path
, argv
[1], strlen(argv
[1]));
18 diter
= dir_iterator_begin(path
.buf
);
20 while (dir_iterator_advance(diter
) == ITER_OK
) {
21 if (S_ISDIR(diter
->st
.st_mode
))
23 else if (S_ISREG(diter
->st
.st_mode
))
28 printf("(%s) [%s] %s\n", diter
->relative_path
, diter
->basename
,