eina: use eina_file_path_join() and eina_environment_tmp_get() when needed
authorVincent Torri <vincent dot torri at gmail dot com>
Thu, 15 Oct 2015 12:41:04 +0000 (14:41 +0200)
committerCedric BAIL <cedric@osg.samsung.com>
Tue, 1 Dec 2015 20:13:12 +0000 (12:13 -0800)
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
src/lib/eina/eina_file_common.c

index 4ffd2ed..57d9b99 100644 (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);