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: Reuben Thomas
Subject: Re: Getting a good temporary directory
Date: Mon, 24 Sep 2012 15:03:26 +0100

On 24 September 2012 12:26, Simon Josefsson <address@hidden> wrote:
> 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.

That's interesting: on my Ubuntu system I can find no trace of TMPDIR
in the system settings or default user settings, and I therefore
mistakenly assumed it wouldn't help. I imagine TMPDIR is not set
because /tmp is guaranteed by the FHS, so your scheme certainly covers
this case too.

Thanks!

-- 
http://rrt.sc3d.org



reply via email to

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