eina: use eina_file_path_join() and eina_environment_tmp_get() when needed

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
Vincent Torri 2015-10-15 14:41:04 +02:00 committed by Cedric BAIL
parent 892df20bd4
commit 9e5852fcfb
1 changed files with 4 additions and 27 deletions

View File

@ -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);