toaruos/libc/stdio/tmpfile.c

16 lines
231 B
C
Raw Normal View History

2018-06-25 06:11:33 +03:00
#include <stdio.h>
#include <unistd.h>
FILE * tmpfile(void) {
static int tmpfile_num = 1;
char tmp[100];
sprintf(tmp, "/tmp/tmp%d.%d", getpid(), tmpfile_num++);
FILE * out = fopen(tmp, "w+b");
unlink(tmp);
return out;
}