summaryrefslogtreecommitdiff
path: root/gtk/updateiconcache.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2007-01-27 04:27:38 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2007-01-27 04:27:38 +0000
commit84cb26f73f2d9d65452be29c8d6e41ad9c350428 (patch)
treec883fe67b0a343a80506f383a58104b4d564f756 /gtk/updateiconcache.c
parent51a5dad07e91aeb0867dab31387bc7fa09eb2e53 (diff)
downloadgtk+-84cb26f73f2d9d65452be29c8d6e41ad9c350428.tar.gz
Check the mtime of all directories, not just the toplevel, if ftw() is
2007-01-26 Matthias Clasen <mclasen@redhat.com> * gtk/updateiconcache.c: Check the mtime of all directories, not just the toplevel, if ftw() is available. (#331671, Behdad Esfahbod) * configure.in: Check for ftw.h. svn path=/trunk/; revision=17221
Diffstat (limited to 'gtk/updateiconcache.c')
-rw-r--r--gtk/updateiconcache.c54
1 files changed, 51 insertions, 3 deletions
diff --git a/gtk/updateiconcache.c b/gtk/updateiconcache.c
index 5aec9a2f00..a9c4cb7347 100644
--- a/gtk/updateiconcache.c
+++ b/gtk/updateiconcache.c
@@ -62,16 +62,62 @@ static gchar *var_name = "-";
#define ALIGN_VALUE(this, boundary) \
(( ((unsigned long)(this)) + (((unsigned long)(boundary)) -1)) & (~(((unsigned long)(boundary))-1)))
-static gboolean
+#ifdef HAVE_FTW_H
+
+#include <ftw.h>
+
+static struct stat cache_stat;
+static gboolean cache_up_to_date;
+
+static int check_dir_mtime (const char *dir,
+ const struct stat *sb,
+ int tf)
+{
+ if (tf != FTW_NS && sb->st_mtime > cache_stat.st_mtime)
+ {
+ cache_up_to_date = FALSE;
+ /* stop tree walk */
+ return 1;
+ }
+
+ return 0;
+}
+
+ gboolean
+ is_cache_up_to_date (const gchar *path)
+ {
+ gchar *cache_path;
+ gint retval;
+
+ cache_path = g_build_filename (path, CACHE_NAME, NULL);
+ retval = g_stat (cache_path, &cache_stat);
+ g_free (cache_path);
+
+ if (retval < 0)
+ {
+ /* Cache file not found */
+ return FALSE;
+ }
+
+ cache_up_to_date = TRUE;
+
+ ftw (path, check_dir_mtime, 20);
+
+ return cache_up_to_date;
+}
+
+#else /* !HAVE_FTW_H */
+
+gboolean
is_cache_up_to_date (const gchar *path)
{
struct stat path_stat, cache_stat;
gchar *cache_path;
- int retval;
+ int retval;
retval = g_stat (path, &path_stat);
- if (retval < 0)
+ if (retval < 0)
{
/* We can't stat the path,
* assume we have a updated cache */
@@ -92,6 +138,8 @@ is_cache_up_to_date (const gchar *path)
return cache_stat.st_mtime >= path_stat.st_mtime;
}
+#endif /* !HAVE_FTW_H */
+
static gboolean
has_theme_index (const gchar *path)
{