mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-26 05:56:14 +01:00
g_get_user_runtime_dir(): New function
Get the value of the XDG_RUNTIME_DIR environment variable.
This commit is contained in:
parent
71088701af
commit
ba9fccf71e
@ -1607,6 +1607,7 @@ g_get_real_name
|
||||
g_get_user_cache_dir
|
||||
g_get_user_data_dir
|
||||
g_get_user_config_dir
|
||||
g_get_user_runtime_dir
|
||||
GUserDirectory
|
||||
g_get_user_special_dir
|
||||
g_get_system_data_dirs
|
||||
|
@ -2290,6 +2290,55 @@ g_get_user_cache_dir (void)
|
||||
return cache_dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_get_user_runtime_dir:
|
||||
*
|
||||
* Returns a directory that is unique to the current user on the local
|
||||
* system.
|
||||
*
|
||||
* On UNIX platforms this is determined using the mechanisms described in
|
||||
* the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
|
||||
* XDG Base Directory Specification</ulink>. This is the directory
|
||||
* specified in the XDG_RUNTIME_DIR environment variable. In the case
|
||||
* that this variable is not set, glib will issue a warning message to
|
||||
* stderr and return the value of g_get_user_cache_dir().
|
||||
*
|
||||
* On Windows this is the folder to use for local (as opposed to
|
||||
* roaming) application data. See documentation for
|
||||
* CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
|
||||
* what g_get_user_config_dir() returns.
|
||||
*
|
||||
* Returns: a string owned by GLib that must not be modified or freed.
|
||||
**/
|
||||
const gchar *
|
||||
g_get_user_runtime_dir (void)
|
||||
{
|
||||
#ifndef G_OS_WIN32
|
||||
static const gchar *runtime_dir;
|
||||
static gsize initialised;
|
||||
|
||||
if (g_once_init_enter (&initialised))
|
||||
{
|
||||
runtime_dir = g_strdup (getenv ("XDG_RUNTIME_DIR"));
|
||||
|
||||
if (runtime_dir == NULL)
|
||||
g_warning ("XDG_RUNTIME_DIR variable not set. "
|
||||
"Falling back to XDG cache dir.");
|
||||
|
||||
g_once_init_leave (&initialised, 1);
|
||||
}
|
||||
|
||||
if (runtime_dir)
|
||||
return runtime_dir;
|
||||
|
||||
/* Both fallback for UNIX and the default
|
||||
* in Windows: use the user cache directory.
|
||||
*/
|
||||
#endif
|
||||
|
||||
return g_get_user_cache_dir ();
|
||||
}
|
||||
|
||||
#ifdef HAVE_CARBON
|
||||
|
||||
static gchar *
|
||||
|
@ -153,6 +153,8 @@ _g_win32_get_system_data_dirs (void)
|
||||
|
||||
G_CONST_RETURN gchar* G_CONST_RETURN * g_get_system_config_dirs (void);
|
||||
|
||||
const gchar * g_get_user_runtime_dir (void);
|
||||
|
||||
G_CONST_RETURN gchar* G_CONST_RETURN * g_get_language_names (void);
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user