From 1e45ff23057a135deb3b01f3325f7b22ca720929 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Sun, 8 Aug 2021 09:36:17 +0200 Subject: [PATCH] WUtil: New function wuserdatapath() to get path for application data Returns the path in the user's GNUstep library: ~/GNUstep/Library --- WINGs/WINGs/WUtil.h | 1 + WINGs/userdefaults.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/WINGs/WINGs/WUtil.h b/WINGs/WINGs/WUtil.h index 0410c4f2..feff8ae8 100644 --- a/WINGs/WINGs/WUtil.h +++ b/WINGs/WINGs/WUtil.h @@ -864,6 +864,7 @@ Bool WMWritePropListToFile(WMPropList *plist, const char *path); /* don't free the returned string */ const char* wusergnusteppath(void); +const char* wuserdatapath(void); /* Free the returned string when you no longer need it */ char* wdefaultspathfordomain(const char *domain); diff --git a/WINGs/userdefaults.c b/WINGs/userdefaults.c index 6eb372c2..ea4ad3c4 100644 --- a/WINGs/userdefaults.c +++ b/WINGs/userdefaults.c @@ -81,6 +81,19 @@ const char *wusergnusteppath() return path; } +const char *wuserdatapath(void) +{ + static char *path = NULL; + + if (path) + /* Value have been already computed, re-use it */ + return path; + + path = wstrconcat(wusergnusteppath(), "/" USERDATA_SUBDIR); + + return path; +} + char *wdefaultspathfordomain(const char *domain) { char *path;