aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compromyse.xyz/abc.txt1
-rw-r--r--compromyse.xyz/config.cfg5
-rw-r--r--include/msg.h1
-rw-r--r--src/msg.c29
4 files changed, 31 insertions, 5 deletions
diff --git a/compromyse.xyz/abc.txt b/compromyse.xyz/abc.txt
new file mode 100644
index 0000000..38bf177
--- /dev/null
+++ b/compromyse.xyz/abc.txt
@@ -0,0 +1 @@
+asfuiahis
diff --git a/compromyse.xyz/config.cfg b/compromyse.xyz/config.cfg
index c785a93..64b7580 100644
--- a/compromyse.xyz/config.cfg
+++ b/compromyse.xyz/config.cfg
@@ -4,3 +4,8 @@ resources = {
posts/a.html,
posts/b.md
}
+
+static = {
+ assets,
+ abc.txt
+}
diff --git a/include/msg.h b/include/msg.h
index 03cf4b0..7320520 100644
--- a/include/msg.h
+++ b/include/msg.h
@@ -20,7 +20,6 @@
#define __MSG_H
#define PARTIALS "partials"
-#define ASSETS "assets"
#define CONFIG_FILE "config.cfg"
#define BASE_TEMPLATE "base.html"
diff --git a/src/msg.c b/src/msg.c
index d0b1639..0b34e93 100644
--- a/src/msg.c
+++ b/src/msg.c
@@ -136,10 +136,31 @@ run(void)
return EXIT_FAILURE;
}
- char *assets_directory;
- asprintf(&assets_directory, "%s/%s", msg->base_directory, ASSETS);
- nftw(assets_directory, copy_recursively, 64, FTW_PHYS | FTW_ACTIONRETVAL);
- free(assets_directory);
+ list_t *static_ = get_wrapped(list_find_corresponding_value_from_ptr_wrapper(
+ config->keys, config->array_values, "static"));
+
+ if (static_ == NULL) {
+ printf("Could not find resources in config.cfg\n");
+ return EXIT_FAILURE;
+ }
+
+ for (size_t i = 0; i < static_->size; i++) {
+ ptr_wrapper_t *value = list_get(static_, i);
+ char *path = NULL;
+ asprintf(&path, "%s/%s", msg->base_directory, (char *) value->ptr);
+
+ struct stat path_stat;
+ stat(path, &path_stat);
+
+ if (S_ISREG(path_stat.st_mode))
+ copy_recursively(path, NULL, FTW_F, NULL);
+ else if (S_ISDIR(path_stat.st_mode)) {
+ printf("%s\n", path);
+ nftw(path, copy_recursively, 64, FTW_PHYS | FTW_ACTIONRETVAL);
+ }
+
+ free(path);
+ }
list_t *resources
= get_wrapped(list_find_corresponding_value_from_ptr_wrapper(