Improve tmpfile api (#114)

This commit is contained in:
Justine Tunney 2021-03-07 21:07:16 -08:00
parent 2bd1e72d5a
commit 816b0e1851
3 changed files with 56 additions and 8 deletions

View file

@ -10,6 +10,7 @@
#include "libc/calls/calls.h"
#include "libc/calls/weirdtypes.h"
#include "libc/errno.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/temp.h"
#include "libc/sysv/consts/exit.h"
#include "libc/time/struct/tm.h"
@ -114,12 +115,9 @@
#define LUA_TMPNAMBUFSIZE 32
#if !defined(LUA_TMPNAMTEMPLATE)
#define LUA_TMPNAMTEMPLATE "/tmp/lua_XXXXXX"
#endif
#define lua_tmpnam(b,e) { \
strcpy(b, LUA_TMPNAMTEMPLATE); \
strcpy(b, kTmpPath); \
strcat(b, "lua_XXXXXX"); \
e = mkstemp(b); \
if (e != -1) close(e); \
e = (e == -1); }