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

util: Rewrite virGetUserRuntimeDirectory() using g_get_user_runtime_dir()

Signed-off-by: NFabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: NCole Robinson <crobinso@redhat.com>
上级 520e626e
......@@ -606,6 +606,16 @@ char *virGetUserCacheDirectory(void)
}
char *virGetUserRuntimeDirectory(void)
{
#ifdef WIN32
return g_strdup(g_get_user_runtime_dir());
#else
return g_build_filename(g_get_user_runtime_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,
......@@ -756,20 +766,6 @@ char *virGetUserShell(uid_t uid)
}
char *virGetUserRuntimeDirectory(void)
{
const char *path = getenv("XDG_RUNTIME_DIR");
if (!path || !path[0]) {
return virGetUserCacheDirectory();
} else {
char *ret;
ret = g_strdup_printf("%s/libvirt", path);
return ret;
}
}
char *virGetUserName(uid_t uid)
{
char *ret;
......@@ -1179,12 +1175,6 @@ virGetUserShell(uid_t uid G_GNUC_UNUSED)
return NULL;
}
char *
virGetUserRuntimeDirectory(void)
{
return virGetUserCacheDirectory();
}
# else /* !HAVE_GETPWUID_R && !WIN32 */
char *
virGetUserDirectoryByUID(uid_t uid G_GNUC_UNUSED)
......@@ -1203,15 +1193,6 @@ virGetUserShell(uid_t uid G_GNUC_UNUSED)
return NULL;
}
char *
virGetUserRuntimeDirectory(void)
{
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virGetUserRuntimeDirectory is not available"));
return NULL;
}
# endif /* ! HAVE_GETPWUID_R && ! WIN32 */
char *
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册