aboutsummaryrefslogtreecommitdiff
path: root/src/cli/stasis_indexer/helpers.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@users.noreply.github.com>2025-03-31 15:53:52 -0400
committerGitHub <noreply@github.com>2025-03-31 15:53:52 -0400
commit34cee3ad5258b86dfe60df155636bf929b9d0e13 (patch)
tree5c11f2fbdc713ed49b65ce839e0550023ff5f0b2 /src/cli/stasis_indexer/helpers.c
parent5da81c51855b99bc8118d15dce7b8063af8a9afe (diff)
parente817b38090defab01e64bc3516ea474215bfcb09 (diff)
downloadstasis-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.c34
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