wp: make the config file lookup methods more generic

* Make the flags public and give them nicer names
* Pass down the flags from the caller, so the caller can now explicitly
  ask for looking into specific directories
* Rename the methods
* Remove and inline the wp_get_xdg_config_dir() method, since it's only
  used internally
* Refactor the lookup dirs ordering to get both WIREPLUMBER_*_DIR env
  variables to replace all the other directories. Previously, we were looking
  for scripts in WIREPLUMBER_DATA_DIR, but we were also looking in /etc at
  the same time (with precedence, even), which could result in unexpected
  behaviour. Now, if a WIREPLUMBER environment variable is specified,
  we only look in there.
This commit is contained in:
George Kiagiadakis
2021-08-12 09:08:40 +03:00
parent 129b44bb0c
commit 27ed36c2da
5 changed files with 68 additions and 114 deletions

View File

@@ -131,7 +131,10 @@ find_script (const gchar * script, gboolean daemon)
g_file_test (script, G_FILE_TEST_IS_REGULAR))
return g_strdup (script);
return wp_find_sysconfig_file (script, "scripts");
return wp_find_file (WP_LOOKUP_DIR_ENV_DATA |
WP_LOOKUP_DIR_ETC |
WP_LOOKUP_DIR_PREFIX_SHARE,
script, "scripts");
}
static gboolean