Mildly improve Windows portability

This commit is contained in:
Přemysl Eric Janouch 2022-07-21 09:50:43 +02:00
parent e7c75f8f9b
commit 60b2395940
Signed by: p
GPG Key ID: A0420B94F92B9493

6
xdg.c
View File

@ -45,7 +45,7 @@ char *
get_xdg_home_dir(const char *var, const char *default_)
{
const char *env = getenv(var);
if (env && *env == '/')
if (env && g_path_is_absolute(env))
return g_strdup(env);
// The specification doesn't handle a missing HOME variable explicitly.
@ -65,9 +65,9 @@ get_xdg_data_dirs(void)
if (!(xdg_data_dirs = getenv("XDG_DATA_DIRS")) || !*xdg_data_dirs)
xdg_data_dirs = "/usr/local/share/:/usr/share/";
gchar **candidates = g_strsplit(xdg_data_dirs, ":", 0);
gchar **candidates = g_strsplit(xdg_data_dirs, G_SEARCHPATH_SEPARATOR_S, 0);
for (gchar **p = candidates; *p; p++) {
if (**p == '/')
if (g_path_is_absolute(*p))
g_ptr_array_add(output, *p);
else
g_free(*p);