Base Directories File Lookup

enum WpBaseDirsFlags

Flags to specify lookup directories.

These flags can be used to specify which directories to look for a file in. The flags can be combined to search in multiple directories at once. Some flags may also used to specify the type of the file being looked up or other lookup parameters.

Lookup is performed in the same order as the flags are listed here. Note that if a WirePlumber-specific environment variable is set ($WIREPLUMBER_*_DIR) and the equivalent WP_BASE_DIRS_ENV_* flag is specified, the lookup in other directories is skipped, even if the file is not found in the environment-specified directory.

Values:

enumerator WP_BASE_DIRS_ENV_CONFIG = (1 << 0)

$WIREPLUMBER_CONFIG_DIR

enumerator WP_BASE_DIRS_ENV_DATA = (1 << 1)

$WIREPLUMBER_DATA_DIR

enumerator WP_BASE_DIRS_ENV_MODULE = (1 << 2)

$WIREPLUMBER_MODULE_DIR

enumerator WP_BASE_DIRS_XDG_CONFIG_HOME = (1 << 8)

XDG_CONFIG_HOME

enumerator WP_BASE_DIRS_XDG_DATA_HOME = (1 << 9)

XDG_DATA_HOME

enumerator WP_BASE_DIRS_XDG_CONFIG_DIRS = (1 << 10)

XDG_CONFIG_DIRS

enumerator WP_BASE_DIRS_BUILD_SYSCONFDIR = (1 << 11)

compile-time $sysconfdir (/etc)

enumerator WP_BASE_DIRS_XDG_DATA_DIRS = (1 << 12)

XDG_DATA_DIRS

enumerator WP_BASE_DIRS_BUILD_DATADIR = (1 << 13)

compile-time $datadir ($prefix/share)

enumerator WP_BASE_DIRS_BUILD_LIBDIR = (1 << 14)

compile-time $libdir ($prefix/lib)

enumerator WP_BASE_DIRS_FLAG_MODULE = (1 << 24)

the file is a loadable module; prepend “lib” and append “.so” if needed

enumerator WP_BASE_DIRS_FLAG_SUBDIR_WIREPLUMBER = (1 << 25)

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

enumerator 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_FLAG_SUBDIR_WIREPLUMBER)
enumerator 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_FLAG_SUBDIR_WIREPLUMBER)
enumerator WP_BASE_DIRS_MODULE = (WP_BASE_DIRS_ENV_MODULE | WP_BASE_DIRS_BUILD_LIBDIR | WP_BASE_DIRS_FLAG_MODULE | WP_BASE_DIRS_FLAG_SUBDIR_WIREPLUMBER)
gchar *wp_base_dirs_find_file(WpBaseDirsFlags flags, const gchar *subdir, const gchar *filename)

Searches for filename in the hierarchy of directories specified by the flags parameter.

Returns the highest priority file found in the hierarchy of directories specified by the flags parameter. The subdir parameter is the name of the subdirectory to search in, inside the specified directories. If subdir is NULL, the base path of each directory is used.

The filename parameter is the name of the file to search for. If the file is found, its full path is returned. If the file is not found, NULL is returned. The file is considered found if it is a regular file.

If the filename is an absolute path, it is tested for existence and returned as is, ignoring the lookup directories in flags as well as the subdir parameter.

Since

0.5.0

Parameters:
  • flags – flags to specify the directories to look into and other options specific to the kind of file being looked up

  • subdir – (nullable): the name of the subdirectory to search in, inside the specified directories

  • filename – the name of the file to search for

Returns:

(transfer full) (nullable): A newly allocated string with the absolute, canonicalized file path, or NULL if the file was not found.

WpIterator *wp_base_dirs_new_files_iterator(WpBaseDirsFlags flags, const gchar *subdir, const gchar *suffix)

Creates an iterator to iterate over all files that match suffix within the subdir of the directories specified in flags.

The subdir parameter is the name of the subdirectory to search in, inside the directories specified by flags. If subdir is NULL, the base path of each directory is used. If subdir is an absolute path, files are only looked up in that directory and the directories in flags are ignored.

The suffix parameter is the filename suffix to match. If suffix is NULL, all files are matched.

The iterator will iterate over the absolute paths of all the files files found, in the order of priority of the directories, starting from the lowest priority directory (e.g. /usr/share/wireplumber) and ending with the highest priority directory (e.g. $XDG_CONFIG_HOME/wireplumber). Files within each directory are also sorted by filename.

Since

0.5.0

Parameters:
  • flags – flags to specify the directories to look into and other options specific to the kind of file being looked up

  • subdir – (nullable): the name of the subdirectory to search in, inside the configuration directories

  • suffix – (nullable): The filename suffix, NULL matches all entries

Returns:

(transfer full): a new iterator iterating over strings which are absolute & canonicalized paths to the files found