3

I am looking for some direction in finding a Windows function that acts similarly to

mkstemp(char*) 

does in Linux, i.e., creates unique filename, opens file, and returns file descriptor. I have come across _mktemp_s, but that only incorporates a small part of what I need. Any suggestions/information in the implementation of a Windows style mkstemp() function would be greatly appreciated.

Armali
  • 18,255
  • 14
  • 57
  • 171
lchristina26
  • 205
  • 5
  • 20
  • The following answer implements what you're looking for: https://stackoverflow.com/a/76880432/11398236 – barnabas Aug 11 '23 at 04:17

1 Answers1

1

If WINAPI is permitted then the function GetTempFileName() does almost everything required, with the exception that it does not return a file descriptor. This function could be wrapped in a function to achieve the exact behaviour required.

hmjd
  • 120,187
  • 20
  • 207
  • 252