From ffbdc460b6460a673efce4226ba9c557dd52b066 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Mon, 2 Jul 2018 22:25:55 -0400 Subject: Add find scrap --- scrap/find.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 scrap/find.c (limited to 'scrap') diff --git a/scrap/find.c b/scrap/find.c new file mode 100644 index 00000000..92744b17 --- /dev/null +++ b/scrap/find.c @@ -0,0 +1,48 @@ +#include +#include +#include +#include +#include +#include + +static const char *path[1024]; +static size_t depth; + +static void traverse(int parent, const char *name) { + path[depth++] = name; + + int fd = openat(parent, name, O_RDONLY); + if (fd < 0) err(EX_NOINPUT, "%s", name); + + DIR *dir = fdopendir(fd); + if (!dir) err(EX_IOERR, "%s", name); + + struct dirent *entry; + while (NULL != (entry = readdir(dir))) { + if (entry->d_namlen == 1 && entry->d_name[0] == '.') continue; + if ( + entry->d_namlen == 2 + && entry->d_name[0] == '.' + && entry->d_name[1] == '.' + ) continue; + + if (entry->d_type == DT_DIR) { + traverse(fd, entry->d_name); + } + + for (size_t i = 0; i < depth; ++i) { + printf("%s/", path[i]); + } + printf("%s\n", entry->d_name); + } + // TODO: Check error. + + closedir(dir); + depth--; +} + +int main(int argc, char *argv[]) { + if (argc < 2) return EX_USAGE; + traverse(AT_FDCWD, argv[1]); + return EX_OK; +} -- cgit 1.4.1 337f&follow=1'>commit diff
Commit message (Collapse)Author
2021-03-24Import security/libretls from ports svnJune McEnroe
2021-03-08Add bubger portJune McEnroe
2021-03-08Update catsit to 1.3June McEnroe
2021-03-08Update imbox to 1.4June McEnroe
2021-02-09Update catgirl to 1.6June McEnroe
2021-02-08Update catsit to 1.2June McEnroe
2021-02-08Update pounce to 2.3June McEnroe
2021-02-04Update cgit-causal-agency to 8e4c63cJune McEnroe
2021-01-20Update cgit-causal-agency to 8a10aa5June McEnroe
2021-01-17Update cgit-causal-agencyJune McEnroe
2021-01-17Update scooper to 1.1June McEnroe
2021-01-17Update catgirl to 1.5 (BONUS WEBISODE)June McEnroe
2021-01-15Update litterbox to 1.7June McEnroe
2021-01-15Update pounce to 2.2June McEnroe
2021-01-15Update catgirl to 1.4June McEnroe
2020-12-28Replace cgit-patched with cgit-causal-agencyJune McEnroe
2020-12-18Add notemap portJune McEnroe
2020-12-15Update libretls to 3.3.1June McEnroe
2020-12-15Update catsit to 1.1June McEnroe
2020-12-15Update pounce to 2.1p1June McEnroe
2020-12-15Add imbox portJune McEnroe
2020-11-24Update pounce to 2.1June McEnroe
2020-11-24Update libretls to 3.3.0June McEnroe
2020-11-17Update catgirl to 1.3June McEnroe
2020-11-17Update libretls to 3.2.2June McEnroe
2020-09-29Update libretls to 3.2.1June McEnroe
2020-09-10Update catgirl to 1.2June McEnroe
2020-09-09Add pounce-palaver portJune McEnroe
2020-09-09Update pounce to 2.0June McEnroe
2020-09-09Update litterbox to 1.6June McEnroe
2020-08-23Add scooper portJune McEnroe
2020-08-23Add catsit portJune McEnroe
2020-08-13Update pounce to 1.4p2June McEnroe
2020-08-11Update pounce to 1.4p1June McEnroe
2020-08-10Add litterbox portJune McEnroe
2020-08-10Add missing USES=pkgconfig to pounceJune McEnroe