How to safely and portably create temp file AND get its name

Viewed 67

I'm working with some legacy code which passes around the name of a file. I'd like to create a temp file and give the legacy code the name of the file to be opened later using legacy functions. tmpnam is unsafe due to the race case between getting the name and creating the file. mkdir isn't portable to Windows and doesn't let me have the name of the file. How can I create a temp file safely, portably, and with retention of file name?

1 Answers
Related