diff options
| author | Raghuram Subramani <raghus2247@gmail.com> | 2025-06-16 15:58:19 +0530 |
|---|---|---|
| committer | Raghuram Subramani <raghus2247@gmail.com> | 2025-06-16 15:58:19 +0530 |
| commit | 7d491fba56966311e09299a137dab90bb7ade124 (patch) | |
| tree | 3f92d4682b8ace2ac625a880f33cf0e97ea117e6 /msg.c | |
| parent | 840e0e406eea0b6397a33cdbd9a39474e5006a12 (diff) | |
(init): recursively search directory
Diffstat (limited to 'msg.c')
| -rw-r--r-- | msg.c | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -0,0 +1,41 @@ +#define _GNU_SOURCE + +#include <ftw.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "config.h" + +int +fn(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf) +{ + (void) sb; + + const char *basename = fpath + ftwbuf->base; + + /* printf("%s\n", basename); */ + if (typeflag == FTW_D) { + if (!strcmp(basename, partials_directory) + || !strcmp(basename, assets_directory)) + return FTW_SKIP_SUBTREE; + + return FTW_CONTINUE; + } + + const char *path = fpath + strlen(directory) + 1; + + printf("%s\n", fpath); + return FTW_CONTINUE; +} + +int +main(int argc, char **argv) +{ + (void) argc; + (void) argv; + + nftw(directory, fn, 64, FTW_PHYS | FTW_ACTIONRETVAL); + + return EXIT_SUCCESS; +} |
