diff --git a/lib/wp/base-dirs.c b/lib/wp/base-dirs.c index 2492e2c9..5121e5f0 100644 --- a/lib/wp/base-dirs.c +++ b/lib/wp/base-dirs.c @@ -55,6 +55,8 @@ lookup_dirs (guint flags, gboolean is_absolute) { g_autoptr(GPtrArray) dirs = g_ptr_array_new_with_free_func (g_free); const gchar *dir; + const gchar *subdir = + (flags & WP_BASE_DIRS_FLAG_SUBDIR_WIREPLUMBER) ? "wireplumber" : "."; /* Compile the list of lookup directories in priority order */ if (is_absolute) { @@ -84,17 +86,16 @@ lookup_dirs (guint flags, gboolean is_absolute) else { if (flags & WP_BASE_DIRS_XDG_CONFIG_HOME) { dir = g_get_user_config_dir (); - g_ptr_array_add (dirs, g_build_filename (dir, "wireplumber", NULL)); + g_ptr_array_add (dirs, g_canonicalize_filename (subdir, dir)); } if (flags & WP_BASE_DIRS_XDG_DATA_HOME) { dir = g_get_user_data_dir (); - g_ptr_array_add (dirs, g_build_filename (dir, "wireplumber", NULL)); + g_ptr_array_add (dirs, g_canonicalize_filename (subdir, dir)); } if (flags & WP_BASE_DIRS_XDG_CONFIG_DIRS) { const gchar * const *xdg_dirs = g_get_system_config_dirs (); for (guint i = 0; xdg_dirs[i]; i++) { - g_ptr_array_add (dirs, g_build_filename (xdg_dirs[i], "wireplumber", - NULL)); + g_ptr_array_add (dirs, g_canonicalize_filename (subdir, xdg_dirs[i])); } } if (flags & WP_BASE_DIRS_BUILD_SYSCONFDIR) { @@ -104,8 +105,7 @@ lookup_dirs (guint flags, gboolean is_absolute) if (flags & WP_BASE_DIRS_XDG_DATA_DIRS) { const gchar * const *xdg_dirs = g_get_system_data_dirs (); for (guint i = 0; xdg_dirs[i]; i++) { - g_ptr_array_add (dirs, g_build_filename (xdg_dirs[i], "wireplumber", - NULL)); + g_ptr_array_add (dirs, g_canonicalize_filename (subdir, xdg_dirs[i])); } } if (flags & WP_BASE_DIRS_BUILD_DATADIR) { diff --git a/lib/wp/base-dirs.h b/lib/wp/base-dirs.h index a242c282..3e445815 100644 --- a/lib/wp/base-dirs.h +++ b/lib/wp/base-dirs.h @@ -48,24 +48,32 @@ typedef enum { /*< flags >*/ /*! the file is a loadable module; prepend "lib" and append ".so" if needed */ WP_BASE_DIRS_FLAG_MODULE = (1 << 24), + /*! append "/wireplumber" to the location, except in the case of locations + that are specified via WirePlumber-specific environment variables; + in LIBDIR, append "/wireplumber-$API_version" instead */ + WP_BASE_DIRS_FLAG_SUBDIR_WIREPLUMBER = (1 << 25), + WP_BASE_DIRS_CONFIGURATION = WP_BASE_DIRS_ENV_CONFIG | WP_BASE_DIRS_XDG_CONFIG_HOME | WP_BASE_DIRS_XDG_CONFIG_DIRS | WP_BASE_DIRS_BUILD_SYSCONFDIR | WP_BASE_DIRS_XDG_DATA_DIRS | - WP_BASE_DIRS_BUILD_DATADIR, + WP_BASE_DIRS_BUILD_DATADIR | + WP_BASE_DIRS_FLAG_SUBDIR_WIREPLUMBER, WP_BASE_DIRS_DATA = WP_BASE_DIRS_ENV_DATA | WP_BASE_DIRS_XDG_DATA_HOME | WP_BASE_DIRS_XDG_DATA_DIRS | - WP_BASE_DIRS_BUILD_DATADIR, + WP_BASE_DIRS_BUILD_DATADIR | + WP_BASE_DIRS_FLAG_SUBDIR_WIREPLUMBER, WP_BASE_DIRS_MODULE = WP_BASE_DIRS_ENV_MODULE | WP_BASE_DIRS_BUILD_LIBDIR | - WP_BASE_DIRS_FLAG_MODULE, + WP_BASE_DIRS_FLAG_MODULE | + WP_BASE_DIRS_FLAG_SUBDIR_WIREPLUMBER, } WpBaseDirsFlags; WP_API