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

Re: mutt_adv_mktemp() ?



On Wednesday, October  4 at 10:26 AM, quoth Kyle Wheeler:
2. More portably, what's wrong with:

Erp, the ordering on that was wrong.

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

Tada!

~Kyle
--
Those who will not reason, are bigots, those who cannot, are fools, and those who dare not, are slaves.
                                          -- George Gordon Noel Byron

Attachment: pgpUdqQaQiaRD.pgp
Description: PGP signature