mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-23 12:41:50 +01:00
[Win32] Don't leak return value from get_special_folder(). (#169348,
2005-03-09 Tor Lillqvist <tml@novell.com> * glib/gutils.c (g_get_user_data_dir, g_get_user_config_dir, g_get_user_cache_dir, g_get_system_data_dirs, g_get_system_config_dirs): [Win32] Don't leak return value from get_special_folder(). (#169348, Daniel Atallah) Guard against g_home_dir being NULL, use g_tmp_dir/g_user_name in that case.
This commit is contained in:
parent
331548d91c
commit
1607e3f1d0
@ -1,3 +1,11 @@
|
||||
2005-03-09 Tor Lillqvist <tml@novell.com>
|
||||
|
||||
* glib/gutils.c (g_get_user_data_dir, g_get_user_config_dir,
|
||||
g_get_user_cache_dir, g_get_system_data_dirs,
|
||||
g_get_system_config_dirs): [Win32] Don't leak return value from
|
||||
get_special_folder(). (#169348, Daniel Atallah) Guard against
|
||||
g_home_dir being NULL, use g_tmp_dir/g_user_name in that case.
|
||||
|
||||
Tue Mar 8 15:46:54 2005 Søren Sandmann <sandmann@redhat.com>
|
||||
|
||||
* glib/gfileutils.c (g_file_replace): New API. A function to
|
||||
|
@ -1,3 +1,11 @@
|
||||
2005-03-09 Tor Lillqvist <tml@novell.com>
|
||||
|
||||
* glib/gutils.c (g_get_user_data_dir, g_get_user_config_dir,
|
||||
g_get_user_cache_dir, g_get_system_data_dirs,
|
||||
g_get_system_config_dirs): [Win32] Don't leak return value from
|
||||
get_special_folder(). (#169348, Daniel Atallah) Guard against
|
||||
g_home_dir being NULL, use g_tmp_dir/g_user_name in that case.
|
||||
|
||||
Tue Mar 8 15:46:54 2005 Søren Sandmann <sandmann@redhat.com>
|
||||
|
||||
* glib/gfileutils.c (g_file_replace): New API. A function to
|
||||
|
@ -1,3 +1,11 @@
|
||||
2005-03-09 Tor Lillqvist <tml@novell.com>
|
||||
|
||||
* glib/gutils.c (g_get_user_data_dir, g_get_user_config_dir,
|
||||
g_get_user_cache_dir, g_get_system_data_dirs,
|
||||
g_get_system_config_dirs): [Win32] Don't leak return value from
|
||||
get_special_folder(). (#169348, Daniel Atallah) Guard against
|
||||
g_home_dir being NULL, use g_tmp_dir/g_user_name in that case.
|
||||
|
||||
Tue Mar 8 15:46:54 2005 Søren Sandmann <sandmann@redhat.com>
|
||||
|
||||
* glib/gfileutils.c (g_file_replace): New API. A function to
|
||||
|
@ -1,3 +1,11 @@
|
||||
2005-03-09 Tor Lillqvist <tml@novell.com>
|
||||
|
||||
* glib/gutils.c (g_get_user_data_dir, g_get_user_config_dir,
|
||||
g_get_user_cache_dir, g_get_system_data_dirs,
|
||||
g_get_system_config_dirs): [Win32] Don't leak return value from
|
||||
get_special_folder(). (#169348, Daniel Atallah) Guard against
|
||||
g_home_dir being NULL, use g_tmp_dir/g_user_name in that case.
|
||||
|
||||
Tue Mar 8 15:46:54 2005 Søren Sandmann <sandmann@redhat.com>
|
||||
|
||||
* glib/gfileutils.c (g_file_replace): New API. A function to
|
||||
|
@ -1872,17 +1872,21 @@ g_get_user_data_dir (void)
|
||||
data_dir = get_special_folder (CSIDL_PERSONAL);
|
||||
#else
|
||||
data_dir = (gchar *) g_getenv ("XDG_DATA_HOME");
|
||||
#endif
|
||||
|
||||
if (data_dir && data_dir[0])
|
||||
data_dir = g_strdup (data_dir);
|
||||
else
|
||||
#endif
|
||||
if (!data_dir || !data_dir[0])
|
||||
{
|
||||
if (!g_tmp_dir)
|
||||
g_get_any_init ();
|
||||
|
||||
data_dir = g_build_filename (g_home_dir, ".local",
|
||||
"share", NULL);
|
||||
if (g_home_dir)
|
||||
data_dir = g_build_filename (g_home_dir, ".local",
|
||||
"share", NULL);
|
||||
else
|
||||
data_dir = g_build_filename (g_tmp_dir, g_user_name, ".local",
|
||||
"share", NULL);
|
||||
}
|
||||
|
||||
g_user_data_dir = data_dir;
|
||||
@ -1922,16 +1926,19 @@ g_get_user_config_dir (void)
|
||||
config_dir = get_special_folder (CSIDL_APPDATA);
|
||||
#else
|
||||
config_dir = (gchar *) g_getenv ("XDG_CONFIG_HOME");
|
||||
#endif
|
||||
|
||||
if (config_dir && config_dir[0])
|
||||
config_dir = g_strdup (config_dir);
|
||||
else
|
||||
#endif
|
||||
if (!config_dir || !config_dir[0])
|
||||
{
|
||||
if (!g_tmp_dir)
|
||||
g_get_any_init ();
|
||||
|
||||
config_dir = g_build_filename (g_home_dir, ".config", NULL);
|
||||
if (g_home_dir)
|
||||
config_dir = g_build_filename (g_home_dir, ".config", NULL);
|
||||
else
|
||||
config_dir = g_build_filename (g_tmp_dir, g_user_name, ".config", NULL);
|
||||
}
|
||||
g_user_config_dir = config_dir;
|
||||
}
|
||||
@ -1970,15 +1977,19 @@ g_get_user_cache_dir (void)
|
||||
cache_dir = get_special_folder (CSIDL_INTERNET_CACHE); /* XXX correct? */
|
||||
#else
|
||||
cache_dir = (gchar *) g_getenv ("XDG_CACHE_HOME");
|
||||
#endif
|
||||
|
||||
if (cache_dir && cache_dir[0])
|
||||
cache_dir = g_strdup (cache_dir);
|
||||
else
|
||||
#endif
|
||||
if (!cache_dir || !cache_dir[0])
|
||||
{
|
||||
if (!g_tmp_dir)
|
||||
g_get_any_init ();
|
||||
|
||||
cache_dir = g_build_filename (g_home_dir, ".cache", NULL);
|
||||
if (g_home_dir)
|
||||
cache_dir = g_build_filename (g_home_dir, ".cache", NULL);
|
||||
else
|
||||
cache_dir = g_build_filename (g_tmp_dir, g_user_name, ".cache", NULL);
|
||||
}
|
||||
g_user_cache_dir = cache_dir;
|
||||
}
|
||||
@ -2014,17 +2025,43 @@ g_get_system_data_dirs (void)
|
||||
if (!g_system_data_dirs)
|
||||
{
|
||||
#ifdef G_OS_WIN32
|
||||
data_dirs = g_strconcat (get_special_folder (CSIDL_COMMON_APPDATA),
|
||||
G_SEARCHPATH_SEPARATOR_S,
|
||||
get_special_folder (CSIDL_COMMON_DOCUMENTS),
|
||||
NULL);
|
||||
char *appdata = get_special_folder (CSIDL_COMMON_APPDATA);
|
||||
char *docs = get_special_folder (CSIDL_COMMON_DOCUMENTS);
|
||||
|
||||
if (appdata && docs)
|
||||
{
|
||||
data_dirs = g_strconcat (appdata,
|
||||
G_SEARCHPATH_SEPARATOR_S,
|
||||
docs,
|
||||
NULL);
|
||||
g_free (appdata);
|
||||
g_free (docs);
|
||||
}
|
||||
else if (appdata)
|
||||
data_dirs = appdata;
|
||||
else if (docs)
|
||||
data_dirs = docs;
|
||||
else
|
||||
data_dirs = NULL;
|
||||
|
||||
if (data_dirs)
|
||||
{
|
||||
data_dir_vector = g_strsplit (data_dirs, G_SEARCHPATH_SEPARATOR_S, 0);
|
||||
g_free (data_dirs);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Punt, return empty list */
|
||||
data_dir_vector = g_strsplit ("", G_SEARCHPATH_SEPARATOR_S, 0);
|
||||
}
|
||||
#else
|
||||
data_dirs = (gchar *) g_getenv ("XDG_DATA_DIRS");
|
||||
|
||||
if (!data_dirs || !data_dirs[0])
|
||||
data_dirs = "/usr/local/share/:/usr/share/";
|
||||
#endif
|
||||
|
||||
data_dir_vector = g_strsplit (data_dirs, G_SEARCHPATH_SEPARATOR_S, 0);
|
||||
#endif
|
||||
|
||||
g_system_data_dirs = data_dir_vector;
|
||||
}
|
||||
@ -2061,13 +2098,24 @@ g_get_system_config_dirs (void)
|
||||
{
|
||||
#ifdef G_OS_WIN32
|
||||
conf_dirs = get_special_folder (CSIDL_COMMON_APPDATA);
|
||||
if (conf_dirs)
|
||||
{
|
||||
conf_dir_vector = g_strsplit (conf_dirs, G_SEARCHPATH_SEPARATOR_S, 0);
|
||||
g_free (conf_dirs);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Return empty list */
|
||||
conf_dir_vector = g_strsplit ("", G_SEARCHPATH_SEPARATOR_S, 0);
|
||||
}
|
||||
#else
|
||||
conf_dirs = (gchar *) g_getenv ("XDG_CONFIG_DIRS");
|
||||
|
||||
if (!conf_dirs || !conf_dirs[0])
|
||||
conf_dirs = "/etc/xdg";
|
||||
#endif
|
||||
|
||||
conf_dir_vector = g_strsplit (conf_dirs, G_SEARCHPATH_SEPARATOR_S, 0);
|
||||
#endif
|
||||
|
||||
g_system_config_dirs = conf_dir_vector;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user