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!
18 #include "thumb_standard.h"
19 #include "ui_fileops.h"
23 *-----------------------------------------------------------------------------
25 *-----------------------------------------------------------------------------
28 static GList *filter_list = NULL;
29 static GList *extension_list = NULL;
30 static GList *sidecar_ext_list = NULL;
32 gint ishidden(const gchar *name)
34 if (name[0] != '.') return FALSE;
35 if (name[1] == '\0' || (name[1] == '.' && name[2] == '\0')) return FALSE;
39 static FilterEntry *filter_entry_new(const gchar *key, const gchar *description,
40 const gchar *extensions, gint enabled)
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;
53 static void filter_entry_free(FilterEntry *fe)
58 g_free(fe->description);
59 g_free(fe->extensions);
63 GList *filter_get_list(void)
68 void filter_remove_entry(FilterEntry *fe)
70 if (!g_list_find(filter_list, fe)) return;
72 filter_list = g_list_remove(filter_list, fe);
73 filter_entry_free(fe);
76 static gint filter_key_exists(const gchar *key)
80 if (!key) return FALSE;
85 FilterEntry *fe = work->data;
88 if (strcmp(fe->key, key) == 0) return TRUE;
94 void filter_add(const gchar *key, const gchar *description, const gchar *extensions, gint enabled)
96 filter_list = g_list_append(filter_list, filter_entry_new(key, description, extensions, enabled));
99 void filter_add_unique(const gchar *description, const gchar *extensions, gint enabled)
104 key = g_strdup("user0");
106 while (filter_key_exists(key))
110 key = g_strdup_printf("user%d", n);
114 filter_add(key, description, extensions, enabled);
118 static void filter_add_if_missing(const gchar *key, const gchar *description, const gchar *extensions, gint enabled)
127 FilterEntry *fe = work->data;
129 if (fe->key && strcmp(fe->key, key) == 0) return;
132 filter_add(key, description, extensions, enabled);
135 void filter_reset(void)
142 FilterEntry *fe = work->data;
144 filter_entry_free(fe);
147 g_list_free(filter_list);
151 void filter_add_defaults(void)
155 list = gdk_pixbuf_get_formats();
159 GdkPixbufFormat *format;
163 GString *filter = NULL;
169 name = gdk_pixbuf_format_get_name(format);
170 desc = gdk_pixbuf_format_get_description(format);
171 extensions = gdk_pixbuf_format_get_extensions(format);
174 while (extensions[i])
178 filter = g_string_new(".");
179 filter = g_string_append(filter, extensions[i]);
183 filter = g_string_append(filter, ";.");
184 filter = g_string_append(filter, extensions[i]);
189 if (debug) printf("loader reported [%s] [%s] [%s]\n", name, desc, filter->str);
191 filter_add_if_missing(name, desc, filter->str, TRUE);
195 g_strfreev(extensions);
196 g_string_free(filter, TRUE);
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);
212 filter_add_if_missing("xmp", "XMP sidecar", ".xmp", FALSE);
214 /* These are the raw camera formats with embedded jpeg/exif.
217 filter_add_if_missing("crw", "Canon raw format", ".crw;.cr2", TRUE);
218 filter_add_if_missing("raf", "Fujifilm raw format", ".raf", TRUE);
219 filter_add_if_missing("nef", "Nikon raw format", ".nef", TRUE);
220 filter_add_if_missing("orf", "Olympus raw format", ".orf", TRUE);
221 filter_add_if_missing("pef", "Pentax raw format", ".pef", TRUE);
224 GList *filter_to_list(const gchar *extensions)
229 if (!extensions) return NULL;
238 while (*p != '\0' && *p != ';')
243 list = g_list_append(list, g_strndup(b, l));
250 void filter_rebuild(void)
254 path_list_free(extension_list);
255 extension_list = NULL;
269 ext = filter_to_list(fe->extensions);
270 if (ext) extension_list = g_list_concat(extension_list, ext);
275 gint filter_name_exists(const gchar *name)
278 if (!extension_list || file_filter_disable) return TRUE;
280 work = extension_list;
283 gchar *filter = work->data;
284 gint lf = strlen(filter);
285 gint ln = strlen(name);
288 if (strncasecmp(name + ln - lf, filter, lf) == 0) return TRUE;
296 void filter_write_list(FILE *f)
303 FilterEntry *fe = work->data;
306 fprintf(f, "filter_ext: \"%s%s\" \"%s\" \"%s\"\n", (fe->enabled) ? "" : "#",
307 fe->key, fe->extensions,
308 (fe->description) ? fe->description : "");
312 void filter_parse(const gchar *text)
320 if (!text || text[0] != '"') return;
322 key = quoted_value(text);
327 while (*p != '"' && *p != '\0') p++;
334 while (*p != '"' && *p != '\0') p++;
341 ext = quoted_value(p);
344 while (*p != '"' && *p != '\0') p++;
346 while (*p != '"' && *p != '\0') p++;
350 desc = quoted_value(p);
357 if (key && key[0] == '#')
360 tmp = g_strdup(key + 1);
367 if (key && strlen(key) > 0 && ext) filter_add(key, desc, ext, enabled);
374 GList *path_list_filter(GList *list, gint is_dir_list)
378 if (!is_dir_list && file_filter_disable && show_dot_files) return list;
383 gchar *name = work->data;
386 base = filename_from_path(name);
388 if ((!show_dot_files && ishidden(base)) ||
389 (!is_dir_list && !filter_name_exists(base)) ||
390 (is_dir_list && base[0] == '.' && (strcmp(base, GQVIEW_CACHE_LOCAL_THUMB) == 0 ||
391 strcmp(base, GQVIEW_CACHE_LOCAL_METADATA) == 0)) )
395 list = g_list_remove_link(list, link);
410 *-----------------------------------------------------------------------------
411 * sidecar extension list
412 *-----------------------------------------------------------------------------
415 static GList *sidecar_ext_get_list(void)
417 return sidecar_ext_list;
420 void sidecar_ext_parse(const gchar *text, gint quoted)
425 work = sidecar_ext_list;
428 gchar *ext = work->data;
432 g_list_free(sidecar_ext_list);
433 sidecar_ext_list = NULL;
436 value = quoted_value(text);
438 value = g_strdup(text);
440 if (value == NULL) return;
442 sidecar_ext_list = filter_to_list(value);
447 void sidecar_ext_write(FILE *f)
450 fprintf(f, "\nsidecar_ext: \"%s\"\n", sidecar_ext_to_string());
453 char *sidecar_ext_to_string()
456 GString *str = g_string_new("");
458 work = sidecar_ext_list;
461 gchar *ext = work->data;
463 g_string_append(str, ext);
464 if (work) g_string_append(str, ";");
466 return g_string_free(str, FALSE);
469 void sidecar_ext_add_defaults()
471 sidecar_ext_parse(".jpg;.cr2;.nef;.crw;.xmp", FALSE);
475 *-----------------------------------------------------------------------------
476 * path list recursive
477 *-----------------------------------------------------------------------------
480 static gint path_list_sort_cb(gconstpointer a, gconstpointer b)
482 return CASE_SORT((gchar *)a, (gchar *)b);
485 GList *path_list_sort(GList *list)
487 return g_list_sort(list, path_list_sort_cb);
490 static void path_list_recursive_append(GList **list, GList *dirs)
497 const gchar *path = work->data;
501 if (path_list(path, &f, &d))
503 f = path_list_filter(f, FALSE);
504 f = path_list_sort(f);
505 *list = g_list_concat(*list, f);
507 d = path_list_filter(d, TRUE);
508 d = path_list_sort(d);
509 path_list_recursive_append(list, d);
517 GList *path_list_recursive(const gchar *path)
522 if (!path_list(path, &list, &d)) return NULL;
523 list = path_list_filter(list, FALSE);
524 list = path_list_sort(list);
526 d = path_list_filter(d, TRUE);
527 d = path_list_sort(d);
528 path_list_recursive_append(&list, d);
535 *-----------------------------------------------------------------------------
536 * text conversion utils
537 *-----------------------------------------------------------------------------
540 gchar *text_from_size(gint64 size)
546 /* what I would like to use is printf("%'d", size)
547 * BUT: not supported on every libc :(
549 if (size > G_MAXUINT)
551 /* the %lld conversion is not valid in all libcs, so use a simple work-around */
552 a = g_strdup_printf("%d%09d", (guint)(size / 1000000000), (guint)(size % 1000000000));
556 a = g_strdup_printf("%d", (guint)size);
562 b = g_new(gchar, l + n + 1);
587 gchar *text_from_size_abrev(gint64 size)
589 if (size < (gint64)1024)
591 return g_strdup_printf(_("%d bytes"), (gint)size);
593 if (size < (gint64)1048576)
595 return g_strdup_printf(_("%.1f K"), (double)size / 1024.0);
597 if (size < (gint64)1073741824)
599 return g_strdup_printf(_("%.1f MB"), (double)size / 1048576.0);
602 /* to avoid overflowing the double, do division in two steps */
604 return g_strdup_printf(_("%.1f GB"), (double)size / 1024.0);
607 /* note: returned string is valid until next call to text_from_time() */
608 const gchar *text_from_time(time_t t)
610 static gchar *ret = NULL;
614 GError *error = NULL;
616 btime = localtime(&t);
618 /* the %x warning about 2 digit years is not an error */
619 buflen = strftime(buf, sizeof(buf), "%x %H:%M", btime);
620 if (buflen < 1) return "";
623 ret = g_locale_to_utf8(buf, buflen, NULL, NULL, &error);
626 printf("Error converting locale strftime to UTF-8: %s\n", error->message);
635 *-----------------------------------------------------------------------------
637 *-----------------------------------------------------------------------------
640 FileData *file_data_merge_sidecar_files(FileData *target, FileData *source);
641 static void file_data_check_sidecars(FileData *fd);
642 FileData *file_data_disconnect_sidecar_file(FileData *target, FileData *sfd);
645 static void file_data_set_path(FileData *fd, const gchar *path)
648 if (strcmp(path, "/") == 0)
650 fd->path = g_strdup(path);
652 fd->extension = fd->name + 1;
656 fd->path = g_strdup(path);
657 fd->name = filename_from_path(fd->path);
659 if (strcmp(fd->name, "..") == 0)
661 gchar *dir = remove_level_from_path(path);
663 fd->path = remove_level_from_path(dir);
666 fd->extension = fd->name + 2;
669 else if (strcmp(fd->name, ".") == 0)
672 fd->path = remove_level_from_path(path);
674 fd->extension = fd->name + 1;
678 fd->extension = extension_from_path(fd->path);
679 if (fd->extension == NULL)
680 fd->extension = fd->name + strlen(fd->name);
683 static void file_data_check_changed_files(FileData *fd, struct stat *st)
686 if (fd->size != st->st_size ||
687 fd->date != st->st_mtime)
689 fd->size = st->st_size;
690 fd->date = st->st_mtime;
691 if (fd->pixbuf) g_object_unref(fd->pixbuf);
695 work = fd->sidecar_files;
698 FileData *sfd = work->data;
701 if (!stat_utf8(sfd->path, &st))
703 file_data_disconnect_sidecar_file(fd, sfd);
706 file_data_check_changed_files(sfd, &st);
711 static GHashTable *file_data_pool = NULL;
713 static FileData *file_data_new(const gchar *path_utf8, struct stat *st, gboolean check_sidecars)
717 if (debug) printf("file_data_new: '%s' %d\n", path_utf8, check_sidecars);
720 file_data_pool = g_hash_table_new (g_str_hash, g_str_equal);
722 fd = g_hash_table_lookup(file_data_pool, path_utf8);
725 file_data_check_changed_files(fd, st);
726 if (debug) printf("file_data_pool hit: '%s'\n", fd->path);
727 return file_data_ref(fd);
730 fd = g_new0(FileData, 1);
732 file_data_set_path(fd, path_utf8);
734 fd->original_path = g_strdup(path_utf8);
735 fd->size = st->st_size;
736 fd->date = st->st_mtime;
738 fd->sidecar_files = NULL;
740 fd->magick = 0x12345678;
742 g_hash_table_insert(file_data_pool, fd->original_path, fd);
744 if (check_sidecars && sidecar_file_priority(fd->extension))
745 file_data_check_sidecars(fd);
749 static void file_data_check_sidecars(FileData *fd)
752 int base_len = fd->extension - fd->path;
753 GString *fname = g_string_new_len(fd->path, base_len);
754 FileData *parent_fd = NULL;
755 GList *work = sidecar_ext_get_list();
758 /* check for possible sidecar files;
759 the sidecar files created here are referenced only via fd->sidecar_files or fd->parent,
760 they have fd->ref set to 0 and file_data unref must chack and free them all together
761 (using fd->ref would cause loops and leaks)
766 gchar *ext = work->data;
769 if (strcmp(ext, fd->extension) == 0)
771 new_fd = fd; /* processing the original file */
776 g_string_truncate(fname, base_len);
777 g_string_append(fname, ext);
779 if (!stat_utf8(fname->str, &nst))
782 new_fd = file_data_new(fname->str, &nst, FALSE);
783 new_fd->ref--; /* do not use ref here */
787 parent_fd = new_fd; /* parent is the one with the highest prio, found first */
789 file_data_merge_sidecar_files(parent_fd, new_fd);
791 g_string_free(fname, TRUE);
795 static FileData *file_data_new_local(const gchar *path, struct stat *st, gboolean check_sidecars)
797 gchar *path_utf8 = path_to_utf8(path);
798 FileData *ret = file_data_new(path_utf8, st, check_sidecars);
803 FileData *file_data_new_simple(const gchar *path_utf8)
807 if (!stat_utf8(path_utf8, &st))
813 return file_data_new(path_utf8, &st, TRUE);
816 FileData *file_data_add_sidecar_file(FileData *target, FileData *sfd)
818 sfd->parent = target;
819 if(!g_list_find(target->sidecar_files, sfd))
820 target->sidecar_files = g_list_prepend(target->sidecar_files, sfd);
825 FileData *file_data_merge_sidecar_files(FileData *target, FileData *source)
828 file_data_add_sidecar_file(target, source);
830 work = source->sidecar_files;
833 FileData *sfd = work->data;
834 file_data_add_sidecar_file(target, sfd);
838 g_list_free(source->sidecar_files);
839 source->sidecar_files = NULL;
841 target->sidecar_files = filelist_sort(target->sidecar_files, SORT_NAME, TRUE);
847 FileData *file_data_ref(FileData *fd)
849 if (fd == NULL) return NULL;
851 // return g_memdup(fd, sizeof(FileData));
852 g_assert(fd->magick == 0x12345678);
857 static void file_data_free(FileData *fd)
859 g_assert(fd->magick == 0x12345678);
860 g_assert(fd->ref == 0);
862 g_hash_table_remove(file_data_pool, fd->original_path);
865 g_free(fd->original_path);
866 if (fd->pixbuf) g_object_unref(fd->pixbuf);
869 g_assert(fd->sidecar_files == NULL); /* sidecar files must be freed before calling this */
871 file_data_change_info_free(NULL, fd);
875 void file_data_unref(FileData *fd)
877 if (fd == NULL) return;
878 g_assert(fd->magick == 0x12345678);
879 if (debug) printf("file_data_unref: '%s'\n", fd->path);
883 FileData *parent = fd->parent ? fd->parent : fd;
890 work = parent->sidecar_files;
893 FileData *sfd = work->data;
899 /* none of parent/children is referenced, we can free everything */
901 if (debug) printf("file_data_unref: deleting '%s', parent '%s'\n", fd->path, parent->path);
903 work = parent->sidecar_files;
906 FileData *sfd = work->data;
911 g_list_free(parent->sidecar_files);
912 parent->sidecar_files = NULL;
914 file_data_free(parent);
919 FileData *file_data_disconnect_sidecar_file(FileData *target, FileData *sfd)
921 sfd->parent = target;
922 g_assert(g_list_find(target->sidecar_files, sfd));
924 target->sidecar_files = g_list_remove(target->sidecar_files, sfd);
935 /* compare name without extension */
936 gint file_data_compare_name_without_ext(FileData *fd1, FileData *fd2)
938 size_t len1 = fd1->extension - fd1->name;
939 size_t len2 = fd2->extension - fd2->name;
941 if (len1 < len2) return -1;
942 if (len1 > len2) return 1;
944 return strncmp(fd1->name, fd2->name, len1);
947 FileData *file_data_do_change(FileData *fd)
950 g_assert(fd->change);
952 g_hash_table_remove(file_data_pool, fd->original_path);
953 g_free(fd->original_path);
954 file_data_set_path(fd, fd->change->dest);
955 fd->original_path = g_strdup(fd->change->dest);
956 g_hash_table_insert(file_data_pool, fd->original_path, fd);
960 gboolean file_data_add_change_info(FileData *fd, FileDataChangeType type, const gchar *src, const gchar *dest)
963 FileDataChangeInfo *fdci;
965 if (fd->change) return FALSE;
967 fdci = g_new0(FileDataChangeInfo, 1);
972 fdci->source = g_strdup(src);
974 fdci->source = g_strdup(fd->path);
977 fdci->dest = g_strdup(dest);
983 void file_data_change_info_free(FileDataChangeInfo *fdci, FileData *fd)
991 g_free(fdci->source);
1004 *-----------------------------------------------------------------------------
1005 * sidecar file info struct
1006 *-----------------------------------------------------------------------------
1011 gint sidecar_file_priority(const gchar *path)
1013 const char *extension = extension_from_path(path);
1016 if (extension == NULL)
1019 work = sidecar_ext_get_list();
1022 gchar *ext = work->data;
1024 if (strcmp(extension, ext) == 0) return i;
1030 gchar *sidecar_file_data_list_to_string(FileData *fd)
1033 GString *result = g_string_new("");
1035 work = fd->sidecar_files;
1038 FileData *sfd = work->data;
1039 result = g_string_append(result, "+ ");
1040 result = g_string_append(result, sfd->extension);
1042 if (work) result = g_string_append_c(result, ' ');
1045 return g_string_free(result, FALSE);
1049 *-----------------------------------------------------------------------------
1051 *-----------------------------------------------------------------------------
1054 static SortType filelist_sort_method = SORT_NONE;
1055 static gint filelist_sort_ascend = TRUE;
1058 gint filelist_sort_compare_filedata(FileData *fa, FileData *fb)
1060 if (!filelist_sort_ascend)
1067 switch (filelist_sort_method)
1070 if (fa->size < fb->size) return -1;
1071 if (fa->size > fb->size) return 1;
1072 return CASE_SORT(fa->name, fb->name); /* fall back to name */
1075 if (fa->date < fb->date) return -1;
1076 if (fa->date > fb->date) return 1;
1077 return CASE_SORT(fa->name, fb->name); /* fall back to name */
1079 #ifdef HAVE_STRVERSCMP
1081 return strverscmp(fa->name, fb->name);
1086 return CASE_SORT(fa->name, fb->name);
1091 gint filelist_sort_compare_filedata_full(FileData *fa, FileData *fb, SortType method, gint ascend)
1093 filelist_sort_method = method;
1094 filelist_sort_ascend = ascend;
1095 return filelist_sort_compare_filedata(fa, fb);
1098 static gint filelist_sort_file_cb(void *a, void *b)
1100 return filelist_sort_compare_filedata(a, b);
1103 GList *filelist_sort_full(GList *list, SortType method, gint ascend, GCompareFunc cb)
1105 filelist_sort_method = method;
1106 filelist_sort_ascend = ascend;
1107 return g_list_sort(list, cb);
1110 GList *filelist_insert_sort_full(GList *list, void *data, SortType method, gint ascend, GCompareFunc cb)
1112 filelist_sort_method = method;
1113 filelist_sort_ascend = ascend;
1114 return g_list_insert_sorted(list, data, cb);
1117 GList *filelist_sort(GList *list, SortType method, gint ascend)
1119 return filelist_sort_full(list, method, ascend, (GCompareFunc) filelist_sort_file_cb);
1122 GList *filelist_insert_sort(GList *list, FileData *fd, SortType method, gint ascend)
1124 return filelist_insert_sort_full(list, fd, method, ascend, (GCompareFunc) filelist_sort_file_cb);
1128 static GList *filelist_filter_out_sidecars(GList *flist)
1130 GList *work = flist;
1131 GList *flist_filtered = NULL;
1135 FileData *fd = work->data;
1137 if (fd->parent) /* remove fd's that are children */
1138 file_data_unref(fd);
1140 flist_filtered = g_list_prepend(flist_filtered, fd);
1143 return flist_filtered;
1146 static gint filelist_read_real(const gchar *path, GList **files, GList **dirs, gint follow_symlinks)
1150 struct stat ent_sbuf;
1158 pathl = path_from_utf8(path);
1159 if (!pathl || (dp = opendir(pathl)) == NULL)
1162 if (files) *files = NULL;
1163 if (dirs) *dirs = NULL;
1168 if (pathl[0] == '/' && pathl[1] == '\0')
1171 pathl = g_strdup("");
1174 while ((dir = readdir(dp)) != NULL)
1176 gchar *name = dir->d_name;
1177 if (show_dot_files || !ishidden(name))
1179 gchar *filepath = g_strconcat(pathl, "/", name, NULL);
1180 if ((follow_symlinks ?
1181 stat(filepath, &ent_sbuf) :
1182 lstat(filepath, &ent_sbuf)) >= 0)
1184 if (S_ISDIR(ent_sbuf.st_mode))
1186 /* we ignore the .thumbnails dir for cleanliness */
1188 !(name[0] == '.' && (name[1] == '\0' || (name[1] == '.' && name[2] == '\0'))) &&
1189 strcmp(name, GQVIEW_CACHE_LOCAL_THUMB) != 0 &&
1190 strcmp(name, GQVIEW_CACHE_LOCAL_METADATA) != 0 &&
1191 strcmp(name, THUMB_FOLDER_LOCAL) != 0)
1193 dlist = g_list_prepend(dlist, file_data_new_local(filepath, &ent_sbuf, FALSE));
1198 if ((files) && filter_name_exists(name))
1200 flist = g_list_prepend(flist, file_data_new_local(filepath, &ent_sbuf, TRUE));
1212 flist = filelist_filter_out_sidecars(flist);
1214 if (dirs) *dirs = dlist;
1215 if (files) *files = flist;
1220 gint filelist_read(const gchar *path, GList **files, GList **dirs)
1222 return filelist_read_real(path, files, dirs, TRUE);
1225 gint filelist_read_lstat(const gchar *path, GList **files, GList **dirs)
1227 return filelist_read_real(path, files, dirs, FALSE);
1230 void filelist_free(GList *list)
1237 file_data_unref((FileData *)work->data);
1245 GList *filelist_copy(GList *list)
1247 GList *new_list = NULL;
1258 new_list = g_list_prepend(new_list, file_data_ref(fd));
1261 return g_list_reverse(new_list);
1264 GList *filelist_from_path_list(GList *list)
1266 GList *new_list = NULL;
1277 new_list = g_list_prepend(new_list, file_data_new_simple(path));
1280 return g_list_reverse(new_list);
1283 GList *filelist_to_path_list(GList *list)
1285 GList *new_list = NULL;
1296 new_list = g_list_prepend(new_list, g_strdup(fd->path));
1299 return g_list_reverse(new_list);
1302 GList *filelist_filter(GList *list, gint is_dir_list)
1306 if (!is_dir_list && file_filter_disable && show_dot_files) return list;
1311 FileData *fd = (FileData *)(work->data);
1312 const gchar *name = fd->name;
1314 if ((!show_dot_files && ishidden(name)) ||
1315 (!is_dir_list && !filter_name_exists(name)) ||
1316 (is_dir_list && name[0] == '.' && (strcmp(name, GQVIEW_CACHE_LOCAL_THUMB) == 0 ||
1317 strcmp(name, GQVIEW_CACHE_LOCAL_METADATA) == 0)) )
1321 list = g_list_remove_link(list, link);
1322 file_data_unref(fd);
1335 *-----------------------------------------------------------------------------
1336 * filelist recursive
1337 *-----------------------------------------------------------------------------
1340 static gint filelist_sort_path_cb(gconstpointer a, gconstpointer b)
1342 return CASE_SORT(((FileData *)a)->path, ((FileData *)b)->path);
1345 GList *filelist_sort_path(GList *list)
1347 return g_list_sort(list, filelist_sort_path_cb);
1350 static void filelist_recursive_append(GList **list, GList *dirs)
1357 FileData *fd = (FileData *)(work->data);
1358 const gchar *path = fd->path;
1362 if (filelist_read(path, &f, &d))
1364 f = filelist_filter(f, FALSE);
1365 f = filelist_sort_path(f);
1366 *list = g_list_concat(*list, f);
1368 d = filelist_filter(d, TRUE);
1369 d = filelist_sort_path(d);
1370 filelist_recursive_append(list, d);
1378 GList *filelist_recursive(const gchar *path)
1383 if (!filelist_read(path, &list, &d)) return NULL;
1384 list = filelist_filter(list, FALSE);
1385 list = filelist_sort_path(list);
1387 d = filelist_filter(d, TRUE);
1388 d = filelist_sort_path(d);
1389 filelist_recursive_append(&list, d);