#ifdef USE_SIDEBAR
WHERE struct ListHead SidebarWhitelist INITVAL(STAILQ_HEAD_INITIALIZER(SidebarWhitelist));
#endif
+WHERE struct ListHead TempAttachmentsList INITVAL(STAILQ_HEAD_INITIALIZER(TempAttachmentsList));
WHERE struct ListHead UserHeader INITVAL(STAILQ_HEAD_INITIALIZER(UserHeader));
/* Lists of AttachMatch */
#include "keymap.h"
#include "mailbox.h"
#include "menu.h"
+#include "mutt_attach.h"
#include "mutt_curses.h"
#include "mutt_history.h"
#include "mutt_logging.h"
if (repeat_error && ErrorBufMessage)
puts(ErrorBuf);
main_exit:
+ mutt_unlink_temp_attachments();
mutt_list_free(&queries);
crypto_module_free();
mutt_window_free();
rfc1524_free_entry(&entry);
if (fp && tempfile[0])
{
- /* Restore write permission so mutt_file_unlink can open the file for writing */
- mutt_file_chmod_add(tempfile, S_IWUSR);
- mutt_file_unlink(tempfile);
+ /* add temporary file to TempAttachmentsList to be deleted on exit */
+ mutt_add_temp_attachment(tempfile);
}
else if (unlink_tempfile)
unlink(tempfile);
return 0;
}
}
+
+/**
+ * mutt_add_temp_attachment - Add file to list of temporary attachments
+ * @param filename filename with full path
+ */
+void mutt_add_temp_attachment(char *filename)
+{
+ mutt_list_insert_tail(&TempAttachmentsList, mutt_str_strdup(filename));
+}
+
+/**
+ * mutt_unlink_temp_attachments - Delete all temporary attachments
+ */
+void mutt_unlink_temp_attachments(void)
+{
+ struct ListNode *np = NULL;
+
+ STAILQ_FOREACH(np, &TempAttachmentsList, entries)
+ {
+ mutt_file_chmod_add(np->data, S_IWUSR);
+ mutt_file_unlink(np->data);
+ }
+
+ mutt_list_free(&TempAttachmentsList);
+}
int mutt_print_attachment(FILE *fp, struct Body *a);
int mutt_save_attachment(FILE *fp, struct Body *m, char *path, int flags, struct Email *e);
+/* small helper functions to handle temporary attachment files */
+void mutt_add_temp_attachment(char *filename);
+void mutt_unlink_temp_attachments(void);
+
#endif /* MUTT_MUTT_ATTACH_H */