about summary refs log tree commit diff
path: root/export.c
diff options
context:
space:
mode:
Diffstat (limited to 'export.c')
-rw-r--r--export.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/export.c b/export.c
index 3e87521..b1f63b8 100644
--- a/export.c
+++ b/export.c
@@ -34,6 +34,12 @@ static const char *uidPath(uint32_t uid, const char *type) {
 	return buf;
 }
 
+static const char *messagePath(const char *messageID, const char *type) {
+	static char buf[PATH_MAX];
+	snprintf(buf, sizeof(buf), "message/%s.%s", messageID, type);
+	return buf;
+}
+
 static void flatten(struct List *flat, struct List nested) {
 	for (size_t i = 0; i < nested.len; ++i) {
 		if (nested.ptr[i].type == List) {
@@ -253,6 +259,10 @@ void exportData(struct List items) {
 		|| fclose(file);
 	if (error) err(EX_IOERR, "%s", path);
 
+	const char *dest = messagePath(envelope.messageID, "mbox");
+	error = link(path, dest);
+	if (error) err(EX_CANTCREAT, "%s", dest);
+
 	path = uidPath(uid, "html");
 	file = fopen(path, "w");
 	if (!file) err(EX_CANTCREAT, "%s", path);