annotate src/cache.c @ 622:54e20abb5c6d

Fix display of collection in overlay info. Due to markup escaped <i>collection</i> was displayed instead of collection's in italic. Overlay info syntax was extended to allow the wrapping of displayed data with markup. General syntax is: %name[:length limit][:extra]% Extra string uses special character '*' to mark the place of the data to display. If no '*' is present, then extra string is just appended to data. Any "\n" is replaced by a newline on display. Pango mark up is accepted in left and right parts. If data is empty, nothing will be displayed. Examples: "%name:<i>*</i>\n%" -> name is displayed in italics ended with a newline "%size:\n%" -> size is displayed with a newline at end "%formatted.ISOSpeedRating:ISO *%" -> prefix iso number with "ISO " (ie. "ISO 100") "Collection <b>*</b>\n" -> display collection name in bold prefixed by "Collection " and a newline is appended Collection name formatting was slighly improved by not displaying the .gqv extension. The default overlay info string was modified to use the new syntax, but older info strings should be displayed as usual.
author zas_
date Sat, 10 May 2008 21:29:53 +0000
parents d4fe3a947929
children 8268cbe682f1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1 /*
196
f6e307c7bad6 rename GQview -> Geeqie over the code
nadvornik
parents: 65
diff changeset
2 * Geeqie
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3 * (C) 2004 John Ellis
475
48c8e49b571c updated copyright in source files
nadvornik
parents: 446
diff changeset
4 * Copyright (C) 2008 The Geeqie Team
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
5 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
6 * Author: John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
7 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
8 * This software is released under the GNU General Public License (GNU GPL).
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
9 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
10 * This software comes with no warranty of any kind, use at your own risk!
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
11 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
12
281
9995c5fb202a gqview.h -> main.h
zas_
parents: 196
diff changeset
13 #include "main.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
14 #include "cache.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
15
507
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents: 506
diff changeset
16 #include "debug.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
17 #include "md5-util.h"
538
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
18 #include "secure_save.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
19 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
20
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
21 #include <utime.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
22 #include <errno.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
24
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
25 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
26 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
27 * Cache data file format:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
28 *-------------------------------------------------------------------
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 333
diff changeset
29 *
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
30 * SIMcache
535
8123d713dd3f Typo fix.
zas_
parents: 517
diff changeset
31 * #comment
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
32 * Dimensions=[<width> x <height>]
37
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
33 * Date=[<value in time_t format, or -1 if no embedded date>]
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34 * Checksum=[<value>]
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
35 * MD5sum=[<32 character ascii text digest>]
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
36 * SimilarityGrid[32 x 32]=<3072 bytes of data (1024 pixels in RGB format, 1 pixel is 24bits)>
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 333
diff changeset
37 *
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 333
diff changeset
38 *
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39 * The first line (9 bytes) indicates it is a SIMcache format file. (new line char must exist)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
40 * Comment lines starting with a # are ignored up to a new line.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
41 * All data lines should end with a new line char.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
42 * Format is very strict, data must begin with the char immediately following '='.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
43 * Currently SimilarityGrid is always assumed to be 32 x 32 RGB.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
45
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
46
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
48 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
49 * sim cache data
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
50 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
52
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
53 CacheData *cache_sim_data_new(void)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
54 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55 CacheData *cd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
56
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
57 cd = g_new0(CacheData, 1);
37
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
58 cd->date = -1;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
59
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
60 return cd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63 void cache_sim_data_free(CacheData *cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
64 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
65 if (!cd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
66
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
67 g_free(cd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
68 image_sim_free(cd->sim);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
69 g_free(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
70 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
71
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
72 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
73 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74 * sim cache write
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
77
538
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
78 static gint cache_sim_write_dimensions(SecureSaveInfo *ssi, CacheData *cd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
79 {
538
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
80 if (!cd || !cd->dimensions) return FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81
538
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
82 secure_fprintf(ssi, "Dimensions=[%d x %d]\n", cd->width, cd->height);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
83
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
84 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
85 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
86
538
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
87 static gint cache_sim_write_date(SecureSaveInfo *ssi, CacheData *cd)
37
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
88 {
538
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
89 if (!cd || !cd->have_date) return FALSE;
37
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
90
538
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
91 secure_fprintf(ssi, "Date=[%ld]\n", cd->date);
37
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
92
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
93 return TRUE;
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
94 }
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
95
538
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
96 static gint cache_sim_write_checksum(SecureSaveInfo *ssi, CacheData *cd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97 {
538
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
98 if (!cd || !cd->have_checksum) return FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99
538
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
100 secure_fprintf(ssi, "Checksum=[%ld]\n", cd->checksum);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
101
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
103 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
104
538
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
105 static gint cache_sim_write_md5sum(SecureSaveInfo *ssi, CacheData *cd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
106 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
107 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
108
538
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
109 if (!cd || !cd->have_md5sum) return FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
110
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
111 text = md5_digest_to_text(cd->md5sum);
538
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
112 secure_fprintf(ssi, "MD5sum=[%s]\n", text);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
113 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
114
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
115 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
117
538
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
118 static gint cache_sim_write_similarity(SecureSaveInfo *ssi, CacheData *cd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
119 {
539
58b7c38d5a5b cache_sim_write_similarity(): cleanup and simplification.
zas_
parents: 538
diff changeset
120 guint x, y;
58b7c38d5a5b cache_sim_write_similarity(): cleanup and simplification.
zas_
parents: 538
diff changeset
121 guint8 buf[3 * 32];
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122
539
58b7c38d5a5b cache_sim_write_similarity(): cleanup and simplification.
zas_
parents: 538
diff changeset
123 if (!cd || !cd->similarity || !cd->sim || !cd->sim->filled) return FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
124
539
58b7c38d5a5b cache_sim_write_similarity(): cleanup and simplification.
zas_
parents: 538
diff changeset
125 secure_fprintf(ssi, "SimilarityGrid[32 x 32]=");
58b7c38d5a5b cache_sim_write_similarity(): cleanup and simplification.
zas_
parents: 538
diff changeset
126 for (y = 0; y < 32; y++)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
127 {
539
58b7c38d5a5b cache_sim_write_similarity(): cleanup and simplification.
zas_
parents: 538
diff changeset
128 guint s = y * 32;
58b7c38d5a5b cache_sim_write_similarity(): cleanup and simplification.
zas_
parents: 538
diff changeset
129 guint8 *avg_r = &cd->sim->avg_r[s];
58b7c38d5a5b cache_sim_write_similarity(): cleanup and simplification.
zas_
parents: 538
diff changeset
130 guint8 *avg_g = &cd->sim->avg_g[s];
58b7c38d5a5b cache_sim_write_similarity(): cleanup and simplification.
zas_
parents: 538
diff changeset
131 guint8 *avg_b = &cd->sim->avg_b[s];
58b7c38d5a5b cache_sim_write_similarity(): cleanup and simplification.
zas_
parents: 538
diff changeset
132 guint n = 0;
58b7c38d5a5b cache_sim_write_similarity(): cleanup and simplification.
zas_
parents: 538
diff changeset
133
58b7c38d5a5b cache_sim_write_similarity(): cleanup and simplification.
zas_
parents: 538
diff changeset
134 for (x = 0; x < 32; x++)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
135 {
539
58b7c38d5a5b cache_sim_write_similarity(): cleanup and simplification.
zas_
parents: 538
diff changeset
136 buf[n++] = avg_r[x];
58b7c38d5a5b cache_sim_write_similarity(): cleanup and simplification.
zas_
parents: 538
diff changeset
137 buf[n++] = avg_g[x];
58b7c38d5a5b cache_sim_write_similarity(): cleanup and simplification.
zas_
parents: 538
diff changeset
138 buf[n++] = avg_b[x];
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
140
539
58b7c38d5a5b cache_sim_write_similarity(): cleanup and simplification.
zas_
parents: 538
diff changeset
141 secure_fwrite(buf, sizeof(buf), 1, ssi);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
143
539
58b7c38d5a5b cache_sim_write_similarity(): cleanup and simplification.
zas_
parents: 538
diff changeset
144 secure_fputc(ssi, '\n');
58b7c38d5a5b cache_sim_write_similarity(): cleanup and simplification.
zas_
parents: 538
diff changeset
145
58b7c38d5a5b cache_sim_write_similarity(): cleanup and simplification.
zas_
parents: 538
diff changeset
146 return TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
147 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
148
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
149 gint cache_sim_data_save(CacheData *cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
150 {
538
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
151 SecureSaveInfo *ssi;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152 gchar *pathl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
153
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
154 if (!cd || !cd->path) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
155
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
156 pathl = path_from_utf8(cd->path);
538
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
157 ssi = secure_open(pathl);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
158 g_free(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
159
538
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
160 if (!ssi)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
161 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
162 printf("Unable to save sim cache data: %s\n", cd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
163 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
165
538
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
166 secure_fprintf(ssi, "SIMcache\n#%s %s\n", PACKAGE, VERSION);
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
167 cache_sim_write_dimensions(ssi, cd);
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
168 cache_sim_write_date(ssi, cd);
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
169 cache_sim_write_checksum(ssi, cd);
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
170 cache_sim_write_md5sum(ssi, cd);
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
171 cache_sim_write_similarity(ssi, cd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
172
538
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
173 if (secure_close(ssi))
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
174 {
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
175 printf_term(_("error saving sim cache data: %s\nerror: %s\n"), cd->path,
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
176 secsave_strerror(secsave_errno));
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
177 return FALSE;
d0279926efea Use secure_save stuff to write .sim files.
zas_
parents: 535
diff changeset
178 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
179
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
180 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
181 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
184 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185 * sim cache read
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
187 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188
65
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
189 static gint cache_sim_read_skipline(FILE *f, int s)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
190 {
65
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
191 if (!f) return FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
192
65
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
193 if (fseek(f, 0 - s, SEEK_CUR) == 0)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
195 char b;
65
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
196 while (fread(&b, sizeof(b), 1, f) == 1)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
197 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
198 if (b == '\n') return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
202
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
203 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
204 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
205
65
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
206 static gint cache_sim_read_comment(FILE *f, char *buf, int s, CacheData *cd)
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
207 {
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
208 if (!f || !buf || !cd) return FALSE;
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
209
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
210 if (s < 1 || buf[0] != '#') return FALSE;
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
211
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
212 return cache_sim_read_skipline(f, s - 1);
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
213 }
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
214
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
215 static gint cache_sim_read_dimensions(FILE *f, char *buf, int s, CacheData *cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
216 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
217 if (!f || !buf || !cd) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
218
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219 if (s < 10 || strncmp("Dimensions", buf, 10) != 0) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
220
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
221 if (fseek(f, - s, SEEK_CUR) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
222 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223 char b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
224 char buf[1024];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
225 gint p = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
226 gint w, h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
227
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228 b = 'X';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
229 while (b != '[')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
230 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
231 if (fread(&b, sizeof(b), 1, f) != 1) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
232 }
540
d4fe3a947929 Use sizeof() instead of hardcoded buffer sizes.
zas_
parents: 539
diff changeset
233 while (b != ']' && p < sizeof(buf) - 1)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
235 if (fread(&b, sizeof(b), 1, f) != 1) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236 buf[p] = b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
237 p++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
238 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240 while (b != '\n')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
241 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
242 if (fread(&b, sizeof(b), 1, f) != 1) break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
243 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245 buf[p] = '\0';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
246 if (sscanf(buf, "%d x %d", &w, &h) != 2) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
247
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248 cd->width = w;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
249 cd->height = h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
250 cd->dimensions = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
251
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
252 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
254
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
255 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257
37
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
258 static gint cache_sim_read_date(FILE *f, char *buf, int s, CacheData *cd)
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
259 {
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
260 if (!f || !buf || !cd) return FALSE;
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
261
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
262 if (s < 4 || strncmp("Date", buf, 4) != 0) return FALSE;
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
263
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
264 if (fseek(f, - s, SEEK_CUR) == 0)
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
265 {
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
266 char b;
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
267 char buf[1024];
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
268 gint p = 0;
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
269
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
270 b = 'X';
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
271 while (b != '[')
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
272 {
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
273 if (fread(&b, sizeof(b), 1, f) != 1) return FALSE;
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
274 }
540
d4fe3a947929 Use sizeof() instead of hardcoded buffer sizes.
zas_
parents: 539
diff changeset
275 while (b != ']' && p < sizeof(buf) - 1)
37
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
276 {
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
277 if (fread(&b, sizeof(b), 1, f) != 1) return FALSE;
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
278 buf[p] = b;
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
279 p++;
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
280 }
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
281
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
282 while (b != '\n')
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
283 {
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
284 if (fread(&b, sizeof(b), 1, f) != 1) break;
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
285 }
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
286
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
287 buf[p] = '\0';
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
288 cd->date = strtol(buf, NULL, 10);
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
289
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
290 cd->have_date = TRUE;
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
291
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
292 return TRUE;
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
293 }
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
294
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
295 return FALSE;
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
296 }
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
297
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
298 static gint cache_sim_read_checksum(FILE *f, char *buf, int s, CacheData *cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
299 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
300 if (!f || !buf || !cd) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
302 if (s < 8 || strncmp("Checksum", buf, 8) != 0) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
303
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
304 if (fseek(f, - s, SEEK_CUR) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
305 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
306 char b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
307 char buf[1024];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
308 gint p = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
309
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
310 b = 'X';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
311 while (b != '[')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
312 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
313 if (fread(&b, sizeof(b), 1, f) != 1) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
314 }
540
d4fe3a947929 Use sizeof() instead of hardcoded buffer sizes.
zas_
parents: 539
diff changeset
315 while (b != ']' && p < sizeof(buf) - 1)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
316 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
317 if (fread(&b, sizeof(b), 1, f) != 1) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
318 buf[p] = b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
319 p++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
320 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
321
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
322 while (b != '\n')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
323 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
324 if (fread(&b, sizeof(b), 1, f) != 1) break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
326
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
327 buf[p] = '\0';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
328 cd->checksum = strtol(buf, NULL, 10);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
329
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
330 cd->have_checksum = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
331
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
332 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
333 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
334
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
336 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
337
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
338 static gint cache_sim_read_md5sum(FILE *f, char *buf, int s, CacheData *cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
339 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
340 if (!f || !buf || !cd) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
341
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
342 if (s < 8 || strncmp("MD5sum", buf, 6) != 0) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
343
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
344 if (fseek(f, - s, SEEK_CUR) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
345 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
346 char b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
347 char buf[64];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
348 gint p = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
349
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
350 b = 'X';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
351 while (b != '[')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
352 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
353 if (fread(&b, sizeof(b), 1, f) != 1) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
354 }
540
d4fe3a947929 Use sizeof() instead of hardcoded buffer sizes.
zas_
parents: 539
diff changeset
355 while (b != ']' && p < sizeof(buf) - 1)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
356 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
357 if (fread(&b, sizeof(b), 1, f) != 1) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
358 buf[p] = b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
359 p++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
360 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
361 while (b != '\n')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
362 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
363 if (fread(&b, sizeof(b), 1, f) != 1) break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
364 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
365
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
366 buf[p] = '\0';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
367 cd->have_md5sum = md5_digest_from_text(buf, cd->md5sum);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
368
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
370 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
371
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
373 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375 static gint cache_sim_read_similarity(FILE *f, char *buf, int s, CacheData *cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
377 if (!f || !buf || !cd) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
378
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
379 if (s < 11 || strncmp("Similarity", buf, 10) != 0) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
380
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381 if (strncmp("Grid[32 x 32]", buf + 10, 13) != 0) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
382
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
383 if (fseek(f, - s, SEEK_CUR) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
384 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
385 char b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
386 guint8 pixel_buf[3];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
387 ImageSimilarityData *sd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
388 gint x, y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
389
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
390 b = 'X';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391 while (b != '=')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
392 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
393 if (fread(&b, sizeof(b), 1, f) != 1) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
396 if (cd->sim)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
397 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
398 /* use current sim that may already contain data we will not touch here */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
399 sd = cd->sim;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
400 cd->sim = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
401 cd->similarity = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
402 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
403 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405 sd = image_sim_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408 for (y = 0; y < 32; y++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
410 gint s = y * 32;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
411 for (x = 0; x < 32; x++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
412 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413 if (fread(&pixel_buf, sizeof(pixel_buf), 1, f) != 1)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415 image_sim_free(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
416 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
417 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418 sd->avg_r[s + x] = pixel_buf[0];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
419 sd->avg_g[s + x] = pixel_buf[1];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
420 sd->avg_b[s + x] = pixel_buf[2];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
421 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
422 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
423
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
424 if (fread(&b, sizeof(b), 1, f) == 1)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
425 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
426 if (b != '\n') fseek(f, -1, SEEK_CUR);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
427 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
428
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
429 cd->sim = sd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
430 cd->sim->filled = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431 cd->similarity = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
432
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
433 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
434 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
435
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
436 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
437 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
438
65
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
439 #define CACHE_LOAD_LINE_NOISE 8
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
440
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
441 CacheData *cache_sim_data_load(const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
442 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
443 FILE *f;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
444 CacheData *cd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
445 char buf[32];
65
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
446 gint success = CACHE_LOAD_LINE_NOISE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
447 gchar *pathl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
448
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
449 if (!path) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
450
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
451 pathl = path_from_utf8(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
452 f = fopen(pathl, "r");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
453 g_free(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
454
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
455 if (!f) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
456
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
457 cd = cache_sim_data_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
458 cd->path = g_strdup(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
459
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
460 if (fread(&buf, sizeof(char), 9, f) != 9 ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
461 strncmp(buf, "SIMcache", 8) != 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
462 {
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
463 DEBUG_1("%s is not a cache file", cd->path);
65
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
464 success = 0;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
465 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
466
65
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
467 while (success > 0)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
468 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
469 int s;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
470 s = fread(&buf, sizeof(char), sizeof(buf), f);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
471
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
472 if (s < 1)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
473 {
65
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
474 success = 0;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
475 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
476 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
477 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
478 if (!cache_sim_read_comment(f, buf, s, cd) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
479 !cache_sim_read_dimensions(f, buf, s, cd) &&
37
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
480 !cache_sim_read_date(f, buf, s, cd) &&
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
481 !cache_sim_read_checksum(f, buf, s, cd) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
482 !cache_sim_read_md5sum(f, buf, s, cd) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
483 !cache_sim_read_similarity(f, buf, s, cd))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
484 {
65
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
485 if (!cache_sim_read_skipline(f, s))
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
486 {
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
487 success = 0;
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
488 }
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
489 else
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
490 {
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
491 success--;
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
492 }
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
493 }
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
494 else
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
495 {
322bb41c9b9e Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
gqview
parents: 39
diff changeset
496 success = CACHE_LOAD_LINE_NOISE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
497 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
498 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
499 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
500
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
501 fclose(f);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
502
39
64068b1bab89 Thu Apr 14 10:44:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 37
diff changeset
503 if (!cd->dimensions &&
64068b1bab89 Thu Apr 14 10:44:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 37
diff changeset
504 !cd->have_date &&
64068b1bab89 Thu Apr 14 10:44:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 37
diff changeset
505 !cd->have_checksum &&
64068b1bab89 Thu Apr 14 10:44:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 37
diff changeset
506 !cd->have_md5sum &&
64068b1bab89 Thu Apr 14 10:44:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 37
diff changeset
507 !cd->similarity)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
508 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
509 cache_sim_data_free(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
510 cd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
511 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
512
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
513 return cd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
514 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
515
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
516 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
517 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
518 * sim cache setting
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
519 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
520 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
521
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
522 void cache_sim_data_set_dimensions(CacheData *cd, gint w, gint h)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
523 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
524 if (!cd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
525
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526 cd->width = w;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
527 cd->height = h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
528 cd->dimensions = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
529 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
530
37
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
531 void cache_sim_data_set_date(CacheData *cd, time_t date)
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
532 {
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
533 if (!cd) return;
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
534
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
535 cd->date = date;
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
536 cd->have_date = TRUE;
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
537 }
67ba4381497e Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
538
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
539 void cache_sim_data_set_checksum(CacheData *cd, long checksum)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
540 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
541 if (!cd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
542
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
543 cd->checksum = checksum;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
544 cd->have_checksum = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
545 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
546
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
547 void cache_sim_data_set_md5sum(CacheData *cd, guchar digest[16])
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
548 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
549 gint i;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
550
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
551 if (!cd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
552
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
553 for (i = 0; i < 16; i++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
555 cd->md5sum[i] = digest[i];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
556 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
557 cd->have_md5sum = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
558 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
559
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
560 void cache_sim_data_set_similarity(CacheData *cd, ImageSimilarityData *sd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
561 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
562 if (!cd || !sd || !sd->filled) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
563
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
564 if (!cd->sim) cd->sim = image_sim_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
565
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
566 memcpy(cd->sim->avg_r, sd->avg_r, 1024);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
567 memcpy(cd->sim->avg_g, sd->avg_g, 1024);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
568 memcpy(cd->sim->avg_b, sd->avg_b, 1024);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
569 cd->sim->filled = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
570
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
571 cd->similarity = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
572 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
573
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
574 gint cache_sim_data_filled(ImageSimilarityData *sd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
575 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
576 if (!sd) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
577 return sd->filled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
578 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
579
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
580 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
581 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
582 * cache path location utils
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
583 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
584 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
585
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
586 /* warning: this func modifies path string contents!, on fail it is set to fail point */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
587 gint cache_ensure_dir_exists(gchar *path, mode_t mode)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
588 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
589 if (!path) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
590
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
591 if (!isdir(path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
592 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
593 gchar *p = path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
594 while (p[0] != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
595 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
596 p++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
597 if (p[0] == '/' || p[0] == '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
598 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
599 gint end = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
600 if (p[0] != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
601 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
602 p[0] = '\0';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
603 end = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
604 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
605 if (!isdir(path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
606 {
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
607 DEBUG_1("creating sub dir:%s", path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
608 if (!mkdir_utf8(path, mode))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
609 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
610 printf("create dir failed: %s\n", path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
611 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
612 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
613 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
614 if (!end) p[0] = '/';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
615 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
616 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
617 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
618 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
619 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
620
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
621 static void cache_path_parts(CacheType type,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
622 const gchar **cache_rc, const gchar **cache_local, const gchar **cache_ext)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
623 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
624 switch (type)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
625 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
626 case CACHE_TYPE_THUMB:
283
e213fb025621 GQVIEW_* -> GQ_*
zas_
parents: 281
diff changeset
627 *cache_rc = GQ_CACHE_RC_THUMB;
e213fb025621 GQVIEW_* -> GQ_*
zas_
parents: 281
diff changeset
628 *cache_local = GQ_CACHE_LOCAL_THUMB;
e213fb025621 GQVIEW_* -> GQ_*
zas_
parents: 281
diff changeset
629 *cache_ext = GQ_CACHE_EXT_THUMB;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
630 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
631 case CACHE_TYPE_SIM:
283
e213fb025621 GQVIEW_* -> GQ_*
zas_
parents: 281
diff changeset
632 *cache_rc = GQ_CACHE_RC_THUMB;
e213fb025621 GQVIEW_* -> GQ_*
zas_
parents: 281
diff changeset
633 *cache_local = GQ_CACHE_LOCAL_THUMB;
e213fb025621 GQVIEW_* -> GQ_*
zas_
parents: 281
diff changeset
634 *cache_ext = GQ_CACHE_EXT_SIM;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
635 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
636 case CACHE_TYPE_METADATA:
283
e213fb025621 GQVIEW_* -> GQ_*
zas_
parents: 281
diff changeset
637 *cache_rc = GQ_CACHE_RC_METADATA;
e213fb025621 GQVIEW_* -> GQ_*
zas_
parents: 281
diff changeset
638 *cache_local = GQ_CACHE_LOCAL_METADATA;
e213fb025621 GQVIEW_* -> GQ_*
zas_
parents: 281
diff changeset
639 *cache_ext = GQ_CACHE_EXT_METADATA;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
640 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
641 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
642 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
643
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
644 gchar *cache_get_location(CacheType type, const gchar *source, gint include_name, mode_t *mode)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
645 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
646 gchar *path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
647 gchar *base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
648 gchar *name = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
649 const gchar *cache_rc;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
650 const gchar *cache_local;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
651 const gchar *cache_ext;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
652
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
653 if (!source) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
654
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
655 cache_path_parts(type, &cache_rc, &cache_local, &cache_ext);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
656
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
657 base = remove_level_from_path(source);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
658 if (include_name)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
659 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
660 name = g_strconcat("/", filename_from_path(source), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
661 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
662 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
663 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
664 cache_ext = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
665 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
666
333
767b53cd9ab7 Rename thumbnails related options.
zas_
parents: 318
diff changeset
667 if (((type != CACHE_TYPE_METADATA && options->thumbnails.cache_into_dirs) ||
318
b16b9b8979e5 Add a new struct ConfOptions to handle options.
zas_
parents: 283
diff changeset
668 (type == CACHE_TYPE_METADATA && options->enable_metadata_dirs)) &&
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
669 access_file(base, W_OK))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
670 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
671 path = g_strconcat(base, "/", cache_local, name, cache_ext, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
672 if (mode) *mode = 0775;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
673 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
674
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
675 if (!path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
676 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
677 path = g_strconcat(homedir(), "/", cache_rc, base, name, cache_ext, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
678 if (mode) *mode = 0755;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
679 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
680
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
681 g_free(base);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
682 if (name) g_free(name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
683
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
684 return path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
685 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
686
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
687 gchar *cache_find_location(CacheType type, const gchar *source)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
688 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
689 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
690 const gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
691 gchar *base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
692 const gchar *cache_rc;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
693 const gchar *cache_local;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
694 const gchar *cache_ext;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
695 gint prefer_local;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
696
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
697 if (!source) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
698
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
699 cache_path_parts(type, &cache_rc, &cache_local, &cache_ext);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
700
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
701 name = filename_from_path(source);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
702 base = remove_level_from_path(source);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
703
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
704 if (type == CACHE_TYPE_METADATA)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
705 {
318
b16b9b8979e5 Add a new struct ConfOptions to handle options.
zas_
parents: 283
diff changeset
706 prefer_local = options->enable_metadata_dirs;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
707 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
708 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
709 {
333
767b53cd9ab7 Rename thumbnails related options.
zas_
parents: 318
diff changeset
710 prefer_local = options->thumbnails.cache_into_dirs;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
711 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
712
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
713 if (prefer_local)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
714 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
715 path = g_strconcat(base, "/", cache_local, "/", name, cache_ext, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
716 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
717 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
718 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
719 path = g_strconcat(homedir(), "/", cache_rc, source, cache_ext, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
720 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
721
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
722 if (!isfile(path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
723 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
724 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
725
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
726 /* try the opposite method if not found */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
727 if (!prefer_local)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
728 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
729 path = g_strconcat(base, "/", cache_local, "/", name, cache_ext, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
730 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
731 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
732 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
733 path = g_strconcat(homedir(), "/", cache_rc, source, cache_ext, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
734 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
735
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
736 if (!isfile(path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
737 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
738 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
739 path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
740 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
741 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
742
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
743 g_free(base);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
744
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
745 return path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
746 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
747
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
748 gint cache_time_valid(const gchar *cache, const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
749 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
750 struct stat cache_st;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
751 struct stat path_st;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
752 gchar *cachel;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
753 gchar *pathl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
754 gint ret = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
755
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
756 if (!cache || !path) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
757
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
758 cachel = path_from_utf8(cache);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
759 pathl = path_from_utf8(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
760
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
761 if (stat(cachel, &cache_st) == 0 &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
762 stat(pathl, &path_st) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
763 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
764 if (cache_st.st_mtime == path_st.st_mtime)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
765 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
766 ret = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
767 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
768 else if (cache_st.st_mtime > path_st.st_mtime)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
769 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
770 struct utimbuf ut;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
771
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
772 ut.actime = ut.modtime = cache_st.st_mtime;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
773 if (utime(cachel, &ut) < 0 &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
774 errno == EPERM)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
775 {
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
776 DEBUG_1("cache permission workaround: %s", cachel);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
777 ret = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
778 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
779 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
780 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
781
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
782 g_free(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
783 g_free(cachel);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
784
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
785 return ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
786 }