remove some mutt_mktemp
[apps/madmutt.git] / imap / message.c
index 1f634af..6c1fce7 100644 (file)
 #include <lib-lib/lib-lib.h>
 
 #include <lib-ui/curses.h>
+#include <lib-mx/mx.h>
+#include <lib-mx/hcache.h>
 
 #include "mutt.h"
 #include "imap_private.h"
 #include "message.h"
-#include "mx.h"
-#include "hcache.h"
 
 #ifdef HAVE_PGP
 #include "pgp.h"
@@ -83,13 +83,13 @@ int imap_read_headers (IMAP_DATA * idata, int msgbegin, int msgend)
 
   /* instead of downloading all headers and then parsing them, we parse them
    * as they come in. */
-  mutt_mktemp (tempfile);
-  if (!(fp = safe_fopen (tempfile, "w+"))) {
-    mutt_error (_("Could not create temporary file %s"), tempfile);
-    mutt_sleep (2);
+  fp = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL);
+  if (!fp) {
+    mutt_error(_("Could not create temporary file"));
+    mutt_sleep(2);
     return -1;
   }
-  unlink (tempfile);
+  unlink(tempfile);
 
   /* make sure context has room to hold the mailbox */
   while ((msgend) >= idata->ctx->hdrmax)
@@ -376,12 +376,11 @@ int imap_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno)
     mutt_message _("Fetching message...");
 
   cache->uid = HEADER_DATA (h)->uid;
-  mutt_mktemp (path);
-  cache->path = m_strdup(path);
-  if (!(msg->fp = safe_fopen (path, "w+"))) {
-    p_delete(&cache->path);
+  msg->fp = m_tempfile(path, sizeof(path), NONULL(Tempdir), NULL);
+  if (!msg->fp) {
     return -1;
   }
+  cache->path = m_strdup(path);
 
   /* mark this header as currently inactive so the command handler won't
    * also try to update it. HACK until all this code can be moved into the