mkstemp() implementation for win32

前端 未结 3 618
甜味超标
甜味超标 2020-12-31 11:17

Can anybody point me to the code that implements mkstemp() (C/C++) on Win32, or very close analog.

Must be race-free.

It\'s supposed to look like



        
3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-31 11:46

    You can use _mktemp_s() function, or any of it's variations:

    errno_t _mktemp_s(
       char *template,
       size_t sizeInChars
    );
    

    where:

    • template: File name pattern.
    • sizeInChars: Size of the buffer in single-byte characters in _mktemp_s; wide characters in _wmktemp_s, including the null terminator.

    It returns 0 on success, and an error code on failure. Note that the function modifyes the template argument.

提交回复
热议问题