提交 e59b946c 编写于 作者: F Fabiano Fidêncio

util: Rewrite virGetUserConfigDirectory() using g_get_user_config_dir()

Signed-off-by: NFabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: NCole Robinson <crobinso@redhat.com>
上级 850fb89a
...@@ -586,6 +586,16 @@ virGetUserDirectory(void) ...@@ -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 #ifdef HAVE_GETPWUID_R
/* Look up fields from the user database for the given user. On /* Look up fields from the user database for the given user. On
* error, set errno, report the error if not instructed otherwise via @quiet, * 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) ...@@ -754,11 +764,6 @@ static char *virGetXDGDirectory(const char *xdgenvname, const char *xdgdefdir)
return ret; return ret;
} }
char *virGetUserConfigDirectory(void)
{
return virGetXDGDirectory("XDG_CONFIG_HOME", ".config");
}
char *virGetUserCacheDirectory(void) char *virGetUserCacheDirectory(void)
{ {
return virGetXDGDirectory("XDG_CACHE_HOME", ".cache"); return virGetXDGDirectory("XDG_CACHE_HOME", ".cache");
...@@ -1187,21 +1192,6 @@ virGetUserShell(uid_t uid G_GNUC_UNUSED) ...@@ -1187,21 +1192,6 @@ virGetUserShell(uid_t uid G_GNUC_UNUSED)
return NULL; 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 * char *
virGetUserCacheDirectory(void) virGetUserCacheDirectory(void)
{ {
...@@ -1242,15 +1232,6 @@ virGetUserShell(uid_t uid G_GNUC_UNUSED) ...@@ -1242,15 +1232,6 @@ virGetUserShell(uid_t uid G_GNUC_UNUSED)
return NULL; return NULL;
} }
char *
virGetUserConfigDirectory(void)
{
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virGetUserConfigDirectory is not available"));
return NULL;
}
char * char *
virGetUserCacheDirectory(void) virGetUserCacheDirectory(void)
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册