1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/bl/mkdtemp.c Sat Feb 18 23:07:09 2012 +0000
1.3 @@ -0,0 +1,35 @@
1.4 +#include <stdlib.h>
1.5 +#include <string.h>
1.6 +#include <errno.h>
1.7 +#include <glib.h>
1.8 +#include <glib/gstdio.h>
1.9 +#include "mkdtemp.h"
1.10 +
1.11 +#if !HAVE_G_MKDTEMP
1.12 +char *g_mkdtemp(char *template)
1.13 +{
1.14 +#if !defined(WIN32) && HAVE_MKDTEMP
1.15 + return mkdtemp(template);
1.16 +#else
1.17 + char *s;
1.18 + for(;;)
1.19 + {
1.20 + s=g_strdup(template);
1.21 + mktemp(s);
1.22 + if (!*s)
1.23 + {
1.24 + g_free(s);
1.25 + errno=EEXIST;
1.26 + return NULL;
1.27 + }
1.28 + if (g_mkdir(s,0700)>=0)
1.29 + {
1.30 + strcpy(template,s);
1.31 + g_free(s);
1.32 + return template;
1.33 + }
1.34 + g_free(s);
1.35 + }
1.36 +#endif /* !defined(WIN32) && HAVE_MKDTEMP */
1.37 +}
1.38 +#endif /* !HAVE_G_MKDTEMP */