>>I'm looking for a C-function that will open a file with a unique
>>filename. This may well be a RTFM but the FM is so big!
>Check the functions tempnam() and tmpnam, these allow you to create
>unique filenames. Then just use those to open a file for temporary
>access. Also, there is a function tmpfile() which will return a
>unique file descriptor. (I think that this function is only availible
>with ANSI C, though?) Hope this helps some!
if you're using SunOS 4.x.x, your best bet is to use mktemp(),
but FILE *tmpfile() and char *tmpnam() are ANSI, and _should_ work
on everything.
from TFM (SunOS 4.1.3)
mkstemp() makes
the same replacement to the template but returns a file
descriptor for the template file open for reading and writ-
ing. mkstemp() avoids the race between testing whether the
file exists and opening it for use.
So mkstemp() is the safest bet to avoid any race conditions ...
--
Carl Brewer Ph :61-9-380-1893 | #include \
Systems/Network Officer, Reid Library Fax:61-9-380-1012 | <std_disclaimer.h>
Merlin, where are you? Call your Dragon, to weave a mist .... "BEABLE"