Evas GL: Fix aarch64 build error in 'run-time generation and load of shaders' patch 02/63002/3 submit/tizen/20160322.024412
authorPrudhvi Raj, Vasireddi <prudhvi.raj@samsung.com>
Mon, 21 Mar 2016 12:11:12 +0000 (21:11 +0900)
committerPrudhvi Raj, Vasireddi <prudhvi.raj@samsung.com>
Mon, 21 Mar 2016 12:20:21 +0000 (21:20 +0900)
Change-Id: Iae81201874de496a41c3a868b786ceed30487bcf

src/lib/eina/eina_file_common.c

index 8314f00..cdb9ba9 100644 (file)
@@ -913,7 +913,8 @@ EAPI int
 eina_file_mkstemp(const char *templatename, Eina_Tmpstr **path)
 {
    char buffer[PATH_MAX];
-   const char *XXXXXX = NULL, *sep;
+   const char *tmpdir = NULL;
+   const char *XXXXXX = NULL;
    int fd, len;
 #ifndef _WIN32
    mode_t old_umask;
@@ -921,19 +922,23 @@ eina_file_mkstemp(const char *templatename, Eina_Tmpstr **path)
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(templatename, -1);
 
-   sep = strchr(templatename, '/');
-#ifdef _WIN32
-   if (!sep) sep = strchr(templatename, '\\');
-#endif
-   if (sep)
-     {
-        len = eina_strlcpy(buffer, templatename, sizeof(buffer));
-     }
-   else
+# if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
+   if (getuid() == geteuid())
+# endif
      {
-        len = eina_file_path_join(buffer, sizeof(buffer),
-                                  eina_environment_tmp_get(), templatename);
+        tmpdir = getenv("TMPDIR");
+       if (!tmpdir) tmpdir = getenv("XDG_RUNTIME_DIR");
      }
+   if (!tmpdir) tmpdir = "/tmp";
+
+#ifdef _WIN32
+   if (strchr(templatename, '\\'))
+#else
+   if (strchr(templatename, '/'))
+#endif
+   len = snprintf(buffer, PATH_MAX, "%s", templatename);
+else
+   len = snprintf(buffer, PATH_MAX, "%s/%s", tmpdir, templatename);
 
    /*
     * Unix:
@@ -972,23 +977,28 @@ EAPI Eina_Bool
 eina_file_mkdtemp(const char *templatename, Eina_Tmpstr **path)
 {
    char buffer[PATH_MAX];
-   char *tmpdirname, *sep;
+   const char *tmpdir = NULL;
+   char *tmpdirname;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(templatename, EINA_FALSE);
 
-   sep = strchr(templatename, '/');
-#ifdef _WIN32
-   if (!sep) sep = strchr(templatename, '\\');
-#endif
-   if (sep)
-     {
-        eina_strlcpy(buffer, templatename, sizeof(buffer));
-     }
-   else
+# if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
+   if (getuid() == geteuid())
+# endif
      {
-        eina_file_path_join(buffer, sizeof(buffer),
-                            eina_environment_tmp_get(), templatename);
+        tmpdir = getenv("TMPDIR");
+       if (!tmpdir) tmpdir = getenv("XDG_RUNTIME_DIR");
      }
+   if (!tmpdir) tmpdir = "/tmp";
+
+#ifdef _WIN32
+   if (strchr(templatename, '\\'))
+#else
+   if (strchr(templatename, '/'))
+#endif
+   snprintf(buffer, PATH_MAX, "%s", templatename);
+else
+   snprintf(buffer, PATH_MAX, "%s/%s", tmpdir, templatename);
 
    tmpdirname = mkdtemp(buffer);
    if (tmpdirname == NULL)