10 Commits

Author SHA1 Message Date
George Kiagiadakis
4b0024ed27 base-dirs: add missing (nullable) annotation 2024-03-04 07:07:56 +00:00
George Kiagiadakis
8040967e47 base-dirs: ensure we skip non-absolute paths in the XDG env variables
The XDG basedir spec explicitly says non-absolute paths must be ignored
and the glib wraper functions don't check that.
2024-03-04 07:07:56 +00:00
George Kiagiadakis
a873f47d2e base-dirs: tidy up the build-time base dirs and honor the SUBDIR_WIREPLUMBER flag
Add a new private header file, wpbuildbasedirs.h, that contains the
build-time base directories passed directly from meson, without
the "wireplumber" suffix.

Use this to set the WP_BASE_DIRS_BUILD_* and adjust the code to honor
the SUBDIR_WIREPLUMBER flag.
2024-03-04 07:07:56 +00:00
George Kiagiadakis
ad4c6999e8 base-dirs: add a SUBDIR_WIREPLUMBER flag to append "/wireplumber" to the base dirs
This removes the previous hardcoding of this suffix and allows the
functions to be useful to other projects that use libwireplumber
and want to use this code to locate their data & config.
2024-03-04 07:07:56 +00:00
George Kiagiadakis
e7484c16a3 base-dirs: rename ETC & PREFIX* flags to BUILD* and improve documentation
The directories specified by these flags are build-time constants,
so the BUILD* prefix is more appropriate.
2024-03-04 07:07:56 +00:00
George Kiagiadakis
9e77240b64 base-dirs: return NULL from lookup_dirs() when the searched path is absolute
This allows the files iterator to lookup in a specific directory
when the given path is absolute, similar to how pipewire behaves
for configuration files (e.g. /foo/bar/wireplumber.conf must
include /foo/bar/wireplumber.conf.d/*.conf).

This also allows improving the wp_base_dirs_find_file() structure to
avoid duplicated code and add a debug message easily.
2024-03-04 07:07:56 +00:00
George Kiagiadakis
f76f45124e base-dirs: add support for finding modules and remove wp_get_module_dir()
This makes things more consistent and allows us also to add more
search paths in the future if necessary.

Also, stop using g_module_build_path() because it's deprecated and
build the path manually. This obviously is not portable to Windows/Mac
or other exotic platforms, but portability is not important at this
point. PipeWire is also not portable beyond Linux & BSD.
2024-03-04 07:07:56 +00:00
George Kiagiadakis
c8feaad7a9 base-dirs: add XDG_CONFIG/DATA_DIRS and CONFIGURATION & DATA groups
This adds support for the system-wide locations for configuration and
data files, as defined by the XDG Base Directory Specification.

In addition, it adds two flag groups, CONFIGURATION and DATA, to the
base-dirs system, so that we don't have to hard-code the combinations
of flags everywhere.
2024-03-04 07:07:56 +00:00
George Kiagiadakis
a95cbda846 base-dirs: change the function signatures to prefix with wp_base_dirs_*
... and fix the arguments order and the documentation
2024-03-04 07:07:56 +00:00
George Kiagiadakis
6ae8c254a0 base-dirs: move file lookup utils out of wp.{c,h} and into base-dirs.{c,h} 2024-03-04 07:07:56 +00:00