This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository efl.

View the commit online.

commit be64d502b6165640060b2217f0ca9cf18238fe07
Author: Vincent Torri <vto...@outlook.fr>
AuthorDate: Tue Jun 25 11:01:02 2024 +0200

    use eina_environment_home_get() instead of $HOME. also call directly mkdir()
    instead of a function calling mkdir
---
 src/lib/eina/eina_util.c                           | 22 +++++++--------
 .../evas/engines/gl_common/evas_gl_common.h        |  3 --
 .../evas/engines/gl_common/evas_gl_file_cache.c    | 33 ++++++++--------------
 3 files changed, 23 insertions(+), 35 deletions(-)

diff --git a/src/lib/eina/eina_util.c b/src/lib/eina/eina_util.c
index 036b85a382..85164a6e24 100644
--- a/src/lib/eina/eina_util.c
+++ b/src/lib/eina/eina_util.c
@@ -56,8 +56,8 @@ eina_environment_home_get(void)
    if (home) return home;
 #ifdef _WIN32
    home = getenv("USERPROFILE");
-   if (!home) home = getenv("WINDIR");
-   if (!home &&
+   if (!home || !*home) home = getenv("WINDIR");
+   if ((!home  || !*home) &&
        (getenv("HOMEDRIVE") && getenv("HOMEPATH")))
      {
         char buf[PATH_MAX];
@@ -72,7 +72,7 @@ eina_environment_home_get(void)
 # if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
    if (getuid() == geteuid()) home = getenv("HOME");
 # endif
-   if (!home)
+   if (!home || !*home)
      {
 # ifdef HAVE_GETPWENT
         struct passwd pwent, *pwent2 = NULL;
@@ -105,21 +105,21 @@ eina_environment_tmp_get(void)
    if (tmp) return tmp;
 #ifdef _WIN32
    tmp = getenv("TMP");
-   if (!tmp) tmp = getenv("TEMP");
-   if (!tmp) tmp = getenv("USERPROFILE");
-   if (!tmp) tmp = getenv("WINDIR");
-   if (!tmp) tmp = "C:\\";
+   if (!tmp || !*tmp) tmp = getenv("TEMP");
+   if (!tmp || !*tmp) tmp = getenv("USERPROFILE");
+   if (!tmp || !*tmp) tmp = getenv("WINDIR");
+   if (!tmp || !*tmp) tmp = "C:\\";
 #else
 # if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
    if (getuid() == geteuid())
 # endif
      {
         tmp = getenv("TMPDIR");
-        if (!tmp) tmp = getenv("TMP");
-        if (!tmp) tmp = getenv("TEMPDIR");
-        if (!tmp) tmp = getenv("TEMP");
+        if (!tmp || !*tmp) tmp = getenv("TMP");
+        if (!tmp || !*tmp) tmp = getenv("TEMPDIR");
+        if (!tmp || !*tmp) tmp = getenv("TEMP");
      }
-   if (!tmp) tmp = "/tmp";
+   if (!tmp || !*tmp) tmp = "/tmp";
 #endif
 
 #if defined(__MACH__) && defined(__APPLE__)
diff --git a/src/modules/evas/engines/gl_common/evas_gl_common.h b/src/modules/evas/engines/gl_common/evas_gl_common.h
index dafabbbe95..02bf2dc162 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_common.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_common.h
@@ -709,10 +709,7 @@ Evas_GL_Program  *evas_gl_common_shader_program_get(Evas_Engine_GL_Context *gc,
                                                     Shader_Sampling *pmasksam);
 void              evas_gl_common_shader_textures_bind(Evas_GL_Program *p, Eina_Bool recover_prog);
 
-Eina_Bool         evas_gl_common_file_cache_is_dir(const char *file);
-Eina_Bool         evas_gl_common_file_cache_mkdir(const char *dir);
 Eina_Bool         evas_gl_common_file_cache_file_exists(const char *file);
-Eina_Bool         evas_gl_common_file_cache_mkpath_if_not_exists(const char *path);
 Eina_Bool         evas_gl_common_file_cache_mkpath(const char *path);
 int               evas_gl_common_file_cache_dir_check(char *cache_dir, int num);
 int               evas_gl_common_file_cache_file_check(const char *cache_dir, const char *cache_name, char *cache_file, int dir_num);
diff --git a/src/modules/evas/engines/gl_common/evas_gl_file_cache.c b/src/modules/evas/engines/gl_common/evas_gl_file_cache.c
index f31ce118ac..ffeb463d46 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_file_cache.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_file_cache.c
@@ -1,8 +1,12 @@
 #include "evas_gl_private.h"
 
+#ifdef _WIN32
+# include <evil_private.h> /* mkdir */
+#endif
+
 static mode_t default_mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
 
-Eina_Bool
+static Eina_Bool
 evas_gl_common_file_cache_is_dir(const char *file)
 {
    struct stat st;
@@ -12,14 +16,6 @@ evas_gl_common_file_cache_is_dir(const char *file)
    return EINA_FALSE;
 }
 
-Eina_Bool
-evas_gl_common_file_cache_mkdir(const char *dir)
-{
-   /* evas gl only call this function when the dir is not exist */
-   if (mkdir(dir, default_mode) < 0) return EINA_FALSE;
-   return EINA_TRUE;
-}
-
 Eina_Bool
 evas_gl_common_file_cache_file_exists(const char *file)
 {
@@ -29,17 +25,15 @@ evas_gl_common_file_cache_file_exists(const char *file)
    return EINA_TRUE;
 }
 
-Eina_Bool
+static Eina_Bool
 evas_gl_common_file_cache_mkpath_if_not_exists(const char *path)
 {
    struct stat st;
 
    if (stat(path, &st) < 0)
-      return evas_gl_common_file_cache_mkdir(path);
-   else if (!S_ISDIR(st.st_mode))
-      return EINA_FALSE;
+     return mkdir(path, default_mode) == 0;
    else
-      return EINA_TRUE;
+     return S_ISDIR(st.st_mode);
 }
 
 Eina_Bool
@@ -70,16 +64,14 @@ evas_gl_common_file_cache_mkpath(const char *path)
 int
 evas_gl_common_file_cache_dir_check(char *cache_dir, int num)
 {
-   char *home = NULL;
+   char *home;
    char *subdir = ".cache/evas_gl_common_caches";
 
-#if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
-   if (getuid() != geteuid()) return 0;
-#endif
-   home = getenv("HOME");
-   if ((!home) || (!home[0])) return 0;
+   home = (char *)eina_environment_home_get();
+   if (!home) return 0;
 
    snprintf(cache_dir, num, "%s/%s", home, subdir);
+   free(home);
    return evas_gl_common_file_cache_file_exists(cache_dir);
 }
 
@@ -121,4 +113,3 @@ evas_gl_common_file_cache_file_check(const char *cache_dir, const char *cache_na
 
    return evas_gl_common_file_cache_file_exists(cache_file);
 }
-

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to