From: Maurizio M. <Mau...@sp...> - 2014-09-28 16:04:07
|
Perfect, You eventually landed on using _mktemp_s which is what described in the first link I provided you with and is what I was hoping for Windows. Thanks a lot, Maurizio From: Gustaf Neumann [mailto:ne...@wu...] Sent: 28 September 2014 16:56 To: nav...@li... Subject: Re: [naviserver-devel] no mkstemp() on Windows, use TclpCreateTempFile()? mktemp() is useful, but is in in the unix world general strongly discouraged in favor of mkstemp(). The problem with mktemp() + file-create is, that in the time between the pathname is constructed and the file is created, another process might have created a file with the same name. mkstemp() is actually guaranteed to create a unique file. For the time being, i've commited a small implementation of mkstemp() for windows, that opens files with O_EXCL, which should be a first approximation. However, it's not tested, please test it and don't be surprised, if it needs more tweaks (maybe my flag settings are too restrictive). all the best -g Am 27.09.14 16:11, schrieb Andrew Piskorski: On Fri, Sep 26, 2014 at 08:55:37PM +0200, Maurizio Martignano wrote: Dear Andrew and Gustaf, I believe this is the function you are looking for: http://msdn.microsoft.com/en-us/library/ms235413.aspx No, it is not. mktemp and friends merely generate a file name, while mkstemp also opens the file and returns a file handle. So yes, you could use mktemp as part of an implementation of mkstemp, but they do are not replacements for each other. |