add support for XDG_CACHE_HOME to the obt paths
This commit is contained in:
parent
46cf95d36b
commit
2c64fe685e
2 changed files with 14 additions and 0 deletions
13
obt/paths.c
13
obt/paths.c
|
@ -34,6 +34,7 @@ struct _ObtPaths
|
||||||
gint ref;
|
gint ref;
|
||||||
gchar *config_home;
|
gchar *config_home;
|
||||||
gchar *data_home;
|
gchar *data_home;
|
||||||
|
gchar *cache_home;
|
||||||
GSList *config_dirs;
|
GSList *config_dirs;
|
||||||
GSList *data_dirs;
|
GSList *data_dirs;
|
||||||
};
|
};
|
||||||
|
@ -95,6 +96,12 @@ ObtPaths* obt_paths_new(void)
|
||||||
p->data_home = g_build_filename(g_get_home_dir(), ".local",
|
p->data_home = g_build_filename(g_get_home_dir(), ".local",
|
||||||
"share", NULL);
|
"share", NULL);
|
||||||
|
|
||||||
|
path = g_getenv("XDG_CACHE_HOME");
|
||||||
|
if (path && path[0] != '\0') /* not unset or empty */
|
||||||
|
p->cache_home = g_build_filename(path, NULL);
|
||||||
|
else
|
||||||
|
p->cache_home = g_build_filename(g_get_home_dir(), ".cache", NULL);
|
||||||
|
|
||||||
path = g_getenv("XDG_CONFIG_DIRS");
|
path = g_getenv("XDG_CONFIG_DIRS");
|
||||||
if (path && path[0] != '\0') /* not unset or empty */
|
if (path && path[0] != '\0') /* not unset or empty */
|
||||||
p->config_dirs = split_paths(path);
|
p->config_dirs = split_paths(path);
|
||||||
|
@ -154,6 +161,7 @@ void obt_paths_unref(ObtPaths *p)
|
||||||
g_slist_free(p->data_dirs);
|
g_slist_free(p->data_dirs);
|
||||||
g_free(p->config_home);
|
g_free(p->config_home);
|
||||||
g_free(p->data_home);
|
g_free(p->data_home);
|
||||||
|
g_free(p->cache_home);
|
||||||
|
|
||||||
obt_free0(p, ObtPaths, 1);
|
obt_free0(p, ObtPaths, 1);
|
||||||
}
|
}
|
||||||
|
@ -223,6 +231,11 @@ const gchar* obt_paths_data_home(ObtPaths *p)
|
||||||
return p->data_home;
|
return p->data_home;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const gchar* obt_paths_cache_home(ObtPaths *p)
|
||||||
|
{
|
||||||
|
return p->cache_home;
|
||||||
|
}
|
||||||
|
|
||||||
GSList* obt_paths_config_dirs(ObtPaths *p)
|
GSList* obt_paths_config_dirs(ObtPaths *p)
|
||||||
{
|
{
|
||||||
return p->config_dirs;
|
return p->config_dirs;
|
||||||
|
|
|
@ -31,6 +31,7 @@ void obt_paths_unref(ObtPaths *p);
|
||||||
|
|
||||||
const gchar* obt_paths_config_home(ObtPaths *p);
|
const gchar* obt_paths_config_home(ObtPaths *p);
|
||||||
const gchar* obt_paths_data_home(ObtPaths *p);
|
const gchar* obt_paths_data_home(ObtPaths *p);
|
||||||
|
const gchar* obt_paths_cache_home(ObtPaths *p);
|
||||||
GSList* obt_paths_config_dirs(ObtPaths *p);
|
GSList* obt_paths_config_dirs(ObtPaths *p);
|
||||||
GSList* obt_paths_data_dirs(ObtPaths *p);
|
GSList* obt_paths_data_dirs(ObtPaths *p);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue