summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Torri <vincent dot torri at gmail dot com>2015-10-15 14:41:04 +0200
committerNicolas Aguirre <aguirre.nicolas@gmail.com>2015-11-10 08:32:49 +0100
commit65b71bcea72322f42c12d5688320c3b385c0605e (patch)
tree221b6501f7fb3fa058bf2efe21ef15b5d728d299
parent65c82ea15cb53473b4de398ee61a6c3b7047fc20 (diff)
Eina: use eina_file_path_join() and eina_environment_tmp_get() when needed
-rw-r--r--src/lib/eina/eina_file_common.c29
1 files changed, 4 insertions, 25 deletions
diff --git a/src/lib/eina/eina_file_common.c b/src/lib/eina/eina_file_common.c
index 4ffd2edcc3..b86c39b321 100644
--- a/src/lib/eina/eina_file_common.c
+++ b/src/lib/eina/eina_file_common.c
@@ -920,20 +920,8 @@ eina_file_mkstemp(const char *templatename, Eina_Tmpstr **path)
920 mode_t old_umask; 920 mode_t old_umask;
921#endif 921#endif
922 922
923#ifndef HAVE_EVIL 923 len = eina_file_path_join(buffer, sizeof(buffer),
924#if defined(HAVE_GETUID) && defined(HAVE_GETEUID) 924 eina_environment_tmp_get(), templatename);
925 if (getuid() == geteuid())
926#endif
927 {
928 tmpdir = getenv("TMPDIR");
929 if (!tmpdir) tmpdir = getenv("XDG_RUNTIME_DIR");
930 }
931 if (!tmpdir) tmpdir = "/tmp";
932#else
933 tmpdir = (char *)evil_tmpdir_get();
934#endif /* ! HAVE_EVIL */
935
936 len = snprintf(buffer, PATH_MAX, "%s/%s", tmpdir, templatename);
937 925
938 /* 926 /*
939 * Unix: 927 * Unix:
@@ -972,17 +960,8 @@ eina_file_mkdtemp(const char *templatename, Eina_Tmpstr **path)
972 const char *tmpdir = NULL; 960 const char *tmpdir = NULL;
973 char *tmpdirname; 961 char *tmpdirname;
974 962
975#ifndef HAVE_EVIL 963 eina_file_path_join(buffer, sizeof(buffer),
976#if defined(HAVE_GETUID) && defined(HAVE_GETEUID) 964 eina_environment_tmp_get(), templatename);
977 if (getuid() == geteuid())
978#endif
979 tmpdir = getenv("TMPDIR");
980 if (!tmpdir) tmpdir = "/tmp";
981#else
982 tmpdir = (char *)evil_tmpdir_get();
983#endif /* ! HAVE_EVIL */
984
985 snprintf(buffer, PATH_MAX, "%s/%s", tmpdir, templatename);
986 965
987 tmpdirname = mkdtemp(buffer); 966 tmpdirname = mkdtemp(buffer);
988 if (path) *path = eina_tmpstr_add(buffer); 967 if (path) *path = eina_tmpstr_add(buffer);