On 12/17/19 11:41 AM, Fabiano Fidêncio wrote:
> Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
> ---
> src/util/virutil.c | 35 ++++++-----------------------------
> 1 file changed, 6 insertions(+), 29 deletions(-)
>
> diff --git a/src/util/virutil.c b/src/util/virutil.c
> index 8c255abd7f..63680974b8 100644
> --- a/src/util/virutil.c
> +++ b/src/util/virutil.c
> @@ -586,6 +586,12 @@ virGetUserDirectory(void)
> }
>
>
> +char *virGetUserConfigDirectory(void)
> +{
> + return g_strdup_printf("%s/libvirt", g_get_user_config_dir());
> +}
> +
> +
> #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 +760,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 +1188,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;
> -}
> -
Unfortunately looks like the windows implementations do _not_ add
'/libvirt' to the returned directory. I'm doubtful anyone is depending
on these paths being stable, but for safety we should differentiate
this. I think it's fine to do:
#ifdef WIN32
return g_strdup(g_get_blah());
#else
return g_strdup_print(...);
#endif
Rather than have two different functions
Also, a couple ideas for a follow up series: all the error handling from
the GetUser*Directory functions can be removed after this. Also, the it
looks like the windows impl of virGetUserDirectoryByUID can be entirely
replaced with g_get_user_home(), which allows dropping some more windows
helpers (the code was apparently adapted from glib anyways)
- Cole
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list