From nobody Tue Feb 10 04:17:21 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576615327; cv=none; d=zohomail.com; s=zohoarc; b=Um+l83MQB03e04f1AflKc8phAYHIDpMY9Uc/Qt1qBWiThv8bYnrPQ2Awy8R0eSA5HsNn7P6lQMXi67ZQxZWnaIgnDBjrwJH4yy/OQRecalo0jJD8q1v6UHmxytqwwbp2klswaLORDeGsErnI8IBNENw4axkDJged+nBqvX9glw4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576615327; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aE6LRpuM2yDtFloR3gXK89O3/XBzrIYBqkwwhxTsn6o=; b=hBuY2hHQSqemwRTX7hWL1rQo48kwDRht/sWODksCHANBXH/HT/gLyq1JE+YaFy+JykXHOJD0XxqxzOhtazCKVPBDWmeV3/8zs74ekTQm+iPOjCVFdYe84P3Vj8NnJTcUInE5yhPEl4m+TsgUknA6MyRi7iSDcBKxh9ukK2Egzio= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1576615327020396.40528649096734; Tue, 17 Dec 2019 12:42:07 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-42-l5kKSh0GPjO5XsneQScYmg-1; Tue, 17 Dec 2019 15:41:27 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D0C5D101F4E2; Tue, 17 Dec 2019 20:41:21 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A2D1A61355; Tue, 17 Dec 2019 20:41:21 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5AA9218089C8; Tue, 17 Dec 2019 20:41:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xBHKeUC0006629 for ; Tue, 17 Dec 2019 15:40:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id 12D436FF0F; Tue, 17 Dec 2019 20:40:30 +0000 (UTC) Received: from laerte.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 66BB17C856; Tue, 17 Dec 2019 20:40:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576615322; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=aE6LRpuM2yDtFloR3gXK89O3/XBzrIYBqkwwhxTsn6o=; b=cT3Vh71w1SLdcpJN+eEbcOQbR3euhpJfkpgIVlEy3GW1ZI7gwbbuCjeWh2Vtl5jSlGXXpy 46nk09QN+UDRsN7Mi6lYUQNoOzvoJK2LS1U1VTgbKYRlX3js2JZKxBA5VR6Dc7+D/qJeaI /MMpjiZxVs/Ssqwwz7nM/D1GRvsgJxQ= From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= To: libvir-list@redhat.com Date: Tue, 17 Dec 2019 21:40:20 +0100 Message-Id: <20191217204021.1018731-4-fidencio@redhat.com> In-Reply-To: <20191217204021.1018731-1-fidencio@redhat.com> References: <20191217204021.1018731-1-fidencio@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Subject: [libvirt] [PATCH v3 3/4] util: Rewrite virGetUserCacheDirectory() using g_get_user_cache_dir() X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: l5kKSh0GPjO5XsneQScYmg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Fabiano Fid=C3=AAncio --- src/util/virutil.c | 57 ++++++++-------------------------------------- 1 file changed, 10 insertions(+), 47 deletions(-) diff --git a/src/util/virutil.c b/src/util/virutil.c index 1bcdde9ad6..2e8b4e95b7 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -596,6 +596,16 @@ char *virGetUserConfigDirectory(void) } =20 =20 +char *virGetUserCacheDirectory(void) +{ +#ifdef WIN32 + return g_strdup(g_get_user_cache_dir()); +#else + return g_strdup_printf("%s/libvirt", g_get_user_cache_dir()); +#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 @qui= et, @@ -746,29 +756,6 @@ char *virGetUserShell(uid_t uid) } =20 =20 -static char *virGetXDGDirectory(const char *xdgenvname, const char *xdgdef= dir) -{ - const char *path =3D getenv(xdgenvname); - char *ret =3D NULL; - char *home =3D NULL; - - if (path && path[0]) { - ret =3D g_strdup_printf("%s/libvirt", path); - } else { - home =3D virGetUserDirectory(); - if (home) - ret =3D g_strdup_printf("%s/%s/libvirt", home, xdgdefdir); - } - - VIR_FREE(home); - return ret; -} - -char *virGetUserCacheDirectory(void) -{ - return virGetXDGDirectory("XDG_CACHE_HOME", ".cache"); -} - char *virGetUserRuntimeDirectory(void) { const char *path =3D getenv("XDG_RUNTIME_DIR"); @@ -1192,21 +1179,6 @@ virGetUserShell(uid_t uid G_GNUC_UNUSED) return NULL; } =20 -char * -virGetUserCacheDirectory(void) -{ - char *ret; - if (virGetWin32SpecialFolder(CSIDL_INTERNET_CACHE, &ret) < 0) - return NULL; - - if (!ret) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to determine config directory")); - return NULL; - } - return ret; -} - char * virGetUserRuntimeDirectory(void) { @@ -1232,15 +1204,6 @@ virGetUserShell(uid_t uid G_GNUC_UNUSED) return NULL; } =20 -char * -virGetUserCacheDirectory(void) -{ - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("virGetUserCacheDirectory is not available")); - - return NULL; -} - char * virGetUserRuntimeDirectory(void) { --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list