mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-05 13:38:02 +02:00
lib: add a function to get the xdg state dir
Added recently to the XDG spec, XDG_STATE_HOME ($HOME/.local/state/) is for files that are neither configuration/data files nor runtime/cache files.
This commit is contained in:
parent
fd37c0cd2e
commit
ab62af1748
2 changed files with 23 additions and 0 deletions
20
lib/wp/wp.c
20
lib/wp/wp.c
|
|
@ -77,6 +77,26 @@ wp_get_module_dir (void)
|
|||
return module_dir;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the full path to the WirePlumber XDG_STATE_HOME subdirectory
|
||||
* \returns Wireplumber's XDG_STATE_HOME subdirectory
|
||||
*/
|
||||
const gchar *
|
||||
wp_get_xdg_state_dir (void)
|
||||
{
|
||||
static gchar xdg_dir[PATH_MAX] = {0};
|
||||
if (xdg_dir[0] == '\0') {
|
||||
g_autofree gchar *path = NULL;
|
||||
g_autofree gchar *base = g_strdup (g_getenv ("XDG_STATE_HOME"));
|
||||
if (!base)
|
||||
base = g_build_filename (g_get_home_dir (), ".local", "state", NULL);
|
||||
|
||||
path = g_build_filename (base, "wireplumber", NULL);
|
||||
g_strlcpy (xdg_dir, path, sizeof (xdg_dir));
|
||||
}
|
||||
return xdg_dir;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the Wireplumber configuration directory
|
||||
* \returns The Wireplumber configuration directory
|
||||
|
|
|
|||
|
|
@ -65,6 +65,9 @@ void wp_init (WpInitFlags flags);
|
|||
WP_API
|
||||
const gchar * wp_get_module_dir (void);
|
||||
|
||||
WP_API
|
||||
const gchar * wp_get_xdg_state_dir (void);
|
||||
|
||||
WP_API
|
||||
const gchar * wp_get_config_dir (void);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue