gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r21864 - gnunet/src/util


From: gnunet
Subject: [GNUnet-SVN] r21864 - gnunet/src/util
Date: Mon, 11 Jun 2012 00:41:48 +0200

Author: grothoff
Date: 2012-06-11 00:41:48 +0200 (Mon, 11 Jun 2012)
New Revision: 21864

Modified:
   gnunet/src/util/disk.c
Log:
-LRN: fix mkdtemp on W32

Modified: gnunet/src/util/disk.c
===================================================================
--- gnunet/src/util/disk.c      2012-06-10 22:40:45 UTC (rev 21863)
+++ gnunet/src/util/disk.c      2012-06-10 22:41:48 UTC (rev 21864)
@@ -440,6 +440,36 @@
   return fn;
 }
 
+#if WINDOWS
+static char *
+mkdtemp (char *fn)
+{
+  char *random_fn;
+  char *tfn;
+  while (1)
+  {
+    tfn = GNUNET_strdup (fn);
+    random_fn = _mktemp (tfn);
+    if (NULL == random_fn)
+    {
+      GNUNET_free (tfn);
+      return NULL;
+    }
+    /* FIXME: assume fn to be UTF-8-encoded and do the right thing */
+    if (0 == CreateDirectoryA (tfn, NULL))
+    {
+      DWORD error = GetLastError ();
+      GNUNET_free (tfn);
+      if (ERROR_ALREADY_EXISTS == error)
+        continue;
+      return NULL;
+    }
+    break;
+  }
+  strcpy (fn, tfn);
+  return fn;
+}
+#endif
 
 /**
  * Create an (empty) temporary directory on disk.  If the given name is not




reply via email to

[Prev in Thread] Current Thread [Next in Thread]