aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2010-01-14 03:01:53 +0800
committerMilan Crha <mcrha@redhat.com>2010-01-14 03:01:53 +0800
commit4d114e022ca38e7aeb6cc2cc3715f7dca69c82a6 (patch)
treeb1cc0dc426b767d9e1421512563e034f01971ad9 /e-util
parent8b13842910a5f006d31cd347e7c5af265a4768ce (diff)
downloadgsoc2013-evolution-4d114e022ca38e7aeb6cc2cc3715f7dca69c82a6.tar
gsoc2013-evolution-4d114e022ca38e7aeb6cc2cc3715f7dca69c82a6.tar.gz
gsoc2013-evolution-4d114e022ca38e7aeb6cc2cc3715f7dca69c82a6.tar.bz2
gsoc2013-evolution-4d114e022ca38e7aeb6cc2cc3715f7dca69c82a6.tar.lz
gsoc2013-evolution-4d114e022ca38e7aeb6cc2cc3715f7dca69c82a6.tar.xz
gsoc2013-evolution-4d114e022ca38e7aeb6cc2cc3715f7dca69c82a6.tar.zst
gsoc2013-evolution-4d114e022ca38e7aeb6cc2cc3715f7dca69c82a6.zip
Bug #606874 - mktemp disabled in latest glibc-2.11.90-8
Diffstat (limited to 'e-util')
-rw-r--r--e-util/e-mktemp.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/e-util/e-mktemp.c b/e-util/e-mktemp.c
index 509b312ee8..15b566877e 100644
--- a/e-util/e-mktemp.c
+++ b/e-util/e-mktemp.c
@@ -167,7 +167,7 @@ gchar *
e_mktemp (const gchar *template)
{
GString *path;
- gchar *ret;
+ gint fd;
path = get_dir (TRUE);
if (!path)
@@ -179,10 +179,14 @@ e_mktemp (const gchar *template)
else
g_string_append (path, "unknown-XXXXXX");
- ret = mktemp (path->str);
- g_string_free(path, ret == NULL);
+ fd = g_mkstemp (path->str);
- return ret;
+ if (fd != -1) {
+ close (fd);
+ g_unlink (path->str);
+ }
+
+ return g_string_free (path, fd == -1);
}
gint
@@ -226,7 +230,17 @@ e_mkdtemp (const gchar *template)
#ifdef HAVE_MKDTEMP
tmpdir = mkdtemp (path->str);
#else
- tmpdir = mktemp (path->str);
+ {
+ gint fd = g_mkstemp (path->str);
+ if (fd == -1) {
+ tmpdir = NULL;
+ } else {
+ close (fd);
+ tmpdir = path->str;
+ g_unlink (tmpdir);
+ }
+ }
+
if (tmpdir) {
if (g_mkdir (tmpdir, S_IRWXU) == -1)
tmpdir = NULL;