<<< Date Index >>>     <<< Thread Index >>>

Re: mutt_adv_mktemp() ?



On Wednesday, October  4 at 07:45 AM, quoth Rocco Rutte:
The nametemplate should be used. The only effect is that mutt adds the extension on its own because mktemp() and mkstemp() cannot replace a sequence within a string but only at the end (...which is why we cannot use mkstemp() all over the place).

Two points:

1. For extensions, there is mkstemps(), though it is slightly less portable.

2. More portably, what's wrong with:

   char tmpfile[POSIX_PATH_MAX] = "/tmp/muttXXXXXX";
   char tmpfile2[POSIX_PATH_MAX];
   char *extension = "foo";
   sprintf(tmpfile2, "%s.%s", tmpfile, extension);
   fd = mkstemp(tmpfile);
   rename(tmpfile, tmpfile2);

~Kyle
--
Most truths are so naked that people feel sorry for them and cover them up, at least a little bit.
                                                  -- Edward R. Murrow

Attachment: pgpFWgmTaY3GV.pgp
Description: PGP signature