2 * Acess2 POSIX Emulation Layer
8 #include <unistd.h> // mktemp
9 #include <stdlib.h> // mkstemp
11 #include <string.h> // str*
15 int mkstemp(char *template)
17 size_t tpl_len = strlen(template);
22 if( strcmp(template+tpl_len-6, "XXXXXX") != 0 ) {
27 for( int i = 0; i < 1000000; i ++ )
29 snprintf(template+tpl_len-6, 6+1, "%06d", i);
30 int fd = open(template, O_EXCL|O_CREAT, 0600);
31 if(fd == -1) continue ;
41 char *mktemp(char *template)
43 int fd = mkstemp(template);