- strncpy (buf, filename, sizeof (buf));
- strncpy (tmpfile, basename (filename), sizeof (tmpfile));
- mutt_adv_mktemp ((const char*) dirname (buf), tmpfile, sizeof (tmpfile));
- debug_print (1, ("Opening %s\n", tmpfile));
- if (!(ofp = fopen (tmpfile, "w"))) {
- fclose (ifp);
- mutt_error (_("Unable to open %s for writing"), tmpfile);
+ m_strcpy(buf, sizeof(buf), filename);
+ ofp = m_tempfile(tmpf, sizeof(tmpf), dirname(buf), filename);
+ if (!ofp) {
+ m_fclose(&ifp);
+ mutt_error (_("Unable to open %s for writing"), tmpf);