From: Reinhard M. <ma...@tc...> - 2006-01-18 10:38:42
|
Hi, On Tue, 17 Jan 2006 at 14:23, Techentin, Robert W. wrote: > [...] But, you can't ever get the file name back from the open file > handle. if that was true, how would you ever be able to unlink() a file that was generated by mkstemp() when you don't need it anymore? The version of the mkstemp() manpage I have at hand says that the file name is returned by overwriting the X'es in the template string you pass to it: --- snip --- DESCRIPTION The mkstemp() function generates a unique temporary file name from template. The last six characters of template must be XXXXXX and these are replaced with a string that makes the filename unique. The file is then created with mode read/write and permissions 0666 (glibc 2.0.6 and earlier), 0600 (glibc 2.0.7 and later). Since it will be modified, template must not be a string constant, but should be declared as a character array. The file is opened with the O_EXCL flag, guaranteeing that when mkstemp returns success- fully we are the only user. --- snap --- So I see no reason for not using mkstemp(), and in fact it is being used internally by the Tcl core already. See TclpCreateTempFile() and TclpTempFileName() in unix/tclUnixPipe.c . cu Reinhard |