From the DMD versioning talk I came to the changelog for 2.060 and found #7537 
fixed (http://d.puremagic.com/issues/show_bug.cgi?id=7537), which I had to work 
around before.
Seeing as this is a basic C library function, I was wondering if D could have a 
modern version. Looking at the MSDN it seems, like Microsoft added quite a few 
functions to the Visual Studio C Runtime over the years:

           directory         generates  security enhanced¹

tmpnam_s   current working²  filename   yes
tmpnam     current working²  filename   no
_tempnam   TMP/user defined  filename   no
tmpfile_s  system root       FILE ptr³  yes
tmpfile    system root       FILE ptr³  no

¹ = http://msdn.microsoft.com/en-us/library/8ef0s5kh(v=vs.80).aspx
² = functions that use the current working directory require that you set it to 
the desired location first, which makes them difficult to use in a library, 
especially since the cwd is attached to the process and other user threads may 
not be prepared for sudden changes
³ = these files are automagically deleted when the process exists

It looks like "GetTempFileName" 
(http://msdn.microsoft.com/en-us/library/windows/desktop/aa364991(v=vs.85).aspx)
 is the actual operating system function that is used by the C Runtime. I'd 
like to see a cross-platform solution that uses GetTempFileName on Windows. The 
result should be usable as a D File. It is currently impossible to create a 
std.stream wrapped around a File.tmpfile, because it returns a C FILE pointer 
(and until 2.060, because of the administrator rights issue on Windows).
On Unix mkstemp 
(http://pubs.opengroup.org/onlinepubs/009695399/functions/mkstemp.html) looks 
like a pretty similar function as well. Unlike the Windows equivalent it 
returns an open file descriptor/handle in addition to the file name. In both 
cases the user has to delete the files after use. To me it looks they are 
flexible enough to write up set of cross-platform (Windows/MacOS 
X/Linux/FreeBSD) functions for temporary files.

The question is: Is the problem solved with the fixed bug, or is there interest 
in D functions for temporary files?

-- 
Marco

Reply via email to