From 7f0cb741c77f74a48ffd10a1e7d36ff2adf95f03 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 7 Jan 2014 22:39:35 +0000 Subject: Implement POSIX-compliant mktemp for WIN32 --- win32/mingw.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'win32') diff --git a/win32/mingw.c b/win32/mingw.c index b9f720e1a..70a8cb611 100644 --- a/win32/mingw.c +++ b/win32/mingw.c @@ -435,6 +435,20 @@ unsigned int sleep (unsigned int seconds) return 0; } +/* + * Windows' mktemp returns NULL on error whereas POSIX always returns the + * template and signals an error by making it an empty string. + */ +#undef mktemp +char *mingw_mktemp(char *template) +{ + if ( mktemp(template) == NULL ) { + template[0] = '\0'; + } + + return template; +} + int mkstemp(char *template) { char *filename = mktemp(template); -- cgit v1.2.3-55-g6feb