addedd gcc-4.4.0
[dottout.git] / x11-libs / gtk+ / files / gtk+-2.10.11-update-icon-subdirs.patch
blob64cbb0f75942a3febf04c31f4b29e921507d194a
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 */
18 +int
19 +dir_check (const gchar *path, time_t cache_time)
21 + struct stat path_stat;
23 + if (g_stat (path, &path_stat) < 0)
24 + {
25 + return -1;
26 + }
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. */
32 +gboolean
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;
38 + int dir_state;
40 + topdir = g_dir_open (toppath, 0, NULL);
41 + if (!topdir)
42 + {
43 + /* we can't open dir, assume updated cache */
44 + return TRUE;
45 + }
47 + while ((name = g_dir_read_name (topdir)))
48 + {
49 + path = g_build_filename (toppath, name, NULL);
50 + dir_state = dir_check (path, cache_time);
51 + if (dir_state < 0)
52 + {
53 + /* cannot stat dir, for some reason; skip */
54 + g_free (path);
55 + continue;
56 + }
57 + else if (dir_state > 0)
58 + {
59 + /* cache is out of date */
60 + g_free (path);
61 + return FALSE;
62 + }
64 + subdir = g_dir_open (path, 0, NULL);
65 + if (!subdir)
66 + {
67 + /* Cannot open subdir; skip */
68 + g_free (path);
69 + continue;
70 + }
71 + while ((subname = g_dir_read_name (subdir)))
72 + {
73 + subpath = g_build_filename (path, subname, NULL);
74 + dir_state = dir_check (subpath, cache_time);
75 + g_free (subpath);
77 + if (dir_state > 0)
78 + {
79 + /* Cache out of date */
80 + return FALSE;
81 + }
82 + }
83 + g_free (path);
84 + }
86 + /* If we get here, the cache is up to date */
87 + return TRUE;
90 gboolean
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;
95 gchar *cache_path;
96 @@ -88,7 +163,18 @@ is_cache_up_to_date (const gchar *path)
99 /* Check mtime */
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 */
104 + return FALSE;
106 + if (check_subdirs)
108 + return is_cache_up_to_date_subdirs (path, cache_stat.st_mtime);
111 + /* Cache is up to date */
112 + return TRUE;
115 gboolean
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 },
121 { NULL }
124 @@ -1316,7 +1403,7 @@ main (int argc, char **argv)
125 return 1;
128 - if (!force_update && is_cache_up_to_date (path))
129 + if (!force_update && is_cache_up_to_date (path, check_subdirs))
130 return 0;
132 g_type_init ();