aboutsummaryrefslogtreecommitdiff
path: root/src/datacache/plugin_datacache_sqlite.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/datacache/plugin_datacache_sqlite.c')
-rw-r--r--src/datacache/plugin_datacache_sqlite.c24
1 files changed, 2 insertions, 22 deletions
diff --git a/src/datacache/plugin_datacache_sqlite.c b/src/datacache/plugin_datacache_sqlite.c
index 5493dbb90..63f8cbd67 100644
--- a/src/datacache/plugin_datacache_sqlite.c
+++ b/src/datacache/plugin_datacache_sqlite.c
@@ -346,35 +346,15 @@ libgnunet_plugin_datacache_sqlite_init (void *cls)
346 struct Plugin *plugin; 346 struct Plugin *plugin;
347 char *fn; 347 char *fn;
348 char *fn_utf8; 348 char *fn_utf8;
349 int fd;
350 sqlite3 *dbh; 349 sqlite3 *dbh;
351 char *tmpl;
352 const char *tmpdir;
353 char *emsg; 350 char *emsg;
354 351
355 tmpdir = getenv ("TMPDIR"); 352 fn = GNUNET_DISK_mktemp ("gnunet-datacache");
356 tmpdir = tmpdir ? tmpdir : "/tmp"; 353 if (fn == NULL)
357
358#define TEMPLATE "/gnunet-dstoreXXXXXX"
359 tmpl = GNUNET_malloc (strlen (tmpdir) + sizeof (TEMPLATE) + 1);
360 strcpy (tmpl, tmpdir);
361 strcat (tmpl, TEMPLATE);
362#undef TEMPLATE
363#ifdef MINGW
364 fn = (char *) GNUNET_malloc (MAX_PATH + 1);
365 plibc_conv_to_win_path (tmpl, fn);
366 GNUNET_free (tmpl);
367#else
368 fn = tmpl;
369#endif
370 fd = mkstemp (fn);
371 if (fd == -1)
372 { 354 {
373 GNUNET_break (0); 355 GNUNET_break (0);
374 GNUNET_free (fn);
375 return NULL; 356 return NULL;
376 } 357 }
377 CLOSE (fd);
378 fn_utf8 = GNUNET_STRINGS_to_utf8 (fn, strlen (fn), 358 fn_utf8 = GNUNET_STRINGS_to_utf8 (fn, strlen (fn),
379#ifdef ENABLE_NLS 359#ifdef ENABLE_NLS
380 nl_langinfo (CODESET) 360 nl_langinfo (CODESET)