1 /* taken from XFCE's Xarchiver, made to work without glib for mutt */
9 /* mkdtemp fuction for systems which don't have one */
10 char *mkdtemp (char *tmpl)
12 static const char LETTERS[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
13 static long value = 0;
19 if (len < 6 || strcmp (&tmpl[len - 6], "XXXXXX") != 0)
25 value += ((long) time (NULL)) ^ getpid ();
27 for (i = 0; i < 7 ; ++i, value += 7777)
29 /* fill in the random bits */
30 for (j = 0, v = value; j < 6; ++j)
31 tmpl[(len - 6) + j] = LETTERS[v % 62]; v /= 62;
33 /* try to create the directory */
34 if (mkdir (tmpl, 0700) == 0)
36 else if (errno != EEXIST)