summaryrefslogtreecommitdiff
path: root/src/lib/efreet/efreet_base.c
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-06-09 10:13:04 +0100
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-06-09 10:16:24 +0100
commit9be9e9f5ffd50b0079143f18a9c99ff793daa81a (patch)
treeedc25f2c8eef7bb01457febff6680711aa1b40e8 /src/lib/efreet/efreet_base.c
parent0ab3575f700f961ba89a9477f010ca97294a0cf7 (diff)
efreet - handle runtime relocation right with default XDG_DATA_DIRS
XDG_DATA_DIRS was only set up to a default including where efl was installed prefix-wise as the compiled-=in prefix, not runtime determined prefix. it shouldn't actually affect most people except those making use of this. @fix
Diffstat (limited to '')
-rw-r--r--src/lib/efreet/efreet_base.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/lib/efreet/efreet_base.c b/src/lib/efreet/efreet_base.c
index 6497e8d955..736a3a05fc 100644
--- a/src/lib/efreet/efreet_base.c
+++ b/src/lib/efreet/efreet_base.c
@@ -51,6 +51,8 @@ static const char *xdg_pictures_dir = NULL;
51static const char *xdg_videos_dir = NULL; 51static const char *xdg_videos_dir = NULL;
52static const char *hostname = NULL; 52static const char *hostname = NULL;
53 53
54static Eina_Prefix *pfx= NULL;
55
54static void efreet_dirs_init(void); 56static void efreet_dirs_init(void);
55static const char *efreet_dir_get(const char *key, const char *fallback); 57static const char *efreet_dir_get(const char *key, const char *fallback);
56static Eina_List *efreet_dirs_get(const char *key, 58static Eina_List *efreet_dirs_get(const char *key,
@@ -72,6 +74,9 @@ efreet_base_init(void)
72 EINA_LOG_ERR("Efreet: Could not create a log domain for efreet_base.\n"); 74 EINA_LOG_ERR("Efreet: Could not create a log domain for efreet_base.\n");
73 return 0; 75 return 0;
74 } 76 }
77 if (!pfx) pfx = eina_prefix_new
78 (NULL, efreet_init, "EFREET", "efreet", "checkme",
79 PACKAGE_BIN_DIR, PACKAGE_LIB_DIR, PACKAGE_DATA_DIR, PACKAGE_DATA_DIR);
75 efreet_dirs_init(); 80 efreet_dirs_init();
76 return 1; 81 return 1;
77} 82}
@@ -105,6 +110,11 @@ efreet_base_shutdown(void)
105 110
106 IF_RELEASE(hostname); 111 IF_RELEASE(hostname);
107 112
113 if (pfx)
114 {
115 eina_prefix_free(pfx);
116 pfx = NULL;
117 }
108 eina_log_domain_unregister(_efreet_base_log_dom); 118 eina_log_domain_unregister(_efreet_base_log_dom);
109 _efreet_base_log_dom = -1; 119 _efreet_base_log_dom = -1;
110} 120}
@@ -280,6 +290,7 @@ efreet_dirs_reset(void)
280static void 290static void
281efreet_dirs_init(void) 291efreet_dirs_init(void)
282{ 292{
293 char *data_dir = DATA_DIR;
283 char buf[PATH_MAX]; 294 char buf[PATH_MAX];
284 295
285 /* efreet_home_dir */ 296 /* efreet_home_dir */
@@ -294,13 +305,27 @@ efreet_dirs_init(void)
294 xdg_cache_home = efreet_dir_get("XDG_CACHE_HOME", "/.cache"); 305 xdg_cache_home = efreet_dir_get("XDG_CACHE_HOME", "/.cache");
295 306
296 /* xdg_data_dirs */ 307 /* xdg_data_dirs */
308 if (pfx)
309 {
310 const char *dir = eina_prefix_get(pfx);
311 if (dir)
312 {
313 size_t len = strlen(dir);
314
315 data_dir = alloca(len + 1 + 5 /*"share" */ + 1);
297#ifdef _WIN32 316#ifdef _WIN32
298 snprintf(buf, sizeof(buf), "%s\\Efl;" DATA_DIR ";", getenv("APPDATA")); 317 snprintf(data_dir, len + 1 + 5 + 1, "%s\\share", dir);
299 xdg_data_dirs = efreet_dirs_get("XDG_DATA_DIRS", buf);
300#else 318#else
301 xdg_data_dirs = efreet_dirs_get("XDG_DATA_DIRS", 319 snprintf(data_dir, len + 1 + 5 + 1, "%s/share", dir);
302 DATA_DIR ":/usr/share:/usr/local/share");
303#endif 320#endif
321 }
322 }
323#ifdef _WIN32
324 snprintf(buf, sizeof(buf), "%s\\Efl;%s;", data_dir, getenv("APPDATA"));
325#else
326 snprintf(buf, sizeof(buf), "%s:/usr/share:/usr/local/share", data_dir);
327#endif
328 xdg_data_dirs = efreet_dirs_get("XDG_DATA_DIRS", buf);
304 /* xdg_config_dirs */ 329 /* xdg_config_dirs */
305#ifdef _WIN32 330#ifdef _WIN32
306 xdg_config_dirs = efreet_dirs_get("XDG_CONFIG_DIRS", getenv("APPDATA")); 331 xdg_config_dirs = efreet_dirs_get("XDG_CONFIG_DIRS", getenv("APPDATA"));