aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/components.h3
-rw-r--r--include/fs.h24
-rw-r--r--include/render.h3
-rw-r--r--include/site.h3
4 files changed, 29 insertions, 4 deletions
diff --git a/include/components.h b/include/components.h
index c56de77..e65a66a 100644
--- a/include/components.h
+++ b/include/components.h
@@ -57,11 +57,14 @@ struct album {
/* The date of the album is the date of the earliest image */
time_t tstamp;
struct bstree *images;
+ /* Files/dirs that belong to images and which shouldn't be deleted */
+ struct hashmap *preserved;
/* Hashmap with values to be passed to the template */
struct hashmap *map;
/* Vector with hashmaps of images to be passed to the templates */
struct vector *thumbs;
struct vector *previews;
+ size_t images_updated;
};
struct image *image_new(char *src, const struct stat *, struct album *);
diff --git a/include/fs.h b/include/fs.h
index 973d585..218958b 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -1,10 +1,17 @@
#ifndef REVELA_FS_H
#define REVELA_FS_H
-#include <stdio.h>
#include <stdbool.h>
#include <sys/stat.h>
+#include "hashmap.h"
+
+enum nmkdir_res {
+ NMKDIR_ERROR,
+ NMKDIR_NOOP,
+ NMKDIR_CREATED,
+};
+
/*
* Returns a pointer to where the basename of the file is inside path.
*/
@@ -14,7 +21,7 @@ const char *rbasename(const char *path);
* Makes a new directory if it doesn't exist. If there were errors returns
* false, otherwise returns true.
*/
-bool nmkdir(const char *path, struct stat *dstat, bool dry);
+enum nmkdir_res nmkdir(const char *path, struct stat *dstat, bool dry);
#define joinpathb(buf, a, b) sprintf(buf, "%s/%s", a, b)
@@ -42,6 +49,16 @@ int file_is_uptodate(const char *path, const struct timespec *srcmtim);
*/
void setdatetime(const char *path, const struct timespec *mtim);
+bool rmentry(const char *path);
+
+/*
+ * Recursively deletes extaneous files from directory, keeping files in the
+ * preserved hashmap. Returns -1 on error, number of deleted entries on success.
+ * The number is not the total number of files on all subdirectories, but only
+ * the number of files/dirs deleted from the directory pointed by path.
+ */
+ssize_t rmextra(const char *path, struct hashmap *preserved);
+
/*
* Copies file(s) truncating and overwritting the file(s) in the destination
* path if they exist and are not a directory, or creating them if they don't
@@ -49,6 +66,7 @@ void setdatetime(const char *path, const struct timespec *mtim);
* recursively. Only copies the regular files that already exist if their
* timestamps do not match.
*/
-bool filesync(const char *restrict srcpath, const char *restrict dstpath);
+bool filesync(const char *restrict srcpath, const char *restrict dstpath,
+ struct hashmap *preserved);
#endif
diff --git a/include/render.h b/include/render.h
index faa6f73..ff83bab 100644
--- a/include/render.h
+++ b/include/render.h
@@ -19,6 +19,7 @@ struct render {
struct hashmap *common_vars;
/* Modification time for the templates dir */
struct timespec modtime;
+ size_t albums_updated;
bool dry_run;
};
@@ -30,6 +31,8 @@ bool render_make_album(struct render *r, const char *path,
bool render_make_image(struct render *r, const char *path,
const struct image *image);
+bool render_set_album_vars(struct render *, struct album *);
+
bool render_init(struct render *, const char *path, struct site_config *,
struct bstree *albums);
diff --git a/include/site.h b/include/site.h
index 678cd47..6ddac82 100644
--- a/include/site.h
+++ b/include/site.h
@@ -12,7 +12,6 @@
#define SITE_DEFAULT_RESOURCES "/usr/share/revela"
#endif
-#define CSSDIR "css"
#define STATICDIR "static"
#define CONTENTDIR "content"
#define TEMPLATESDIR "templates"
@@ -31,6 +30,8 @@ struct site {
*/
size_t rel_content_dir;
struct bstree *albums;
+ /* Files/dirs that belong to albums and which shouldn't be deleted */
+ struct hashmap *album_dirs;
struct render render;
bool dry_run;
};