[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: tmpnam(e)
- From: Reuben Thomas <rrt@...>
- Date: Sun, 6 May 2001 19:19:50 +0100 (BST)
> On the other hand, how do you think things like tmpfile() are created? In
> WATCOM C/C++ it appears to just call some variation of tmpname() to pick a
> filename,
But glibc is rather less broken than that...in any case, a correct
implementation is tricky, and best left to the library vendor.
> It appears as though tmpfile() is an ANSI call. In WATCOM C/C++ there is no
> mkstemp(), however mktemp() exists and tries to create a unique file from a
> template.
tmpfile would be an alternative, but has other problems, since you can't
keep the file after you close it.
> mktemp() doesn't seem particularly universal either since a single
> process instance basically can make at most 26 such files (in DOS) and there is no
> guarantee that these files haven't been created beforehand.
mktemp is basically the same as mkstemp, but apparently not in your
implementation. Many implementations are (apparently) similarly broken to
yours.
> Well, it seems to me that it would be best to supply a function call that is a best
> replacement of the prior solution. I.e., use tmpfile(). If that does not exist on
> all systems, then some C compilers implementation of tmpfile() could be used.
tmpfile does a slightly different job, although admittedly it can and should
be implemented safely. But it's only useful in the case where you want a
scratch file which is later deleted.
--
http://sc3d.org/rrt/ | competent, a. underpromoted