1 diff --exclude-from=/home/dang/bin/scripts/diffrc -up -ruN gtk+-2.10.11.orig/gtk/updateiconcache.c gtk+-2.10.11/gtk/updateiconcache.c
2 --- gtk+-2.10.11.orig/gtk/updateiconcache.c 2007-03-14 00:07:02.000000000 -0400
3 +++ gtk+-2.10.11/gtk/updateiconcache.c 2007-05-01 17:01:46.000000000 -0400
4 @@ -43,6 +43,7 @@ static gboolean force_update = FALSE;
5 static gboolean ignore_theme_index = FALSE;
6 static gboolean quiet = FALSE;
7 static gboolean index_only = FALSE;
8 +static gboolean check_subdirs = FALSE;
9 static gchar *var_name = "-";
11 #define CACHE_NAME "icon-theme.cache"
12 @@ -61,8 +62,82 @@ static gchar *var_name = "-";
13 #define ALIGN_VALUE(this, boundary) \
14 (( ((unsigned long)(this)) + (((unsigned long)(boundary)) -1)) & (~(((unsigned long)(boundary))-1)))
16 +/* returns >0 if dir is newer than time, 0 if dir is older than time,
17 + * <0 if stat fails */
19 +dir_check (const gchar *path, time_t cache_time)
21 + struct stat path_stat;
23 + if (g_stat (path, &path_stat) < 0)
27 + return cache_time < path_stat.st_mtime;
30 +/* Check the subdirectories of the cache dir to see if the cache is up-to-date
31 + * We check first and second level subdirs. */
33 +is_cache_up_to_date_subdirs (const gchar *toppath, time_t cache_time)
35 + GDir *topdir, *subdir;
36 + const gchar *name, *subname;
37 + gchar *path, *subpath;
40 + topdir = g_dir_open (toppath, 0, NULL);
43 + /* we can't open dir, assume updated cache */
47 + while ((name = g_dir_read_name (topdir)))
49 + path = g_build_filename (toppath, name, NULL);
50 + dir_state = dir_check (path, cache_time);
53 + /* cannot stat dir, for some reason; skip */
57 + else if (dir_state > 0)
59 + /* cache is out of date */
64 + subdir = g_dir_open (path, 0, NULL);
67 + /* Cannot open subdir; skip */
71 + while ((subname = g_dir_read_name (subdir)))
73 + subpath = g_build_filename (path, subname, NULL);
74 + dir_state = dir_check (subpath, cache_time);
79 + /* Cache out of date */
86 + /* If we get here, the cache is up to date */
91 -is_cache_up_to_date (const gchar *path)
92 +is_cache_up_to_date (const gchar *path, gboolean check_subdirs)
94 struct stat path_stat, cache_stat;
96 @@ -88,7 +163,18 @@ is_cache_up_to_date (const gchar *path)
100 - return cache_stat.st_mtime >= path_stat.st_mtime;
101 + if (cache_stat.st_mtime < path_stat.st_mtime)
103 + /* Cache is out of date */
108 + return is_cache_up_to_date_subdirs (path, cache_stat.st_mtime);
111 + /* Cache is up to date */
116 @@ -1284,6 +1370,7 @@ static GOptionEntry args[] = {
117 { "index-only", 'i', 0, G_OPTION_ARG_NONE, &index_only, N_("Don't include image data in the cache"), NULL },
118 { "source", 'c', 0, G_OPTION_ARG_STRING, &var_name, N_("Output a C header file"), "NAME" },
119 { "quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet, N_("Turn off verbose output"), NULL },
120 + { "check-subdirs", 's', 0, G_OPTION_ARG_NONE, &check_subdirs, N_("Check subdirectories when determining if cache is up-to-date"), NULL },
124 @@ -1316,7 +1403,7 @@ main (int argc, char **argv)
128 - if (!force_update && is_cache_up_to_date (path))
129 + if (!force_update && is_cache_up_to_date (path, check_subdirs))