2 * Acess2 POSIX Emulation Layer
8 #include <unistd.h> // mktemp
9 #include <stdlib.h> // mkstemp
10 #include <string.h> // str*
14 int mkstemp(char *template)
16 size_t tpl_len = strlen(template);
21 if( strcmp(template+tpl_len-6, "XXXXXX") != 0 ) {
26 for( int i = 0; i < 1000000; i ++ )
28 sprintf(template+tpl_len-6, "%06d", i);
29 int fd = open(template, O_EXCL|O_CREAT, 0600);
30 if(fd == -1) continue ;
40 char *mktemp(char *template)
42 int fd = mkstemp(template);