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 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 thod='get' action='/src/log/bin/dash/depcomp'>
Commit message (Expand)Author
2021-09-26Publish "Installing OpenBSD on Linode"June McEnroe
2021-09-26Use tiny UTF-8-aware col -b replacementJune McEnroe
2021-09-25Install up to cgi-binJune McEnroe
2021-09-25Clean up up (ugh) somewhat againJune McEnroe
2021-09-25Update root path in up.shJune McEnroe
2021-09-25Disable HashKnownHostsJune McEnroe
2021-09-25Add scout to ssh configJune McEnroe
2021-09-25Sandbox up on both FreeBSD and OpenBSDJune McEnroe
2021-09-25Set SO_REUSEADDR in quickJune McEnroe
2021-09-25Revert "Add cat alias using less"June McEnroe
2021-09-24Pledge downgradeJune McEnroe
2021-09-24Set original socket CLOEXECJune McEnroe
2021-09-24Consume request headers using MSG_PEEKJune McEnroe
2021-09-24Set only HTTP_HOSTJune McEnroe
2021-09-23Scroll by single lines in xtermJune McEnroe
2021-09-23Hide htop "function bar"June McEnroe
2021-09-23Allow FocusEvents in xtermJune McEnroe
2021-09-23Use NI_NUMERICSERVJune McEnroe
2021-09-23Make up build away from FreeBSDJune McEnroe
2021-09-23Add quickJune McEnroe
2021-09-23Add The HobbitJune McEnroe
2021-09-22Remove PSF fontsJune McEnroe
2021-09-22Remove Linux-specific utilitiesJune McEnroe
2021-09-22Call sandbox in CGI modeJune McEnroe
2021-09-22Support HTTP PUT in upJune McEnroe
2021-09-22Remove default faviconJune McEnroe
2021-09-21Use Z_FILTERED strategyJune McEnroe
2021-09-21Recalculate various lengths only as neededJune McEnroe
2021-09-21Rewrite pngo, add explicit optionsJune McEnroe
2021-09-16Fix /* **/ comment matchingJune McEnroe
2021-09-15Remove typer, add downgrade to READMEJune McEnroe
2021-09-15Set bot mode on downgradeJune McEnroe
2021-09-15Enter capsicum in downgradeJune McEnroe
2021-09-15Factor out common parts of downgrade messagesJune McEnroe
2021-09-14Add downgrade IRC botJune McEnroe
2021-09-14Sort by title if authors matchJune McEnroe
2021-09-13Swap-remove tags as they're foundJune McEnroe
2021-09-12Replace htagml regex with strncmpJune McEnroe
2021-09-11Also defer printing comment for lone close-parensJune McEnroe
2021-09-10Publish "git-comment"June McEnroe
2021-09-10Add git comment --pretty optionJune McEnroe
2021-09-08Defer printing comment if line is blank or closing braceJune McEnroe
2021-09-08Up default min-repeat to 30 linesJune McEnroe
2021-09-08Handle dirty lines in git-commentJune McEnroe
2021-09-08Document and install git-commentJune McEnroe
2021-09-08Add repeat and all options to git-commentJune McEnroe
2021-09-08Add group threshold to git-commentJune McEnroe