Mercurial > geeqie
annotate src/filelist.c @ 169:501010403a04
fixed loading thumbnails for sidecar files
author | nadvornik |
---|---|
date | Sun, 23 Dec 2007 20:28:50 +0000 |
parents | 05bf5d364dba |
children | 9a56e3d13e67 |
rev | line source |
---|---|
1 | 1 /* |
9 | 2 * GQview |
79
528e3432e0c0
Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents:
53
diff
changeset
|
3 * (C) 2006 John Ellis |
1 | 4 * |
5 * Author: John Ellis | |
6 * | |
9 | 7 * This software is released under the GNU General Public License (GNU GPL). |
8 * Please read the included file COPYING for more information. | |
9 * This software comes with no warranty of any kind, use at your own risk! | |
1 | 10 */ |
11 | |
12 | |
9 | 13 #include "gqview.h" |
14 #include "filelist.h" | |
1 | 15 |
9 | 16 #include "cache.h" |
17 #include "rcfile.h" | |
79
528e3432e0c0
Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents:
53
diff
changeset
|
18 #include "thumb_standard.h" |
9 | 19 #include "ui_fileops.h" |
1 | 20 |
21 | |
22 /* | |
23 *----------------------------------------------------------------------------- | |
24 * file filtering | |
25 *----------------------------------------------------------------------------- | |
26 */ | |
27 | |
9 | 28 static GList *filter_list = NULL; |
29 static GList *extension_list = NULL; | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
30 static GList *sidecar_ext_list = NULL; |
9 | 31 |
32 gint ishidden(const gchar *name) | |
1 | 33 { |
34 if (name[0] != '.') return FALSE; | |
35 if (name[1] == '\0' || (name[1] == '.' && name[2] == '\0')) return FALSE; | |
36 return TRUE; | |
37 } | |
38 | |
9 | 39 static FilterEntry *filter_entry_new(const gchar *key, const gchar *description, |
40 const gchar *extensions, gint enabled) | |
41 { | |
42 FilterEntry *fe; | |
43 | |
44 fe = g_new0(FilterEntry, 1); | |
45 fe->key = g_strdup(key); | |
46 fe->description = g_strdup(description); | |
47 fe->extensions = g_strdup(extensions); | |
48 fe->enabled = enabled; | |
49 | |
50 return fe; | |
51 } | |
52 | |
53 static void filter_entry_free(FilterEntry *fe) | |
54 { | |
55 if (!fe) return; | |
56 | |
57 g_free(fe->key); | |
58 g_free(fe->description); | |
59 g_free(fe->extensions); | |
60 g_free(fe); | |
61 } | |
62 | |
63 GList *filter_get_list(void) | |
64 { | |
65 return filter_list; | |
66 } | |
67 | |
68 void filter_remove_entry(FilterEntry *fe) | |
69 { | |
70 if (!g_list_find(filter_list, fe)) return; | |
71 | |
72 filter_list = g_list_remove(filter_list, fe); | |
73 filter_entry_free(fe); | |
74 } | |
75 | |
76 static gint filter_key_exists(const gchar *key) | |
77 { | |
78 GList *work; | |
79 | |
80 if (!key) return FALSE; | |
81 | |
82 work = filter_list; | |
83 while (work) | |
84 { | |
85 FilterEntry *fe = work->data; | |
86 work = work->next; | |
87 | |
88 if (strcmp(fe->key, key) == 0) return TRUE; | |
89 } | |
90 | |
91 return FALSE; | |
92 } | |
93 | |
94 void filter_add(const gchar *key, const gchar *description, const gchar *extensions, gint enabled) | |
95 { | |
96 filter_list = g_list_append(filter_list, filter_entry_new(key, description, extensions, enabled)); | |
97 } | |
98 | |
99 void filter_add_unique(const gchar *description, const gchar *extensions, gint enabled) | |
100 { | |
101 gchar *key; | |
102 gint n; | |
103 | |
104 key = g_strdup("user0"); | |
105 n = 1; | |
106 while (filter_key_exists(key)) | |
107 { | |
108 g_free(key); | |
109 if (n > 999) return; | |
110 key = g_strdup_printf("user%d", n); | |
111 n++; | |
112 } | |
113 | |
114 filter_add(key, description, extensions, enabled); | |
115 g_free(key); | |
116 } | |
117 | |
118 static void filter_add_if_missing(const gchar *key, const gchar *description, const gchar *extensions, gint enabled) | |
119 { | |
120 GList *work; | |
121 | |
122 if (!key) return; | |
123 | |
124 work = filter_list; | |
125 while (work) | |
126 { | |
127 FilterEntry *fe = work->data; | |
128 work = work->next; | |
129 if (fe->key && strcmp(fe->key, key) == 0) return; | |
130 } | |
131 | |
132 filter_add(key, description, extensions, enabled); | |
133 } | |
134 | |
135 void filter_reset(void) | |
1 | 136 { |
137 GList *work; | |
9 | 138 |
139 work = filter_list; | |
140 while (work) | |
141 { | |
142 FilterEntry *fe = work->data; | |
143 work = work->next; | |
144 filter_entry_free(fe); | |
145 } | |
146 | |
147 g_list_free(filter_list); | |
148 filter_list = NULL; | |
149 } | |
150 | |
151 void filter_add_defaults(void) | |
152 { | |
153 GSList *list, *work; | |
154 | |
155 list = gdk_pixbuf_get_formats(); | |
156 work = list; | |
157 while (work) | |
158 { | |
159 GdkPixbufFormat *format; | |
160 gchar *name; | |
161 gchar *desc; | |
162 gchar **extensions; | |
163 GString *filter = NULL; | |
164 gint i; | |
165 | |
166 format = work->data; | |
167 work = work->next; | |
168 | |
169 name = gdk_pixbuf_format_get_name(format); | |
170 desc = gdk_pixbuf_format_get_description(format); | |
171 extensions = gdk_pixbuf_format_get_extensions(format); | |
172 | |
173 i = 0; | |
174 while (extensions[i]) | |
175 { | |
176 if (!filter) | |
177 { | |
178 filter = g_string_new("."); | |
179 filter = g_string_append(filter, extensions[i]); | |
180 } | |
181 else | |
182 { | |
183 filter = g_string_append(filter, ";."); | |
184 filter = g_string_append(filter, extensions[i]); | |
185 } | |
186 i++; | |
187 } | |
188 | |
189 if (debug) printf("loader reported [%s] [%s] [%s]\n", name, desc, filter->str); | |
190 | |
191 filter_add_if_missing(name, desc, filter->str, TRUE); | |
192 | |
193 g_free(name); | |
194 g_free(desc); | |
195 g_strfreev(extensions); | |
196 g_string_free(filter, TRUE); | |
197 } | |
198 g_slist_free(list); | |
1 | 199 |
9 | 200 /* add defaults even if gdk-pixbuf does not have them, but disabled */ |
201 filter_add_if_missing("jpeg", "JPEG group", ".jpg;.jpeg;.jpe", FALSE); | |
202 filter_add_if_missing("png", "Portable Network Graphic", ".png", FALSE); | |
203 filter_add_if_missing("tiff", "Tiff", ".tif;.tiff", FALSE); | |
204 filter_add_if_missing("pnm", "Packed Pixel formats", ".pbm;.pgm;.pnm;.ppm", FALSE); | |
205 filter_add_if_missing("gif", "Graphics Interchange Format", ".gif", FALSE); | |
206 filter_add_if_missing("xbm", "X bitmap", ".xbm", FALSE); | |
207 filter_add_if_missing("xpm", "X pixmap", ".xpm", FALSE); | |
208 filter_add_if_missing("bmp", "Bitmap", ".bmp", FALSE); | |
209 filter_add_if_missing("ico", "Icon file", ".ico;.cur", FALSE); | |
210 filter_add_if_missing("ras", "Raster", ".ras", FALSE); | |
211 filter_add_if_missing("svg", "Scalable Vector Graphics", ".svg", FALSE); | |
43
ee03f36e9e4b
Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
212 |
ee03f36e9e4b
Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
213 /* These are the raw camera formats with embedded jpeg/exif. |
ee03f36e9e4b
Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
214 * (see format_raw.c) |
ee03f36e9e4b
Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
215 */ |
53
00843150f7c8
Tue Jun 7 03:47:03 2005 John Ellis <johne@verizon.net>
gqview
parents:
52
diff
changeset
|
216 filter_add_if_missing("crw", "Canon raw format", ".crw;.cr2", TRUE); |
45
7cfa60beda76
Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents:
43
diff
changeset
|
217 filter_add_if_missing("raf", "Fujifilm raw format", ".raf", TRUE); |
53
00843150f7c8
Tue Jun 7 03:47:03 2005 John Ellis <johne@verizon.net>
gqview
parents:
52
diff
changeset
|
218 filter_add_if_missing("nef", "Nikon raw format", ".nef", TRUE); |
101
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
219 filter_add_if_missing("orf", "Olympus raw format", ".orf", TRUE); |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
220 filter_add_if_missing("pef", "Pentax raw format", ".pef", TRUE); |
9 | 221 } |
222 | |
147
b2266996fa83
added possibility to specify prefered file type for external commands
nadvornik
parents:
146
diff
changeset
|
223 GList *filter_to_list(const gchar *extensions) |
9 | 224 { |
225 GList *list = NULL; | |
226 const gchar *p; | |
227 | |
228 if (!extensions) return NULL; | |
229 | |
230 p = extensions; | |
231 while (*p != '\0') | |
232 { | |
233 const gchar *b; | |
234 gint l = 0; | |
235 | |
236 b = p; | |
237 while (*p != '\0' && *p != ';') | |
238 { | |
239 p++; | |
240 l++; | |
241 } | |
242 list = g_list_append(list, g_strndup(b, l)); | |
243 if (*p == ';') p++; | |
244 } | |
245 | |
246 return list; | |
247 } | |
248 | |
249 void filter_rebuild(void) | |
250 { | |
251 GList *work; | |
252 | |
253 path_list_free(extension_list); | |
254 extension_list = NULL; | |
255 | |
256 work = filter_list; | |
257 while (work) | |
258 { | |
259 FilterEntry *fe; | |
260 | |
261 fe = work->data; | |
262 work = work->next; | |
263 | |
264 if (fe->enabled) | |
265 { | |
266 GList *ext; | |
267 | |
268 ext = filter_to_list(fe->extensions); | |
269 if (ext) extension_list = g_list_concat(extension_list, ext); | |
270 } | |
271 } | |
272 } | |
273 | |
274 gint filter_name_exists(const gchar *name) | |
275 { | |
276 GList *work; | |
277 if (!extension_list || file_filter_disable) return TRUE; | |
278 | |
279 work = extension_list; | |
1 | 280 while (work) |
281 { | |
282 gchar *filter = work->data; | |
283 gint lf = strlen(filter); | |
284 gint ln = strlen(name); | |
285 if (ln >= lf) | |
286 { | |
287 if (strncasecmp(name + ln - lf, filter, lf) == 0) return TRUE; | |
288 } | |
289 work = work->next; | |
290 } | |
291 | |
292 return FALSE; | |
293 } | |
294 | |
9 | 295 void filter_write_list(FILE *f) |
1 | 296 { |
9 | 297 GList *work; |
298 | |
299 work = filter_list; | |
300 while (work) | |
301 { | |
302 FilterEntry *fe = work->data; | |
303 work = work->next; | |
304 | |
305 fprintf(f, "filter_ext: \"%s%s\" \"%s\" \"%s\"\n", (fe->enabled) ? "" : "#", | |
306 fe->key, fe->extensions, | |
307 (fe->description) ? fe->description : ""); | |
308 } | |
1 | 309 } |
310 | |
9 | 311 void filter_parse(const gchar *text) |
1 | 312 { |
9 | 313 const gchar *p; |
314 gchar *key; | |
315 gchar *ext; | |
316 gchar *desc; | |
317 gint enabled = TRUE; | |
318 | |
319 if (!text || text[0] != '"') return; | |
320 | |
321 key = quoted_value(text); | |
322 if (!key) return; | |
323 | |
324 p = text; | |
325 p++; | |
326 while (*p != '"' && *p != '\0') p++; | |
327 if (*p != '"') | |
328 { | |
329 g_free(key); | |
330 return; | |
331 } | |
332 p++; | |
333 while (*p != '"' && *p != '\0') p++; | |
334 if (*p != '"') | |
1 | 335 { |
9 | 336 g_free(key); |
337 return; | |
338 } | |
339 | |
340 ext = quoted_value(p); | |
341 | |
342 p++; | |
343 while (*p != '"' && *p != '\0') p++; | |
344 if (*p == '"') p++; | |
345 while (*p != '"' && *p != '\0') p++; | |
346 | |
347 if (*p == '"') | |
348 { | |
349 desc = quoted_value(p); | |
350 } | |
351 else | |
352 { | |
353 desc = NULL; | |
354 } | |
355 | |
356 if (key && key[0] == '#') | |
357 { | |
358 gchar *tmp; | |
359 tmp = g_strdup(key + 1); | |
360 g_free(key); | |
361 key = tmp; | |
362 | |
363 enabled = FALSE; | |
1 | 364 } |
365 | |
9 | 366 if (key && strlen(key) > 0 && ext) filter_add(key, desc, ext, enabled); |
367 | |
368 g_free(key); | |
369 g_free(ext); | |
370 g_free(desc); | |
371 } | |
1 | 372 |
9 | 373 GList *path_list_filter(GList *list, gint is_dir_list) |
374 { | |
375 GList *work; | |
376 | |
377 if (!is_dir_list && file_filter_disable && show_dot_files) return list; | |
378 | |
379 work = list; | |
380 while (work) | |
1 | 381 { |
9 | 382 gchar *name = work->data; |
383 const gchar *base; | |
384 | |
385 base = filename_from_path(name); | |
386 | |
387 if ((!show_dot_files && ishidden(base)) || | |
388 (!is_dir_list && !filter_name_exists(base)) || | |
389 (is_dir_list && base[0] == '.' && (strcmp(base, GQVIEW_CACHE_LOCAL_THUMB) == 0 || | |
390 strcmp(base, GQVIEW_CACHE_LOCAL_METADATA) == 0)) ) | |
391 { | |
392 GList *link = work; | |
393 work = work->next; | |
394 list = g_list_remove_link(list, link); | |
395 g_free(name); | |
396 g_list_free(link); | |
397 } | |
398 else | |
1 | 399 { |
9 | 400 work = work->next; |
1 | 401 } |
402 } | |
9 | 403 |
404 return list; | |
405 } | |
406 | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
407 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
408 /* |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
409 *----------------------------------------------------------------------------- |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
410 * sidecar extension list |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
411 *----------------------------------------------------------------------------- |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
412 */ |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
413 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
414 static GList *sidecar_ext_get_list(void) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
415 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
416 return sidecar_ext_list; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
417 } |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
418 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
419 void sidecar_ext_parse(const gchar *text) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
420 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
421 GList *work; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
422 gchar *value; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
423 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
424 work = sidecar_ext_list; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
425 while (work) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
426 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
427 gchar *ext = work->data; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
428 work = work->next; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
429 g_free(ext); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
430 } |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
431 g_list_free(sidecar_ext_list); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
432 sidecar_ext_list = NULL; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
433 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
434 value = quoted_value(text); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
435 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
436 if (value == NULL) return; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
437 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
438 sidecar_ext_list = filter_to_list(value); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
439 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
440 g_free(value); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
441 } |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
442 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
443 void sidecar_ext_write(FILE *f) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
444 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
445 GList *work; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
446 fprintf(f, "\nsidecar_ext: \""); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
447 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
448 work = sidecar_ext_list; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
449 while (work) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
450 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
451 gchar *ext = work->data; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
452 work = work->next; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
453 fprintf(f, "%s%s", ext, work ? ";" : ""); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
454 } |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
455 fprintf(f, "\"\n"); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
456 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
457 } |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
458 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
459 void sidecar_ext_add_defaults() |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
460 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
461 sidecar_ext_parse("\".jpg;.cr2;.nef;.crw\""); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
462 } |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
463 |
9 | 464 /* |
465 *----------------------------------------------------------------------------- | |
466 * path list recursive | |
467 *----------------------------------------------------------------------------- | |
468 */ | |
469 | |
470 static gint path_list_sort_cb(gconstpointer a, gconstpointer b) | |
471 { | |
472 return CASE_SORT((gchar *)a, (gchar *)b); | |
473 } | |
474 | |
475 GList *path_list_sort(GList *list) | |
476 { | |
477 return g_list_sort(list, path_list_sort_cb); | |
478 } | |
479 | |
480 static void path_list_recursive_append(GList **list, GList *dirs) | |
481 { | |
482 GList *work; | |
483 | |
484 work = dirs; | |
485 while (work) | |
486 { | |
487 const gchar *path = work->data; | |
488 GList *f = NULL; | |
489 GList *d = NULL; | |
490 | |
491 if (path_list(path, &f, &d)) | |
492 { | |
493 f = path_list_filter(f, FALSE); | |
494 f = path_list_sort(f); | |
495 *list = g_list_concat(*list, f); | |
496 | |
497 d = path_list_filter(d, TRUE); | |
498 d = path_list_sort(d); | |
499 path_list_recursive_append(list, d); | |
52
a210a19f26da
Sun Jun 5 03:05:39 2005 John Ellis <johne@verizon.net>
gqview
parents:
45
diff
changeset
|
500 path_list_free(d); |
9 | 501 } |
502 | |
503 work = work->next; | |
504 } | |
505 } | |
506 | |
507 GList *path_list_recursive(const gchar *path) | |
508 { | |
509 GList *list = NULL; | |
510 GList *d = NULL; | |
511 | |
512 if (!path_list(path, &list, &d)) return NULL; | |
513 list = path_list_filter(list, FALSE); | |
514 list = path_list_sort(list); | |
515 | |
516 d = path_list_filter(d, TRUE); | |
517 d = path_list_sort(d); | |
518 path_list_recursive_append(&list, d); | |
519 path_list_free(d); | |
520 | |
521 return list; | |
1 | 522 } |
523 | |
524 /* | |
525 *----------------------------------------------------------------------------- | |
9 | 526 * text conversion utils |
1 | 527 *----------------------------------------------------------------------------- |
528 */ | |
529 | |
9 | 530 gchar *text_from_size(gint64 size) |
1 | 531 { |
9 | 532 gchar *a, *b; |
533 gchar *s, *d; | |
534 gint l, n, i; | |
535 | |
536 /* what I would like to use is printf("%'d", size) | |
537 * BUT: not supported on every libc :( | |
538 */ | |
539 if (size > G_MAXUINT) | |
540 { | |
541 /* the %lld conversion is not valid in all libcs, so use a simple work-around */ | |
542 a = g_strdup_printf("%d%09d", (guint)(size / 1000000000), (guint)(size % 1000000000)); | |
543 } | |
544 else | |
545 { | |
546 a = g_strdup_printf("%d", (guint)size); | |
547 } | |
548 l = strlen(a); | |
549 n = (l - 1)/ 3; | |
550 if (n < 1) return a; | |
551 | |
552 b = g_new(gchar, l + n + 1); | |
553 | |
554 s = a; | |
555 d = b; | |
556 i = l - n * 3; | |
557 while (*s != '\0') | |
558 { | |
559 if (i < 1) | |
560 { | |
561 i = 3; | |
562 *d = ','; | |
563 d++; | |
564 } | |
565 | |
566 *d = *s; | |
567 s++; | |
568 d++; | |
569 i--; | |
570 } | |
571 *d = '\0'; | |
572 | |
573 g_free(a); | |
574 return b; | |
575 } | |
576 | |
577 gchar *text_from_size_abrev(gint64 size) | |
578 { | |
579 if (size < (gint64)1024) | |
580 { | |
581 return g_strdup_printf(_("%d bytes"), (gint)size); | |
582 } | |
583 if (size < (gint64)1048576) | |
584 { | |
15
3263965d5f9e
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
585 return g_strdup_printf(_("%.1f K"), (double)size / 1024.0); |
9 | 586 } |
587 if (size < (gint64)1073741824) | |
588 { | |
15
3263965d5f9e
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
589 return g_strdup_printf(_("%.1f MB"), (double)size / 1048576.0); |
9 | 590 } |
591 | |
15
3263965d5f9e
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
592 /* to avoid overflowing the double, do division in two steps */ |
3263965d5f9e
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
593 size /= 1048576; |
3263965d5f9e
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
594 return g_strdup_printf(_("%.1f GB"), (double)size / 1024.0); |
9 | 595 } |
596 | |
597 /* note: returned string is valid until next call to text_from_time() */ | |
598 const gchar *text_from_time(time_t t) | |
599 { | |
600 static gchar *ret = NULL; | |
601 gchar buf[128]; | |
602 gint buflen; | |
603 struct tm *btime; | |
604 GError *error = NULL; | |
605 | |
606 btime = localtime(&t); | |
607 | |
608 /* the %x warning about 2 digit years is not an error */ | |
609 buflen = strftime(buf, sizeof(buf), "%x %H:%M", btime); | |
610 if (buflen < 1) return ""; | |
611 | |
612 g_free(ret); | |
613 ret = g_locale_to_utf8(buf, buflen, NULL, NULL, &error); | |
614 if (error) | |
615 { | |
616 printf("Error converting locale strftime to UTF-8: %s\n", error->message); | |
617 g_error_free(error); | |
618 return ""; | |
619 } | |
620 | |
621 return ret; | |
1 | 622 } |
623 | |
9 | 624 /* |
625 *----------------------------------------------------------------------------- | |
626 * file info struct | |
627 *----------------------------------------------------------------------------- | |
628 */ | |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
629 |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
630 FileData *file_data_merge_sidecar_files(FileData *target, FileData *source); |
167 | 631 static void file_data_check_sidecars(FileData *fd); |
632 FileData *file_data_disconnect_sidecar_file(FileData *target, FileData *sfd); | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
633 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
634 |
138 | 635 static void file_data_set_path(FileData *fd, const gchar *path) |
636 { | |
9 | 637 |
138 | 638 if (strcmp(path, "/") == 0) |
639 { | |
640 fd->path = g_strdup(path); | |
641 fd->name = fd->path; | |
642 fd->extension = fd->name + 1; | |
643 return; | |
644 } | |
645 | |
646 fd->path = g_strdup(path); | |
647 fd->name = filename_from_path(fd->path); | |
648 | |
649 if (strcmp(fd->name, "..") == 0) | |
650 { | |
651 gchar *dir = remove_level_from_path(path); | |
652 g_free(fd->path); | |
653 fd->path = remove_level_from_path(dir); | |
654 g_free(dir); | |
655 fd->name = ".."; | |
656 fd->extension = fd->name + 2; | |
657 return; | |
658 } | |
659 else if (strcmp(fd->name, ".") == 0) | |
660 { | |
661 g_free(fd->path); | |
662 fd->path = remove_level_from_path(path); | |
663 fd->name = "."; | |
664 fd->extension = fd->name + 1; | |
665 return; | |
666 } | |
667 | |
668 fd->extension = extension_from_path(fd->path); | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
669 if (fd->extension == NULL) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
670 fd->extension = fd->name + strlen(fd->name); |
138 | 671 } |
672 | |
167 | 673 static void file_data_check_changed_files(FileData *fd, struct stat *st) |
164 | 674 { |
167 | 675 GList *work; |
164 | 676 if (fd->size != st->st_size || |
677 fd->date != st->st_mtime) | |
678 { | |
679 fd->size = st->st_size; | |
680 fd->date = st->st_mtime; | |
681 if (fd->pixbuf) g_object_unref(fd->pixbuf); | |
682 fd->pixbuf = NULL; | |
683 } | |
167 | 684 |
685 work = fd->sidecar_files; | |
686 while (work) | |
687 { | |
688 FileData *sfd = work->data; | |
689 struct stat st; | |
690 | |
691 if (!stat_utf8(sfd->path, &st)) | |
692 { | |
693 file_data_disconnect_sidecar_file(fd, sfd); | |
694 } | |
695 | |
696 file_data_check_changed_files(sfd, &st); | |
697 work = work->next; | |
698 } | |
164 | 699 } |
700 | |
138 | 701 static GHashTable *file_data_pool = NULL; |
702 | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
703 static FileData *file_data_new(const gchar *path_utf8, struct stat *st, gboolean check_sidecars) |
9 | 704 { |
705 FileData *fd; | |
706 | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
707 printf("file_data_new: '%s' %d\n", path_utf8, check_sidecars); |
138 | 708 |
709 if (!file_data_pool) | |
710 file_data_pool = g_hash_table_new (g_str_hash, g_str_equal); | |
711 | |
712 fd = g_hash_table_lookup(file_data_pool, path_utf8); | |
713 if (fd) | |
714 { | |
167 | 715 file_data_check_changed_files(fd, st); |
138 | 716 printf("file_data_pool hit: '%s'\n", fd->path); |
717 return file_data_ref(fd); | |
718 } | |
719 | |
9 | 720 fd = g_new0(FileData, 1); |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
721 |
138 | 722 file_data_set_path(fd, path_utf8); |
723 | |
724 fd->original_path = g_strdup(path_utf8); | |
9 | 725 fd->size = st->st_size; |
726 fd->date = st->st_mtime; | |
727 fd->pixbuf = NULL; | |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
728 fd->sidecar_files = NULL; |
138 | 729 fd->ref = 1; |
730 fd->magick = 0x12345678; | |
731 | |
732 g_hash_table_insert(file_data_pool, fd->original_path, fd); | |
733 | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
734 if (check_sidecars && sidecar_file_priority(fd->extension)) |
146 | 735 file_data_check_sidecars(fd); |
9 | 736 return fd; |
737 } | |
738 | |
146 | 739 static void file_data_check_sidecars(FileData *fd) |
740 { | |
741 int i = 0; | |
742 int base_len = fd->extension - fd->path; | |
743 GString *fname = g_string_new_len(fd->path, base_len); | |
744 FileData *parent_fd = NULL; | |
745 GList *work = sidecar_ext_get_list(); | |
746 while (work) | |
747 { | |
748 /* check for possible sidecar files; | |
749 the sidecar files created here are referenced only via fd->sidecar_files or fd->parent, | |
750 they have fd->ref set to 0 and file_data unref must chack and free them all together | |
751 (using fd->ref would cause loops and leaks) | |
752 */ | |
753 | |
754 FileData *new_fd; | |
755 | |
756 gchar *ext = work->data; | |
757 work = work->next; | |
758 | |
759 if (strcmp(ext, fd->extension) == 0) | |
760 { | |
761 new_fd = fd; /* processing the original file */ | |
762 } | |
763 else | |
764 { | |
765 struct stat nst; | |
766 g_string_truncate(fname, base_len); | |
767 g_string_append(fname, ext); | |
768 | |
769 if (!stat_utf8(fname->str, &nst)) | |
770 continue; | |
771 | |
772 new_fd = file_data_new(fname->str, &nst, FALSE); | |
773 new_fd->ref--; /* do not use ref here */ | |
774 } | |
775 | |
776 if (!parent_fd) | |
777 parent_fd = new_fd; /* parent is the one with the highest prio, found first */ | |
778 else | |
779 file_data_merge_sidecar_files(parent_fd, new_fd); | |
780 } | |
781 g_string_free(fname, TRUE); | |
782 } | |
783 | |
784 | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
785 static FileData *file_data_new_local(const gchar *path, struct stat *st, gboolean check_sidecars) |
138 | 786 { |
787 gchar *path_utf8 = path_to_utf8(path); | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
788 FileData *ret = file_data_new(path_utf8, st, check_sidecars); |
138 | 789 g_free(path_utf8); |
790 return ret; | |
791 } | |
792 | |
793 FileData *file_data_new_simple(const gchar *path_utf8) | |
9 | 794 { |
795 struct stat st; | |
796 | |
138 | 797 if (!stat_utf8(path_utf8, &st)) |
9 | 798 { |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
799 st.st_size = 0; |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
800 st.st_mtime = 0; |
9 | 801 } |
802 | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
803 return file_data_new(path_utf8, &st, TRUE); |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
804 } |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
805 |
141 | 806 FileData *file_data_add_sidecar_file(FileData *target, FileData *sfd) |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
807 { |
141 | 808 sfd->parent = target; |
146 | 809 if(!g_list_find(target->sidecar_files, sfd)) |
810 target->sidecar_files = g_list_prepend(target->sidecar_files, sfd); | |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
811 return target; |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
812 } |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
813 |
167 | 814 |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
815 FileData *file_data_merge_sidecar_files(FileData *target, FileData *source) |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
816 { |
141 | 817 GList *work; |
818 file_data_add_sidecar_file(target, source); | |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
819 |
141 | 820 work = source->sidecar_files; |
821 while (work) | |
822 { | |
823 FileData *sfd = work->data; | |
146 | 824 file_data_add_sidecar_file(target, sfd); |
141 | 825 work = work->next; |
826 } | |
827 | |
146 | 828 g_list_free(source->sidecar_files); |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
829 source->sidecar_files = NULL; |
167 | 830 |
831 target->sidecar_files = filelist_sort(target->sidecar_files, SORT_NAME, TRUE); | |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
832 return target; |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
833 } |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
834 |
167 | 835 |
836 | |
138 | 837 FileData *file_data_ref(FileData *fd) |
838 { | |
839 if (fd == NULL) return NULL; | |
840 | |
841 // return g_memdup(fd, sizeof(FileData)); | |
842 g_assert(fd->magick == 0x12345678); | |
843 fd->ref++; | |
844 return fd; | |
845 } | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
846 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
847 static void file_data_free(FileData *fd) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
848 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
849 g_assert(fd->magick == 0x12345678); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
850 g_assert(fd->ref == 0); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
851 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
852 g_hash_table_remove(file_data_pool, fd->original_path); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
853 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
854 g_free(fd->path); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
855 g_free(fd->original_path); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
856 if (fd->pixbuf) g_object_unref(fd->pixbuf); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
857 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
858 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
859 g_assert(fd->sidecar_files == NULL); /* sidecar files must be freed before calling this */ |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
860 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
861 file_data_change_info_free(NULL, fd); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
862 g_free(fd); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
863 } |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
864 |
138 | 865 void file_data_unref(FileData *fd) |
866 { | |
867 if (fd == NULL) return; | |
868 g_assert(fd->magick == 0x12345678); | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
869 printf("file_data_unref: '%s'\n", fd->path); |
138 | 870 fd->ref--; |
871 if (fd->ref == 0) | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
872 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
873 FileData *parent = fd->parent ? fd->parent : fd; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
874 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
875 GList *work; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
876 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
877 if (parent->ref > 0) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
878 return; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
879 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
880 work = parent->sidecar_files; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
881 while (work) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
882 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
883 FileData *sfd = work->data; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
884 if (sfd->ref > 0) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
885 return; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
886 work = work->next; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
887 } |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
888 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
889 /* none of parent/children is referenced, we can free everything */ |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
890 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
891 printf("file_data_unref: '%s', parent '%s'\n", fd->path, parent->path); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
892 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
893 work = parent->sidecar_files; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
894 while (work) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
895 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
896 FileData *sfd = work->data; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
897 file_data_free(sfd); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
898 work = work->next; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
899 } |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
900 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
901 g_list_free(parent->sidecar_files); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
902 parent->sidecar_files = NULL; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
903 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
904 file_data_free(parent); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
905 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
906 } |
138 | 907 } |
908 | |
167 | 909 FileData *file_data_disconnect_sidecar_file(FileData *target, FileData *sfd) |
910 { | |
911 sfd->parent = target; | |
912 g_assert(g_list_find(target->sidecar_files, sfd)); | |
913 | |
914 target->sidecar_files = g_list_remove(target->sidecar_files, sfd); | |
915 sfd->parent = NULL; | |
916 | |
917 if (sfd->ref == 0) { | |
918 file_data_free(sfd); | |
919 return NULL; | |
920 } | |
921 | |
922 return sfd; | |
923 } | |
924 | |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
925 /* compare name without extension */ |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
926 gint file_data_compare_name_without_ext(FileData *fd1, FileData *fd2) |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
927 { |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
928 size_t len1 = fd1->extension - fd1->name; |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
929 size_t len2 = fd2->extension - fd2->name; |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
930 |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
931 if (len1 < len2) return -1; |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
932 if (len1 > len2) return 1; |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
933 |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
934 return strncmp(fd1->name, fd2->name, len1); |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
935 } |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
936 |
138 | 937 FileData *file_data_do_change(FileData *fd) |
938 { | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
939 //FIXME sidecars |
138 | 940 g_assert(fd->change); |
941 g_free(fd->path); | |
942 g_hash_table_remove(file_data_pool, fd->original_path); | |
943 g_free(fd->original_path); | |
944 file_data_set_path(fd, fd->change->dest); | |
945 fd->original_path = g_strdup(fd->change->dest); | |
946 g_hash_table_insert(file_data_pool, fd->original_path, fd); | |
947 | |
948 } | |
949 | |
143
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
950 gboolean file_data_add_change_info(FileData *fd, FileDataChangeType type, const gchar *src, const gchar *dest) |
138 | 951 { |
143
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
952 |
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
953 FileDataChangeInfo *fdci; |
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
954 |
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
955 if (fd->change) return FALSE; |
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
956 |
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
957 fdci = g_new0(FileDataChangeInfo, 1); |
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
958 |
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
959 fdci->type = type; |
138 | 960 |
961 if (src) | |
962 fdci->source = g_strdup(src); | |
143
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
963 else |
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
964 fdci->source = g_strdup(fd->path); |
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
965 |
138 | 966 if (dest) |
967 fdci->dest = g_strdup(dest); | |
968 | |
143
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
969 fd->change = fdci; |
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
970 return TRUE; |
138 | 971 } |
972 | |
973 void file_data_change_info_free(FileDataChangeInfo *fdci, FileData *fd) | |
974 { | |
975 if (!fdci && fd) | |
976 fdci = fd->change; | |
977 | |
978 if (!fdci) | |
979 return; | |
980 | |
981 g_free(fdci->source); | |
982 g_free(fdci->dest); | |
983 | |
984 g_free(fdci); | |
985 | |
986 if (fd) | |
987 fd->change = NULL; | |
988 } | |
139 | 989 |
990 | |
991 | |
138 | 992 |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
993 /* |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
994 *----------------------------------------------------------------------------- |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
995 * sidecar file info struct |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
996 *----------------------------------------------------------------------------- |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
997 */ |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
998 |
9 | 999 |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
1000 |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
1001 gint sidecar_file_priority(const gchar *path) |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
1002 { |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
1003 const char *extension = extension_from_path(path); |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
1004 int i = 1; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
1005 GList *work; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
1006 if (extension == NULL) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
1007 return 0; |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
1008 |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
1009 work = sidecar_ext_get_list(); |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
1010 |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
1011 while (work) { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
1012 gchar *ext = work->data; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
1013 work = work->next; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
1014 if (strcmp(extension, ext) == 0) return i; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
1015 i++; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
1016 } |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
1017 return 0; |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
1018 } |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
1019 |
139 | 1020 gchar *sidecar_file_data_list_to_string(FileData *fd) |
1021 { | |
1022 GList *work; | |
1023 GString *result = g_string_new(""); | |
1024 | |
1025 work = fd->sidecar_files; | |
1026 while (work) | |
1027 { | |
141 | 1028 FileData *sfd = work->data; |
139 | 1029 result = g_string_append(result, "+ "); |
1030 result = g_string_append(result, sfd->extension); | |
1031 work = work->next; | |
1032 if (work) result = g_string_append_c(result, ' '); | |
1033 } | |
1034 | |
1035 return g_string_free(result, FALSE); | |
1036 } | |
1037 | |
9 | 1038 /* |
1039 *----------------------------------------------------------------------------- | |
1040 * load file list | |
1041 *----------------------------------------------------------------------------- | |
1042 */ | |
1043 | |
1044 static SortType filelist_sort_method = SORT_NONE; | |
1045 static gint filelist_sort_ascend = TRUE; | |
1046 | |
138 | 1047 |
1048 gint filelist_sort_compare_filedata(FileData *fa, FileData *fb) | |
9 | 1049 { |
1050 if (!filelist_sort_ascend) | |
1051 { | |
138 | 1052 FileData *tmp = fa; |
1053 fa = fb; | |
1054 fb = tmp; | |
9 | 1055 } |
1056 | |
1057 switch (filelist_sort_method) | |
1058 { | |
1059 case SORT_SIZE: | |
1060 if (fa->size < fb->size) return -1; | |
1061 if (fa->size > fb->size) return 1; | |
167 | 1062 return CASE_SORT(fa->name, fb->name); /* fall back to name */ |
9 | 1063 break; |
1064 case SORT_TIME: | |
1065 if (fa->date < fb->date) return -1; | |
1066 if (fa->date > fb->date) return 1; | |
167 | 1067 return CASE_SORT(fa->name, fb->name); /* fall back to name */ |
9 | 1068 break; |
1069 #ifdef HAVE_STRVERSCMP | |
1070 case SORT_NUMBER: | |
1071 return strverscmp(fa->name, fb->name); | |
1072 break; | |
1073 #endif | |
1074 case SORT_NAME: | |
1075 default: | |
1076 return CASE_SORT(fa->name, fb->name); | |
1077 break; | |
1078 } | |
1079 } | |
1080 | |
167 | 1081 gint filelist_sort_compare_filedata_full(FileData *fa, FileData *fb, SortType method, gint ascend) |
1082 { | |
1083 filelist_sort_method = method; | |
1084 filelist_sort_ascend = ascend; | |
1085 return filelist_sort_compare_filedata(fa, fb); | |
1086 } | |
1087 | |
138 | 1088 static gint filelist_sort_file_cb(void *a, void *b) |
1089 { | |
1090 return filelist_sort_compare_filedata(a, b); | |
1091 } | |
1092 | |
1093 GList *filelist_sort_full(GList *list, SortType method, gint ascend, GCompareFunc cb) | |
9 | 1094 { |
1095 filelist_sort_method = method; | |
1096 filelist_sort_ascend = ascend; | |
138 | 1097 return g_list_sort(list, cb); |
1098 } | |
1099 | |
1100 GList *filelist_insert_sort_full(GList *list, void *data, SortType method, gint ascend, GCompareFunc cb) | |
1101 { | |
1102 filelist_sort_method = method; | |
1103 filelist_sort_ascend = ascend; | |
1104 return g_list_insert_sorted(list, data, cb); | |
1105 } | |
1106 | |
1107 GList *filelist_sort(GList *list, SortType method, gint ascend) | |
1108 { | |
1109 return filelist_sort_full(list, method, ascend, (GCompareFunc) filelist_sort_file_cb); | |
9 | 1110 } |
1111 | |
1112 GList *filelist_insert_sort(GList *list, FileData *fd, SortType method, gint ascend) | |
1113 { | |
138 | 1114 return filelist_insert_sort_full(list, fd, method, ascend, (GCompareFunc) filelist_sort_file_cb); |
9 | 1115 } |
1116 | |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
1117 |
148 | 1118 static GList *filelist_filter_out_sidecars(GList *flist) |
1119 { | |
1120 GList *work = flist; | |
1121 GList *flist_filtered = NULL; | |
1122 | |
1123 while (work) | |
1124 { | |
1125 FileData *fd = work->data; | |
1126 work = work->next; | |
1127 if (fd->parent) /* remove fd's that are children */ | |
1128 file_data_unref(fd); | |
1129 else | |
1130 flist_filtered = g_list_prepend(flist_filtered, fd); | |
1131 } | |
1132 g_list_free(flist); | |
1133 return flist_filtered; | |
1134 } | |
1135 | |
138 | 1136 static gint filelist_read_real(const gchar *path, GList **files, GList **dirs, gint follow_symlinks) |
1 | 1137 { |
1138 DIR *dp; | |
1139 struct dirent *dir; | |
1140 struct stat ent_sbuf; | |
9 | 1141 gchar *pathl; |
1142 GList *dlist; | |
1143 GList *flist; | |
1 | 1144 |
9 | 1145 dlist = NULL; |
1146 flist = NULL; | |
1147 | |
1148 pathl = path_from_utf8(path); | |
1149 if (!pathl || (dp = opendir(pathl)) == NULL) | |
1 | 1150 { |
9 | 1151 g_free(pathl); |
1152 if (files) *files = NULL; | |
1153 if (dirs) *dirs = NULL; | |
1154 return FALSE; | |
1 | 1155 } |
1156 | |
9 | 1157 /* root dir fix */ |
1158 if (pathl[0] == '/' && pathl[1] == '\0') | |
1159 { | |
1160 g_free(pathl); | |
1161 pathl = g_strdup(""); | |
1162 } | |
1 | 1163 |
1164 while ((dir = readdir(dp)) != NULL) | |
1165 { | |
9 | 1166 gchar *name = dir->d_name; |
1167 if (show_dot_files || !ishidden(name)) | |
1 | 1168 { |
9 | 1169 gchar *filepath = g_strconcat(pathl, "/", name, NULL); |
138 | 1170 if ((follow_symlinks ? |
1171 stat(filepath, &ent_sbuf) : | |
1172 lstat(filepath, &ent_sbuf)) >= 0) | |
1 | 1173 { |
9 | 1174 if (S_ISDIR(ent_sbuf.st_mode)) |
1 | 1175 { |
9 | 1176 /* we ignore the .thumbnails dir for cleanliness */ |
1177 if ((dirs) && | |
1178 !(name[0] == '.' && (name[1] == '\0' || (name[1] == '.' && name[2] == '\0'))) && | |
1179 strcmp(name, GQVIEW_CACHE_LOCAL_THUMB) != 0 && | |
79
528e3432e0c0
Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents:
53
diff
changeset
|
1180 strcmp(name, GQVIEW_CACHE_LOCAL_METADATA) != 0 && |
528e3432e0c0
Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents:
53
diff
changeset
|
1181 strcmp(name, THUMB_FOLDER_LOCAL) != 0) |
9 | 1182 { |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
1183 dlist = g_list_prepend(dlist, file_data_new_local(filepath, &ent_sbuf, FALSE)); |
9 | 1184 } |
1 | 1185 } |
1186 else | |
1187 { | |
9 | 1188 if ((files) && filter_name_exists(name)) |
1189 { | |
148 | 1190 flist = g_list_prepend(flist, file_data_new_local(filepath, &ent_sbuf, TRUE)); |
9 | 1191 } |
1 | 1192 } |
1193 } | |
9 | 1194 g_free(filepath); |
1 | 1195 } |
1196 } | |
1197 | |
1198 closedir(dp); | |
1199 | |
9 | 1200 g_free(pathl); |
1 | 1201 |
148 | 1202 flist = filelist_filter_out_sidecars(flist); |
1203 | |
9 | 1204 if (dirs) *dirs = dlist; |
1205 if (files) *files = flist; | |
1 | 1206 |
9 | 1207 return TRUE; |
1 | 1208 } |
1209 | |
138 | 1210 gint filelist_read(const gchar *path, GList **files, GList **dirs) |
1211 { | |
1212 return filelist_read_real(path, files, dirs, TRUE); | |
1213 } | |
1214 | |
1215 gint filelist_read_lstat(const gchar *path, GList **files, GList **dirs) | |
1216 { | |
1217 return filelist_read_real(path, files, dirs, FALSE); | |
1218 } | |
1219 | |
9 | 1220 void filelist_free(GList *list) |
1 | 1221 { |
9 | 1222 GList *work; |
3 | 1223 |
9 | 1224 work = list; |
1225 while (work) | |
1 | 1226 { |
138 | 1227 file_data_unref((FileData *)work->data); |
1 | 1228 work = work->next; |
1229 } | |
1230 | |
9 | 1231 g_list_free(list); |
3 | 1232 } |
1233 | |
1 | 1234 |
138 | 1235 GList *filelist_copy(GList *list) |
1236 { | |
1237 GList *new_list = NULL; | |
1238 GList *work; | |
1239 | |
1240 work = list; | |
1241 while (work) | |
1242 { | |
1243 FileData *fd; | |
1244 | |
1245 fd = work->data; | |
1246 work = work->next; | |
1247 | |
1248 new_list = g_list_prepend(new_list, file_data_ref(fd)); | |
1249 } | |
1250 | |
1251 return g_list_reverse(new_list); | |
1252 } | |
1253 | |
1254 GList *filelist_from_path_list(GList *list) | |
1255 { | |
1256 GList *new_list = NULL; | |
1257 GList *work; | |
1258 | |
1259 work = list; | |
1260 while (work) | |
1261 { | |
1262 gchar *path; | |
1263 | |
1264 path = work->data; | |
1265 work = work->next; | |
1266 | |
1267 new_list = g_list_prepend(new_list, file_data_new_simple(path)); | |
1268 } | |
1269 | |
1270 return g_list_reverse(new_list); | |
1271 } | |
1272 | |
1273 GList *filelist_to_path_list(GList *list) | |
1274 { | |
1275 GList *new_list = NULL; | |
1276 GList *work; | |
1277 | |
1278 work = list; | |
1279 while (work) | |
1280 { | |
1281 FileData *fd; | |
1282 | |
1283 fd = work->data; | |
1284 work = work->next; | |
1285 | |
1286 new_list = g_list_prepend(new_list, g_strdup(fd->path)); | |
1287 } | |
1288 | |
1289 return g_list_reverse(new_list); | |
1290 } | |
1291 | |
1292 GList *filelist_filter(GList *list, gint is_dir_list) | |
1293 { | |
1294 GList *work; | |
1295 | |
1296 if (!is_dir_list && file_filter_disable && show_dot_files) return list; | |
1297 | |
1298 work = list; | |
1299 while (work) | |
1300 { | |
1301 FileData *fd = (FileData *)(work->data); | |
1302 const gchar *name = fd->name; | |
1303 | |
1304 if ((!show_dot_files && ishidden(name)) || | |
1305 (!is_dir_list && !filter_name_exists(name)) || | |
1306 (is_dir_list && name[0] == '.' && (strcmp(name, GQVIEW_CACHE_LOCAL_THUMB) == 0 || | |
1307 strcmp(name, GQVIEW_CACHE_LOCAL_METADATA) == 0)) ) | |
1308 { | |
1309 GList *link = work; | |
1310 work = work->next; | |
1311 list = g_list_remove_link(list, link); | |
1312 file_data_unref(fd); | |
1313 g_list_free(link); | |
1314 } | |
1315 else | |
1316 { | |
1317 work = work->next; | |
1318 } | |
1319 } | |
1320 | |
1321 return list; | |
1322 } | |
1323 | |
1324 /* | |
1325 *----------------------------------------------------------------------------- | |
1326 * filelist recursive | |
1327 *----------------------------------------------------------------------------- | |
1328 */ | |
1329 | |
1330 static gint filelist_sort_path_cb(gconstpointer a, gconstpointer b) | |
1331 { | |
1332 return CASE_SORT(((FileData *)a)->path, ((FileData *)b)->path); | |
1333 } | |
1334 | |
1335 GList *filelist_sort_path(GList *list) | |
1336 { | |
1337 return g_list_sort(list, filelist_sort_path_cb); | |
1338 } | |
1339 | |
1340 static void filelist_recursive_append(GList **list, GList *dirs) | |
1341 { | |
1342 GList *work; | |
1343 | |
1344 work = dirs; | |
1345 while (work) | |
1346 { | |
1347 FileData *fd = (FileData *)(work->data); | |
1348 const gchar *path = fd->path; | |
1349 GList *f = NULL; | |
1350 GList *d = NULL; | |
1351 | |
1352 if (filelist_read(path, &f, &d)) | |
1353 { | |
1354 f = filelist_filter(f, FALSE); | |
1355 f = filelist_sort_path(f); | |
1356 *list = g_list_concat(*list, f); | |
1357 | |
1358 d = filelist_filter(d, TRUE); | |
1359 d = filelist_sort_path(d); | |
1360 filelist_recursive_append(list, d); | |
1361 filelist_free(d); | |
1362 } | |
1363 | |
1364 work = work->next; | |
1365 } | |
1366 } | |
1367 | |
1368 GList *filelist_recursive(const gchar *path) | |
1369 { | |
1370 GList *list = NULL; | |
1371 GList *d = NULL; | |
1372 | |
1373 if (!filelist_read(path, &list, &d)) return NULL; | |
1374 list = filelist_filter(list, FALSE); | |
1375 list = filelist_sort_path(list); | |
1376 | |
1377 d = filelist_filter(d, TRUE); | |
1378 d = filelist_sort_path(d); | |
1379 filelist_recursive_append(&list, d); | |
1380 filelist_free(d); | |
1381 | |
1382 return list; | |
1383 } |