bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting a good temporary directory


From: Simon Josefsson
Subject: Re: Getting a good temporary directory
Date: Mon, 24 Sep 2012 13:26:43 +0200
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/23.3 (gnu/linux)

Reuben Thomas <address@hidden> writes:

> I'm trying to rewrite some code that uses tmpname to use mkstemp.
> Unfortunately, I can't see a simple way to get a good location for
> temporary files independently of tmpname. P_tmpdir is obsolescent and
> optional, and it seems that there's no other POSIX way to get at "the
> path commonly known as /tmp".

Am I missing something, or why couldn't you use getenv("TMPDIR")?  It is
defined by POSIX:

http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html

If it is not available, falling back to "/tmp" would not be an error as
far as I can tell.  POSIX environments should have TMPDIR defined.

/Simon



reply via email to

[Prev in Thread] Current Thread [Next in Thread]