forked from enlightenment/efl
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
This commit is contained in:
parent
af2fd2ead0
commit
7ef58c47d3
|
@ -51,6 +51,8 @@ static const char *xdg_pictures_dir = NULL;
|
||||||
static const char *xdg_videos_dir = NULL;
|
static const char *xdg_videos_dir = NULL;
|
||||||
static const char *hostname = NULL;
|
static const char *hostname = NULL;
|
||||||
|
|
||||||
|
static Eina_Prefix *pfx= NULL;
|
||||||
|
|
||||||
static void efreet_dirs_init(void);
|
static void efreet_dirs_init(void);
|
||||||
static const char *efreet_dir_get(const char *key, const char *fallback);
|
static const char *efreet_dir_get(const char *key, const char *fallback);
|
||||||
static Eina_List *efreet_dirs_get(const char *key,
|
static Eina_List *efreet_dirs_get(const char *key,
|
||||||
|
@ -72,6 +74,9 @@ efreet_base_init(void)
|
||||||
EINA_LOG_ERR("Efreet: Could not create a log domain for efreet_base.\n");
|
EINA_LOG_ERR("Efreet: Could not create a log domain for efreet_base.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (!pfx) pfx = eina_prefix_new
|
||||||
|
(NULL, efreet_init, "EFREET", "efreet", "checkme",
|
||||||
|
PACKAGE_BIN_DIR, PACKAGE_LIB_DIR, PACKAGE_DATA_DIR, PACKAGE_DATA_DIR);
|
||||||
efreet_dirs_init();
|
efreet_dirs_init();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -105,6 +110,11 @@ efreet_base_shutdown(void)
|
||||||
|
|
||||||
IF_RELEASE(hostname);
|
IF_RELEASE(hostname);
|
||||||
|
|
||||||
|
if (pfx)
|
||||||
|
{
|
||||||
|
eina_prefix_free(pfx);
|
||||||
|
pfx = NULL;
|
||||||
|
}
|
||||||
eina_log_domain_unregister(_efreet_base_log_dom);
|
eina_log_domain_unregister(_efreet_base_log_dom);
|
||||||
_efreet_base_log_dom = -1;
|
_efreet_base_log_dom = -1;
|
||||||
}
|
}
|
||||||
|
@ -280,6 +290,7 @@ efreet_dirs_reset(void)
|
||||||
static void
|
static void
|
||||||
efreet_dirs_init(void)
|
efreet_dirs_init(void)
|
||||||
{
|
{
|
||||||
|
char *data_dir = DATA_DIR;
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
|
|
||||||
/* efreet_home_dir */
|
/* efreet_home_dir */
|
||||||
|
@ -294,13 +305,27 @@ efreet_dirs_init(void)
|
||||||
xdg_cache_home = efreet_dir_get("XDG_CACHE_HOME", "/.cache");
|
xdg_cache_home = efreet_dir_get("XDG_CACHE_HOME", "/.cache");
|
||||||
|
|
||||||
/* xdg_data_dirs */
|
/* xdg_data_dirs */
|
||||||
|
if (pfx)
|
||||||
|
{
|
||||||
|
const char *dir = eina_prefix_get(pfx);
|
||||||
|
if (dir)
|
||||||
|
{
|
||||||
|
size_t len = strlen(dir);
|
||||||
|
|
||||||
|
data_dir = alloca(len + 1 + 5 /*"share" */ + 1);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
snprintf(buf, sizeof(buf), "%s\\Efl;" DATA_DIR ";", getenv("APPDATA"));
|
snprintf(data_dir, len + 1 + 5 + 1, "%s\\share", dir);
|
||||||
xdg_data_dirs = efreet_dirs_get("XDG_DATA_DIRS", buf);
|
|
||||||
#else
|
#else
|
||||||
xdg_data_dirs = efreet_dirs_get("XDG_DATA_DIRS",
|
snprintf(data_dir, len + 1 + 5 + 1, "%s/share", dir);
|
||||||
DATA_DIR ":/usr/share:/usr/local/share");
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef _WIN32
|
||||||
|
snprintf(buf, sizeof(buf), "%s\\Efl;%s;", data_dir, getenv("APPDATA"));
|
||||||
|
#else
|
||||||
|
snprintf(buf, sizeof(buf), "%s:/usr/share:/usr/local/share", data_dir);
|
||||||
|
#endif
|
||||||
|
xdg_data_dirs = efreet_dirs_get("XDG_DATA_DIRS", buf);
|
||||||
/* xdg_config_dirs */
|
/* xdg_config_dirs */
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
xdg_config_dirs = efreet_dirs_get("XDG_CONFIG_DIRS", getenv("APPDATA"));
|
xdg_config_dirs = efreet_dirs_get("XDG_CONFIG_DIRS", getenv("APPDATA"));
|
||||||
|
|
Loading…
Reference in New Issue