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