From b6a1a2ff65a5755d801654f7a41b4854082c96e1 Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Wed, 14 Apr 2010 06:54:49 +0200 Subject: win32: add mkstemp() --- include/mingw.h | 2 +- win32/mingw.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/mingw.h b/include/mingw.h index 1c923089f..75f70e5ef 100644 --- a/include/mingw.h +++ b/include/mingw.h @@ -129,7 +129,7 @@ int fdprintf(int fd, const char *format, ...); NOIMPL(clearenv,void); IMPL(mingw_getenv,char*,NULL,const char *name UNUSED_PARAM); -NOIMPL(mkstemp,char *template UNUSED_PARAM); +int mkstemp(char *template); IMPL(realpath,char *,NULL,const char *path UNUSED_PARAM, char *resolved_path UNUSED_PARAM); NOIMPL(setenv,const char *name UNUSED_PARAM, const char *value UNUSED_PARAM, int replace UNUSED_PARAM); IMPL(unsetenv,void,,const char *env UNUSED_PARAM); diff --git a/win32/mingw.c b/win32/mingw.c index b92fa82a5..3611872ec 100644 --- a/win32/mingw.c +++ b/win32/mingw.c @@ -7,3 +7,11 @@ unsigned int sleep (unsigned int seconds) Sleep(seconds*1000); return 0; } + +int mkstemp(char *template) +{ + char *filename = mktemp(template); + if (filename == NULL) + return -1; + return open(filename, O_RDWR | O_CREAT, 0600); +} -- cgit v1.2.3-55-g6feb