bl/mkdtemp.c
author ali <ali@juiblex.co.uk>
Sun May 26 22:30:38 2013 +0100 (2013-05-26)
changeset 65 1b0e1aaf1800
permissions -rw-r--r--
Break print_pending() and check_for_mismatched_quotes() out
     1 #include <stdlib.h>
     2 #include <string.h>
     3 #include <errno.h>
     4 #include <glib.h>
     5 #include <glib/gstdio.h>
     6 #include "mkdtemp.h"
     7 
     8 #if !HAVE_G_MKDTEMP
     9 char *g_mkdtemp(char *template)
    10 {
    11 #if !defined(WIN32) && HAVE_MKDTEMP
    12     return mkdtemp(template);
    13 #else
    14     char *s;
    15     for(;;)
    16     {
    17 	s=g_strdup(template);
    18 	mktemp(s);
    19 	if (!*s)
    20 	{
    21 	    g_free(s);
    22 	    errno=EEXIST;
    23 	    return NULL;
    24 	}
    25 	if (g_mkdir(s,0700)>=0)
    26 	{
    27 	    strcpy(template,s);
    28 	    g_free(s);
    29 	    return template;
    30 	}
    31 	g_free(s);
    32     }
    33 #endif	/* !defined(WIN32) && HAVE_MKDTEMP */
    34 }
    35 #endif	/* !HAVE_G_MKDTEMP */