diff options
author | Vincent Torri <vincent dot torri at gmail dot com> | 2015-10-15 14:41:04 +0200 |
---|---|---|
committer | Cedric BAIL <cedric@osg.samsung.com> | 2015-12-01 12:13:12 -0800 |
commit | 9e5852fcfb3f3ef7def4908c9f3d8c0c8b1c25f4 (patch) | |
tree | ccafc20191bd122b048a5b3b9c710f010d430e50 | |
parent | 892df20bd45d2e15a7f356a06884d0b121c91c57 (diff) | |
download | efl-9e5852fcfb3f3ef7def4908c9f3d8c0c8b1c25f4.tar.gz |
eina: use eina_file_path_join() and eina_environment_tmp_get() when needed
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r-- | src/lib/eina/eina_file_common.c | 31 |
1 files changed, 4 insertions, 27 deletions
diff --git a/src/lib/eina/eina_file_common.c b/src/lib/eina/eina_file_common.c index 4ffd2edcc3..57d9b99d41 100644 --- a/src/lib/eina/eina_file_common.c +++ b/src/lib/eina/eina_file_common.c @@ -913,27 +913,14 @@ EAPI int eina_file_mkstemp(const char *templatename, Eina_Tmpstr **path) { char buffer[PATH_MAX]; - const char *tmpdir = NULL; const char *XXXXXX = NULL; int fd, len; #ifndef _WIN32 mode_t old_umask; #endif -#ifndef HAVE_EVIL -#if defined(HAVE_GETUID) && defined(HAVE_GETEUID) - if (getuid() == geteuid()) -#endif - { - tmpdir = getenv("TMPDIR"); - if (!tmpdir) tmpdir = getenv("XDG_RUNTIME_DIR"); - } - if (!tmpdir) tmpdir = "/tmp"; -#else - tmpdir = (char *)evil_tmpdir_get(); -#endif /* ! HAVE_EVIL */ - - len = snprintf(buffer, PATH_MAX, "%s/%s", tmpdir, templatename); + len = eina_file_path_join(buffer, sizeof(buffer), + eina_environment_tmp_get(), templatename); /* * Unix: @@ -969,20 +956,10 @@ EAPI Eina_Bool eina_file_mkdtemp(const char *templatename, Eina_Tmpstr **path) { char buffer[PATH_MAX]; - const char *tmpdir = NULL; char *tmpdirname; -#ifndef HAVE_EVIL -#if defined(HAVE_GETUID) && defined(HAVE_GETEUID) - if (getuid() == geteuid()) -#endif - tmpdir = getenv("TMPDIR"); - if (!tmpdir) tmpdir = "/tmp"; -#else - tmpdir = (char *)evil_tmpdir_get(); -#endif /* ! HAVE_EVIL */ - - snprintf(buffer, PATH_MAX, "%s/%s", tmpdir, templatename); + eina_file_path_join(buffer, sizeof(buffer), + eina_environment_tmp_get(), templatename); tmpdirname = mkdtemp(buffer); if (path) *path = eina_tmpstr_add(buffer); |