WHERE char *SpamSeparator;
WHERE struct MbTable *StatusChars;
WHERE char *StatusFormat;
-WHERE char *Tmpdir;
WHERE struct MbTable *ToChars;
WHERE struct MbTable *FlagChars;
WHERE char *Trash;
#include "message.h"
#include "string2.h"
+char *Tmpdir; /**< Temporary directory path */
+
/* these characters must be escaped in regular expressions */
static const char rx_special_chars[] = "^.[$()|*+?{\\";
return 0;
}
+/**
+ * mutt_file_mkstemp_full - Create temporary file safely
+ * @param file Temp filename
+ * @param line Line number of caller
+ * @param func Function name
+ * @retval ptr FILE handle
+ * @retval NULL Error, see errno
+ *
+ * Create and immediately unlink a temp file using mkstemp().
+ */
+FILE *mutt_file_mkstemp_full(const char *file, int line, const char *func)
+{
+ char name[PATH_MAX];
+
+ int n = snprintf(name, sizeof(name), "%s/neomutt-XXXXXX", NONULL(Tmpdir));
+ if (n < 0)
+ return NULL;
+
+ int fd = mkstemp(name);
+ if (fd == -1)
+ return NULL;
+
+ FILE *fp = fdopen(fd, "w+");
+
+ if (unlink(name) && (errno != ENOENT))
+ return NULL;
+
+ MuttLogger(0, file, line, func, 1, "created temp file '%s'\n", name);
+ return fp;
+}
+
/**
* mutt_file_decrease_mtime - Decrease a file's modification time by 1 second
* @param f Filename
#include <time.h>
struct stat;
+extern char *Tmpdir;
/* Flags for mutt_file_read_line() */
#define MUTT_CONT (1 << 0) /**< \-continuation */
int mutt_file_fsync_close(FILE **f);
int mutt_file_lock(int fd, int excl, int timeout);
int mutt_file_mkdir(const char *path, mode_t mode);
+FILE * mutt_file_mkstemp_full(const char *file, int line, const char *func);
+#define mutt_file_mkstemp() mutt_file_mkstemp_full(__FILE__, __LINE__, __func__)
int mutt_file_open(const char *path, int flags);
size_t mutt_file_quote_filename(char *d, size_t l, const char *f);
char * mutt_file_read_keyword(const char *file, char *buffer, size_t buflen);