diff options
author | Joseph Hunkeler <jhunkeler@users.noreply.github.com> | 2025-03-31 15:53:52 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-31 15:53:52 -0400 |
commit | 34cee3ad5258b86dfe60df155636bf929b9d0e13 (patch) | |
tree | 5c11f2fbdc713ed49b65ce839e0550023ff5f0b2 /src/cli/stasis_indexer/helpers.c | |
parent | 5da81c51855b99bc8118d15dce7b8063af8a9afe (diff) | |
parent | e817b38090defab01e64bc3516ea474215bfcb09 (diff) | |
download | stasis-34cee3ad5258b86dfe60df155636bf929b9d0e13.tar.gz |
Merge pull request #102 from jhunkeler/order-of-battle
Bugs and fixes
Diffstat (limited to 'src/cli/stasis_indexer/helpers.c')
-rw-r--r-- | src/cli/stasis_indexer/helpers.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/cli/stasis_indexer/helpers.c b/src/cli/stasis_indexer/helpers.c index 8ae49a3..018a8f6 100644 --- a/src/cli/stasis_indexer/helpers.c +++ b/src/cli/stasis_indexer/helpers.c @@ -356,3 +356,37 @@ int load_metadata(struct Delivery *ctx, const char *filename) { return 0; } + +int write_manifest(const char *path, char **exclude_path, FILE *fp) { + struct dirent *rec = NULL; + DIR *dp = opendir(path); + if (!dp) { + perror(path); + return -1; + } + while ((rec = readdir(dp)) != NULL) { + if (!strcmp(rec->d_name, ".") || !strcmp(rec->d_name, "..")) { + continue; + } + if (strstr_array(exclude_path, rec->d_name)) { + continue; + } + char filepath[PATH_MAX] = {0}; + strncpy(filepath, path, PATH_MAX - 1); + strcat(filepath, "/"); + strcat(filepath, rec->d_name); + if (rec->d_type == DT_DIR) { + write_manifest(filepath, exclude_path, fp); + continue; + } + + char *output = filepath; + if (!strncmp(output, "./", 2)) { + output += 2; + } + printf("%s\n", output); + fprintf(fp, "%s\n", output); + } + closedir(dp); + return 0; +}
\ No newline at end of file |