mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
util: Rewrite virGetUserConfigDirectory() using g_get_user_config_dir()
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com> Reviewed-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
850fb89a43
commit
e59b946ce4
@ -586,6 +586,16 @@ virGetUserDirectory(void)
|
||||
}
|
||||
|
||||
|
||||
char *virGetUserConfigDirectory(void)
|
||||
{
|
||||
#ifdef WIN32
|
||||
return g_strdup(g_get_user_config_dir());
|
||||
#else
|
||||
return g_build_filename(g_get_user_config_dir(), "libvirt", NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_GETPWUID_R
|
||||
/* Look up fields from the user database for the given user. On
|
||||
* error, set errno, report the error if not instructed otherwise via @quiet,
|
||||
@ -754,11 +764,6 @@ static char *virGetXDGDirectory(const char *xdgenvname, const char *xdgdefdir)
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *virGetUserConfigDirectory(void)
|
||||
{
|
||||
return virGetXDGDirectory("XDG_CONFIG_HOME", ".config");
|
||||
}
|
||||
|
||||
char *virGetUserCacheDirectory(void)
|
||||
{
|
||||
return virGetXDGDirectory("XDG_CACHE_HOME", ".cache");
|
||||
@ -1187,21 +1192,6 @@ virGetUserShell(uid_t uid G_GNUC_UNUSED)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
virGetUserConfigDirectory(void)
|
||||
{
|
||||
char *ret;
|
||||
if (virGetWin32SpecialFolder(CSIDL_LOCAL_APPDATA, &ret) < 0)
|
||||
return NULL;
|
||||
|
||||
if (!ret) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Unable to determine config directory"));
|
||||
return NULL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *
|
||||
virGetUserCacheDirectory(void)
|
||||
{
|
||||
@ -1242,15 +1232,6 @@ virGetUserShell(uid_t uid G_GNUC_UNUSED)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
virGetUserConfigDirectory(void)
|
||||
{
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("virGetUserConfigDirectory is not available"));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
virGetUserCacheDirectory(void)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user