[gnome-video-arcade] Add gva_get_user_cache_dir().
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-video-arcade] Add gva_get_user_cache_dir().
- Date: Tue, 27 Mar 2018 17:26:11 +0000 (UTC)
commit 047e633dfb700650065d913cbb2795ba2e20b094
Author: Matthew Barnes <mbarnes fedoraproject org>
Date: Wed Dec 27 23:09:57 2017 -0500
Add gva_get_user_cache_dir().
Returns the directory where user-specific cached application files are
stored.
docs/reference/gnome-video-arcade-sections.txt | 1 +
src/gva-util.c | 28 ++++++++++++++++++++++++
src/gva-util.h | 1 +
3 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gnome-video-arcade-sections.txt b/docs/reference/gnome-video-arcade-sections.txt
index ed644b8..49495e9 100644
--- a/docs/reference/gnome-video-arcade-sections.txt
+++ b/docs/reference/gnome-video-arcade-sections.txt
@@ -502,6 +502,7 @@ gva_get_monospace_font_name
gva_get_settings
gva_get_soup_session
gva_get_time_elapsed
+gva_get_user_cache_dir
gva_get_user_data_dir
gva_help_display
gva_save_window_state
diff --git a/src/gva-util.c b/src/gva-util.c
index 7e5ac12..8031d92 100644
--- a/src/gva-util.c
+++ b/src/gva-util.c
@@ -321,6 +321,34 @@ gva_get_time_elapsed (GTimeVal *start_time,
}
/**
+ * gva_get_user_cache_dir:
+ *
+ * Returns the directory where user-specific cached application files
+ * are stored. The function also creates the directory the first time
+ * it is called.
+ *
+ * Returns: user-specific application cache directory
+ **/
+const gchar *
+gva_get_user_cache_dir (void)
+{
+ static gchar *user_cache_dir = NULL;
+
+ if (G_UNLIKELY (user_cache_dir == NULL))
+ {
+ user_cache_dir = g_build_filename (
+ g_get_user_cache_dir (), PACKAGE, NULL);
+
+ if (g_mkdir_with_parents (user_cache_dir, 0700) < 0)
+ g_warning (
+ "Unable to create %s: %s",
+ user_cache_dir, g_strerror (errno));
+ }
+
+ return user_cache_dir;
+}
+
+/**
* gva_get_user_data_dir:
*
* Returns the directory where user-specific application data is stored.
diff --git a/src/gva-util.h b/src/gva-util.h
index 34bf001..8006061 100644
--- a/src/gva-util.h
+++ b/src/gva-util.h
@@ -70,6 +70,7 @@ GSettings * gva_get_settings (void);
SoupSession * gva_get_soup_session (void);
void gva_get_time_elapsed (GTimeVal *start_time,
GTimeVal *time_elapsed);
+const gchar * gva_get_user_cache_dir (void);
const gchar * gva_get_user_data_dir (void);
void gva_help_display (GtkWindow *parent,
const gchar *link_id);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]