gutils: Add internal API to override XDG directories

Add a new internal function, g_set_user_dirs(), which will safely
override the values returned by g_get_user_data_dir() and friends, and
the value returned by g_get_home_dir().

This is intended to be used by unit tests, and will be hooked up to them
in a following commit.

This can be called as many times as needed by the current process. It’s
thread-safe. It does not modify the environment, so none of the changes
are propagated to any subsequently spawned subprocesses.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://gitlab.gnome.org/GNOME/glib/issues/538
This commit is contained in:
Philip Withnall
2018-11-30 17:47:18 +00:00
parent b87dfb4960
commit 91defdb34e
7 changed files with 165 additions and 0 deletions

View File

@@ -64,6 +64,7 @@ IGNORE_HFILES = \
glib-init.h \
gconstructor.h \
valgrind.h \
gutilsprivate.h \
gvalgrind.h \
$(NULL)

View File

@@ -36,6 +36,7 @@ if get_option('gtk_doc')
'glib-init.h',
'gconstructor.h',
'valgrind.h',
'gutilsprivate.h',
'gvalgrind.h',
]