[recipes] Add api to get cache dir
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Add api to get cache dir
- Date: Thu, 6 Apr 2017 03:25:19 +0000 (UTC)
commit 7916349a4cde37151c4ad3ff76ed01db73c8efe6
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Apr 5 21:44:08 2017 -0400
Add api to get cache dir
This avoid adding a gnome-recipes subdirectory in the flatpak
case, where it is unnecessary.
src/gr-utils.c | 16 ++++++++++++++++
src/gr-utils.h | 1 +
2 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/src/gr-utils.c b/src/gr-utils.c
index 86c6872..e4b08b8 100644
--- a/src/gr-utils.c
+++ b/src/gr-utils.c
@@ -125,6 +125,22 @@ get_user_data_dir (void)
}
const char *
+get_user_cache_dir (void)
+{
+ static char *dir = NULL;
+
+ if (!dir) {
+ if (in_flatpak_sandbox ())
+ dir = g_strdup (g_get_user_cache_dir ());
+ else
+ dir = g_build_filename (g_get_user_cache_dir (), PACKAGE_NAME, NULL);
+ g_mkdir_with_parents (dir, S_IRWXU | S_IRWXG | S_IRWXO);
+ }
+
+ return (const char *)dir;
+}
+
+const char *
get_pkg_data_dir (void)
{
static char *dir = NULL;
diff --git a/src/gr-utils.h b/src/gr-utils.h
index 1214238..3a8c79a 100644
--- a/src/gr-utils.h
+++ b/src/gr-utils.h
@@ -38,6 +38,7 @@ void pixbuf_blur (GdkPixbuf *src,
const char *get_pkg_data_dir (void);
const char *get_user_data_dir (void);
+const char *get_user_cache_dir (void);
void container_remove_all (GtkContainer *container);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]