2 * Copyright (C) 2004 John Ellis
3 * Copyright (C) 2008 - 2016 The Geeqie Team
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "collect-io.h"
27 #include "layout-util.h"
28 #include "secure-save.h"
30 #include "ui-fileops.h"
32 #define GQ_COLLECTION_MARKER "#" GQ_APPNAME
34 #define GQ_COLLECTION_FAIL_MIN 300
35 #define GQ_COLLECTION_FAIL_PERCENT 98
36 #define GQ_COLLECTION_READ_BUFSIZE 4096
38 struct CollectManagerEntry;
40 static void collection_load_thumb_step(CollectionData *cd);
41 static gboolean collection_save_private(CollectionData *cd, const gchar *path);
43 static CollectManagerEntry *collect_manager_get_entry(const gchar *path);
44 static void collect_manager_entry_reset(CollectManagerEntry *entry);
45 static gint collect_manager_process_action(CollectManagerEntry *entry, gchar **path_ptr);
50 gboolean scan_geometry(gchar *buffer, GdkRectangle &window)
54 if (sscanf(buffer, "%d %d %d %d", &nx, &ny, &nw, &nh) != 4) return FALSE;
66 static gboolean collection_load_private(CollectionData *cd, const gchar *path, CollectionLoadFlags flags)
68 gchar s_buf[GQ_COLLECTION_READ_BUFSIZE];
71 gboolean limit_failures = TRUE;
72 gboolean success = TRUE;
73 gboolean has_official_header = FALSE;
74 gboolean has_geometry_header = FALSE;
75 gboolean has_gqview_header = FALSE;
76 gboolean need_header = TRUE;
79 gboolean changed = FALSE;
80 CollectManagerEntry *entry = nullptr;
81 guint flush = !!(flags & COLLECTION_LOAD_FLUSH);
82 guint append = !!(flags & COLLECTION_LOAD_APPEND);
83 guint only_geometry = !!(flags & COLLECTION_LOAD_GEOMETRY);
84 gboolean reading_extended_filename = FALSE;
89 collection_load_stop(cd);
92 collect_manager_flush();
94 entry = collect_manager_get_entry(path);
98 g_list_free_full(cd->list, reinterpret_cast<GDestroyNotify>(collection_info_free));
103 if (!path && !cd->path) return FALSE;
105 if (!path) path = cd->path;
107 pathl = path_from_utf8(path);
109 DEBUG_1("collection load: append=%d flush=%d only_geometry=%d path=%s",
110 append, flush, only_geometry, pathl);
113 f = fopen(pathl, "r");
117 log_printf("Failed to open collection file: \"%s\"\n", path);
121 GString *extended_filename_buffer = g_string_new(nullptr);
122 while (fgets(s_buf, sizeof(s_buf), f))
127 if (!reading_extended_filename)
129 /* Skip whitespaces and empty lines */
130 while (*p && g_ascii_isspace(*p)) p++;
131 if (*p == '\n' || *p == '\r') continue;
136 if (!need_header) continue;
137 if (g_ascii_strncasecmp(p, GQ_COLLECTION_MARKER, strlen(GQ_COLLECTION_MARKER)) == 0)
139 /* Looks like an official collection, allow unchecked input.
140 * All this does is allow adding files that may not exist,
141 * which is needed for the collection manager to work.
142 * Also unofficial files abort after too many invalid entries.
144 has_official_header = TRUE;
145 limit_failures = FALSE;
147 else if (strncmp(p, "#geometry:", 10 ) == 0 &&
148 scan_geometry(p + 10, cd->window))
150 has_geometry_header = TRUE;
151 cd->window_read = TRUE;
152 if (only_geometry) break;
154 else if (g_ascii_strncasecmp(p, "#GQview collection", strlen("#GQview collection")) == 0)
156 /* As 2008/04/15 there is no difference between our collection file format
157 * and GQview 2.1.5 collection file format so ignore failures as well. */
158 has_gqview_header = TRUE;
159 limit_failures = FALSE;
161 need_header = (!has_official_header && !has_gqview_header) || !has_geometry_header;
165 if (only_geometry) continue;
169 /** @todo This is not safe! */
170 /* Updated: anything within double quotes is considered a filename */
171 if (!reading_extended_filename)
173 /* not yet reading filename */
174 while (*p && *p != '"') p++;
176 /* start of filename read */
178 while (*p && *p != '"') p++;
181 /* first part of extended filename */
182 g_string_append(extended_filename_buffer, buf);
183 reading_extended_filename = TRUE;
190 while (*p && *p != '"') p++;
193 /* end of extended filename still not found */
194 g_string_append(extended_filename_buffer, buf);
199 /* end of extended filename found */
200 g_string_append_len(extended_filename_buffer, buf, p - buf);
201 reading_extended_filename = FALSE;
205 if (extended_filename_buffer->len > 0)
207 buffer2 = g_strdup(extended_filename_buffer->str);
208 g_string_erase(extended_filename_buffer, 0, -1);
213 buffer2 = g_strdup(buf);
221 changed |= collect_manager_process_action(entry, &buffer2);
223 valid = (buffer2[0] == G_DIR_SEPARATOR && collection_add_check(cd, file_data_new_simple(buffer2), FALSE, TRUE));
224 if (!valid) DEBUG_1("collection invalid file: %s", buffer2);
230 if (limit_failures &&
231 fail > GQ_COLLECTION_FAIL_MIN &&
232 fail * 100 / total > GQ_COLLECTION_FAIL_PERCENT)
234 log_printf("%d invalid filenames in unofficial collection file, closing: %s\n", fail, path);
243 g_string_free(extended_filename_buffer, TRUE);
245 DEBUG_1("collection files: total = %d fail = %d official=%d gqview=%d geometry=%d",
246 total, fail, has_official_header, has_gqview_header, has_geometry_header);
249 if (only_geometry) return has_geometry_header;
253 gchar *buf = nullptr;
254 while (collect_manager_process_action(entry, &buf))
256 collection_add_check(cd, file_data_new_group(buf), FALSE, TRUE);
263 cd->list = collection_list_sort(cd->list, cd->sort_method);
265 if (!flush && changed && success)
266 collection_save_private(cd, path);
269 collect_manager_entry_reset(entry);
271 if (!append) cd->changed = FALSE;
276 gboolean collection_load(CollectionData *cd, const gchar *path, CollectionLoadFlags flags)
278 if (collection_load_private(cd, path, static_cast<CollectionLoadFlags>(flags | COLLECTION_LOAD_FLUSH)))
280 layout_recent_add_path(cd->path);
287 static void collection_load_thumb_do(CollectionData *cd)
291 if (!cd->thumb_loader || !g_list_find(cd->list, cd->thumb_info)) return;
293 pixbuf = thumb_loader_get_pixbuf(cd->thumb_loader);
294 collection_info_set_thumb(cd->thumb_info, pixbuf);
295 g_object_unref(pixbuf);
297 if (cd->info_updated_func) cd->info_updated_func(cd, cd->thumb_info, cd->info_updated_data);
300 static void collection_load_thumb_error_cb(ThumbLoader *, gpointer data)
302 auto cd = static_cast<CollectionData *>(data);
304 collection_load_thumb_do(cd);
305 collection_load_thumb_step(cd);
308 static void collection_load_thumb_done_cb(ThumbLoader *, gpointer data)
310 auto cd = static_cast<CollectionData *>(data);
312 collection_load_thumb_do(cd);
313 collection_load_thumb_step(cd);
316 static void collection_load_thumb_step(CollectionData *cd)
323 collection_load_stop(cd);
328 ci = static_cast<CollectInfo *>(work->data);
330 /* find first unloaded thumb */
331 while (work && ci->pixbuf)
333 ci = static_cast<CollectInfo *>(work->data);
337 if (!ci || ci->pixbuf)
340 collection_load_stop(cd);
342 /* send a NULL CollectInfo to notify end */
343 if (cd->info_updated_func) cd->info_updated_func(cd, nullptr, cd->info_updated_data);
348 /* setup loader and call it */
350 thumb_loader_free(cd->thumb_loader);
351 cd->thumb_loader = thumb_loader_new(options->thumbnails.max_width, options->thumbnails.max_height);
352 thumb_loader_set_callbacks(cd->thumb_loader,
353 collection_load_thumb_done_cb,
354 collection_load_thumb_error_cb,
359 if (!thumb_loader_start(cd->thumb_loader, ci->fd))
361 /* error, handle it, do next */
362 DEBUG_1("error loading thumb for %s", ci->fd->path);
363 collection_load_thumb_do(cd);
364 collection_load_thumb_step(cd);
368 void collection_load_thumb_idle(CollectionData *cd)
370 if (!cd->thumb_loader) collection_load_thumb_step(cd);
373 gboolean collection_load_begin(CollectionData *cd, const gchar *path, CollectionLoadFlags flags)
375 if (!collection_load(cd, path, flags)) return FALSE;
377 collection_load_thumb_idle(cd);
382 void collection_load_stop(CollectionData *cd)
384 if (!cd->thumb_loader) return;
386 thumb_loader_free(cd->thumb_loader);
387 cd->thumb_loader = nullptr;
390 static gboolean collection_save_private(CollectionData *cd, const gchar *path)
396 if (!path && !cd->path) return FALSE;
404 pathl = path_from_utf8(path);
405 ssi = secure_open(pathl);
409 log_printf(_("failed to open collection (write) \"%s\"\n"), path);
413 secure_fprintf(ssi, "%s collection\n", GQ_COLLECTION_MARKER);
414 secure_fprintf(ssi, "#created with %s version %s\n", GQ_APPNAME, VERSION);
416 collection_update_geometry(cd);
419 secure_fprintf(ssi, "#geometry: %d %d %d %d\n", cd->window.x, cd->window.y, cd->window.width, cd->window.height);
423 while (work && secsave_errno == SS_ERR_NONE)
425 auto ci = static_cast<CollectInfo *>(work->data);
426 secure_fprintf(ssi, "\"%s\"\n", ci->fd->path);
430 secure_fprintf(ssi, "#end\n");
432 if (secure_close(ssi))
434 log_printf(_("error saving collection file: %s\nerror: %s\n"), path,
435 secsave_strerror(secsave_errno));
439 if (!cd->path || strcmp(path, cd->path) != 0)
441 gchar *buf = cd->path;
442 cd->path = g_strdup(path);
447 cd->name = g_strdup(filename_from_path(cd->path));
449 collection_path_changed(cd);
457 gboolean collection_save(CollectionData *cd, const gchar *path)
459 if (collection_save_private(cd, path))
461 layout_recent_add_path(cd->path);
468 gboolean collection_load_only_geometry(CollectionData *cd, const gchar *path)
470 return collection_load(cd, path, COLLECTION_LOAD_GEOMETRY);
475 *-------------------------------------------------------------------
477 *-------------------------------------------------------------------
480 #define COLLECT_MANAGER_ACTIONS_PER_IDLE 1000
481 #define COLLECT_MANAGER_FLUSH_DELAY 10000
483 struct CollectManagerEntry
487 GHashTable *oldpath_hash;
488 GHashTable *newpath_hash;
492 enum CollectManagerType {
493 COLLECTION_MANAGER_UPDATE,
494 COLLECTION_MANAGER_ADD,
495 COLLECTION_MANAGER_REMOVE
498 struct CollectManagerAction
503 CollectManagerType type;
509 static GList *collection_manager_entry_list = nullptr;
510 static GList *collection_manager_action_list = nullptr;
511 static GList *collection_manager_action_tail = nullptr;
512 static guint collection_manager_timer_id = 0; /* event source id */
515 static CollectManagerAction *collect_manager_action_new(const gchar *oldpath, const gchar *newpath,
516 CollectManagerType type)
518 CollectManagerAction *action;
520 action = g_new0(CollectManagerAction, 1);
523 action->oldpath = g_strdup(oldpath);
524 action->newpath = g_strdup(newpath);
531 static void collect_manager_action_ref(CollectManagerAction *action)
536 static void collect_manager_action_unref(CollectManagerAction *action)
540 if (action->ref > 0) return;
542 g_free(action->oldpath);
543 g_free(action->newpath);
547 static void collect_manager_entry_free_data(CollectManagerEntry *entry)
549 g_list_free_full(entry->add_list, reinterpret_cast<GDestroyNotify>(collect_manager_action_unref));
550 if (g_hash_table_size(entry->oldpath_hash) > 0)
551 g_hash_table_destroy(entry->oldpath_hash);
553 g_hash_table_unref(entry->oldpath_hash);
554 if (g_hash_table_size(entry->newpath_hash) > 0)
555 g_hash_table_destroy(entry->newpath_hash);
557 g_hash_table_unref(entry->newpath_hash);
560 static void collect_manager_entry_init_data(CollectManagerEntry *entry)
562 entry->add_list = nullptr;
563 entry->oldpath_hash = g_hash_table_new_full(g_str_hash, g_str_equal, nullptr, reinterpret_cast<GDestroyNotify>(collect_manager_action_unref));
564 entry->newpath_hash = g_hash_table_new(g_str_hash, g_str_equal);
569 static CollectManagerEntry *collect_manager_entry_new(const gchar *path)
571 CollectManagerEntry *entry;
573 entry = g_new0(CollectManagerEntry, 1);
574 entry->path = g_strdup(path);
575 collect_manager_entry_init_data(entry);
577 collection_manager_entry_list = g_list_append(collection_manager_entry_list, entry);
583 static void collect_manager_entry_free(CollectManagerEntry *entry)
585 collection_manager_entry_list = g_list_remove(collection_manager_entry_list, entry);
587 collect_manager_entry_free_data(entry);
593 static void collect_manager_entry_reset(CollectManagerEntry *entry)
595 collect_manager_entry_free_data(entry);
596 collect_manager_entry_init_data(entry);
599 static CollectManagerEntry *collect_manager_get_entry(const gchar *path)
603 work = collection_manager_entry_list;
606 CollectManagerEntry *entry;
608 entry = static_cast<CollectManagerEntry *>(work->data);
610 if (strcmp(entry->path, path) == 0)
619 static void collect_manager_entry_add_action(CollectManagerEntry *entry, CollectManagerAction *action)
622 CollectManagerAction *orig_action;
624 entry->empty = FALSE;
626 if (action->oldpath == nullptr)
629 if (action->newpath == nullptr)
634 orig_action = static_cast<CollectManagerAction *>(g_hash_table_lookup(entry->newpath_hash, action->newpath));
637 /* target already exists */
638 log_printf("collection manager failed to add another action for target %s in collection %s\n",
639 action->newpath, entry->path);
642 entry->add_list = g_list_append(entry->add_list, action);
643 g_hash_table_insert(entry->newpath_hash, action->newpath, action);
644 collect_manager_action_ref(action);
648 orig_action = static_cast<CollectManagerAction *>(g_hash_table_lookup(entry->newpath_hash, action->oldpath));
651 /* new action with the same file */
652 CollectManagerAction *new_action = collect_manager_action_new(orig_action->oldpath, action->newpath, action->type);
654 if (new_action->oldpath)
656 g_hash_table_steal(entry->oldpath_hash, orig_action->oldpath);
657 g_hash_table_insert(entry->oldpath_hash, new_action->oldpath, new_action);
661 GList *work = g_list_find(entry->add_list, orig_action);
662 work->data = new_action;
665 g_hash_table_steal(entry->newpath_hash, orig_action->newpath);
666 if (new_action->newpath)
668 g_hash_table_insert(entry->newpath_hash, new_action->newpath, new_action);
670 collect_manager_action_unref(orig_action);
675 orig_action = static_cast<CollectManagerAction *>(g_hash_table_lookup(entry->oldpath_hash, action->oldpath));
678 /* another action for the same source, ignore */
679 log_printf("collection manager failed to add another action for source %s in collection %s\n",
680 action->oldpath, entry->path);
684 g_hash_table_insert(entry->oldpath_hash, action->oldpath, action);
687 g_hash_table_insert(entry->newpath_hash, action->newpath, action);
689 collect_manager_action_ref(action);
692 static gboolean collect_manager_process_action(CollectManagerEntry *entry, gchar **path_ptr)
694 gchar *path = *path_ptr;
695 CollectManagerAction *action;
702 action = static_cast<CollectManagerAction *>(entry->add_list->data);
703 g_assert(action->oldpath == nullptr);
704 entry->add_list = g_list_remove(entry->add_list, action);
705 path = g_strdup(action->newpath);
706 g_hash_table_remove(entry->newpath_hash, path);
707 collect_manager_action_unref(action);
710 return (path != nullptr);
713 action = static_cast<CollectManagerAction *>(g_hash_table_lookup(entry->oldpath_hash, path));
717 strcpy(*path_ptr, action->newpath);
721 return FALSE; /* no change */
724 static void collect_manager_refresh()
730 dir_fd = file_data_new_dir(get_collections_dir());
731 filelist_read(dir_fd, &list, nullptr);
732 file_data_unref(dir_fd);
734 work = collection_manager_entry_list;
737 CollectManagerEntry *entry;
740 entry = static_cast<CollectManagerEntry *>(work->data);
744 while (list_step && entry)
748 fd = static_cast<FileData *>(list_step->data);
749 list_step = list_step->next;
751 if (strcmp(fd->path, entry->path) == 0)
753 list = g_list_remove(list, fd);
760 collect_manager_entry_free(entry);
772 fd = static_cast<FileData *>(work->data);
775 collect_manager_entry_new(fd->path);
781 static void collect_manager_process_actions(gint max)
783 if (collection_manager_action_list) DEBUG_1("collection manager processing actions");
785 while (collection_manager_action_list != nullptr && max > 0)
787 CollectManagerAction *action;
790 action = static_cast<CollectManagerAction *>(collection_manager_action_list->data);
791 work = collection_manager_entry_list;
794 CollectManagerEntry *entry;
796 entry = static_cast<CollectManagerEntry *>(work->data);
799 if (action->type == COLLECTION_MANAGER_UPDATE)
801 collect_manager_entry_add_action(entry, action);
803 else if (action->oldpath && action->newpath &&
804 strcmp(action->newpath, entry->path) == 0)
806 /* convert action to standard add format */
807 g_free(action->newpath);
808 if (action->type == COLLECTION_MANAGER_ADD)
810 action->newpath = action->oldpath;
811 action->oldpath = nullptr;
813 else if (action->type == COLLECTION_MANAGER_REMOVE)
815 action->newpath = nullptr;
817 collect_manager_entry_add_action(entry, action);
823 if (action->type != COLLECTION_MANAGER_UPDATE &&
824 action->oldpath && action->newpath)
826 log_printf("collection manager failed to %s %s for collection %s\n",
827 (action->type == COLLECTION_MANAGER_ADD) ? "add" : "remove",
828 action->oldpath, action->newpath);
831 if (collection_manager_action_tail == collection_manager_action_list)
833 collection_manager_action_tail = nullptr;
835 collection_manager_action_list = g_list_remove(collection_manager_action_list, action);
836 collect_manager_action_unref(action);
840 static gboolean collect_manager_process_entry(CollectManagerEntry *entry)
844 if (entry->empty) return FALSE;
846 cd = collection_new(entry->path);
847 (void) collection_load_private(cd, entry->path, COLLECTION_LOAD_NONE);
849 collection_unref(cd);
854 static gboolean collect_manager_process_entry_list()
858 work = collection_manager_entry_list;
861 CollectManagerEntry *entry;
863 entry = static_cast<CollectManagerEntry *>(work->data);
865 if (collect_manager_process_entry(entry)) return TRUE;
873 static gboolean collect_manager_process_cb(gpointer)
875 if (collection_manager_action_list) collect_manager_refresh();
876 collect_manager_process_actions(COLLECT_MANAGER_ACTIONS_PER_IDLE);
877 if (collection_manager_action_list) return G_SOURCE_CONTINUE;
879 if (collect_manager_process_entry_list()) return G_SOURCE_CONTINUE;
881 DEBUG_1("collection manager is up to date");
882 return G_SOURCE_REMOVE;
885 static gboolean collect_manager_timer_cb(gpointer)
887 DEBUG_1("collection manager timer expired");
889 g_idle_add_full(G_PRIORITY_LOW, collect_manager_process_cb, nullptr, nullptr);
891 collection_manager_timer_id = 0;
895 static void collect_manager_timer_push(gint stop)
897 if (collection_manager_timer_id)
901 g_source_remove(collection_manager_timer_id);
902 collection_manager_timer_id = 0;
907 collection_manager_timer_id = g_timeout_add(COLLECT_MANAGER_FLUSH_DELAY,
908 collect_manager_timer_cb, nullptr);
909 DEBUG_1("collection manager timer started");
913 static void collect_manager_add_action(CollectManagerAction *action)
917 /* we keep track of the list's tail to keep this a n(1) operation */
919 if (collection_manager_action_tail)
921 collection_manager_action_tail = g_list_append(collection_manager_action_tail, action);
922 collection_manager_action_tail = collection_manager_action_tail->next;
926 collection_manager_action_list = g_list_append(collection_manager_action_list, action);
927 collection_manager_action_tail = collection_manager_action_list;
930 collect_manager_timer_push(FALSE);
933 void collect_manager_moved(FileData *fd)
935 CollectManagerAction *action;
936 const gchar *oldpath = fd->change->source;
937 const gchar *newpath = fd->change->dest;
939 action = collect_manager_action_new(oldpath, newpath, COLLECTION_MANAGER_UPDATE);
940 collect_manager_add_action(action);
943 void collect_manager_add(FileData *fd, const gchar *collection)
945 CollectManagerAction *action;
948 if (!fd || !collection) return;
950 cw = collection_window_find_by_path(collection);
953 if (collection_list_find_fd(cw->cd->list, fd) == nullptr)
955 collection_add(cw->cd, fd, FALSE);
960 action = collect_manager_action_new(fd->path, collection, COLLECTION_MANAGER_ADD);
961 collect_manager_add_action(action);
964 void collect_manager_remove(FileData *fd, const gchar *collection)
966 CollectManagerAction *action;
969 if (!fd || !collection) return;
971 cw = collection_window_find_by_path(collection);
974 while (collection_remove(cw->cd, fd));
978 action = collect_manager_action_new(fd->path, collection, COLLECTION_MANAGER_REMOVE);
979 collect_manager_add_action(action);
982 void collect_manager_flush()
984 collect_manager_timer_push(TRUE);
986 DEBUG_1("collection manager flushing");
987 while (collect_manager_process_cb(nullptr));
990 void collect_manager_notify_cb(FileData *fd, NotifyType type, gpointer)
992 if (!(type & NOTIFY_CHANGE) || !fd->change) return;
994 DEBUG_1("Notify collect_manager: %s %04x", fd->path, type);
995 switch (fd->change->type)
997 case FILEDATA_CHANGE_MOVE:
998 collect_manager_moved(fd);
1000 case FILEDATA_CHANGE_COPY:
1002 case FILEDATA_CHANGE_RENAME:
1003 collect_manager_moved(fd);
1005 case FILEDATA_CHANGE_DELETE:
1006 case FILEDATA_CHANGE_UNSPECIFIED:
1007 case FILEDATA_CHANGE_WRITE_METADATA:
1012 static gint collection_manager_sort_cb(gconstpointer a, gconstpointer b)
1014 auto char_a = static_cast<const gchar *>(a);
1015 auto char_b = static_cast<const gchar *>(b);
1017 return g_strcmp0(char_a, char_b);
1021 * @brief Creates sorted list of collections
1022 * @param[out] names_exc sorted list of collections names excluding extension
1023 * @param[out] names_inc sorted list of collections names including extension
1024 * @param[out] paths sorted list of collection paths
1026 * Lists of type gchar.
1027 * Used lists must be freed with string_list_free()
1029 void collect_manager_list(GList **names_exc, GList **names_inc, GList **paths)
1032 GList *list = nullptr;
1037 if (names_exc == nullptr && names_inc == nullptr && paths == nullptr)
1042 dir_fd = file_data_new_dir((get_collections_dir()));
1044 filelist_read(dir_fd, &list, nullptr);
1048 fd = static_cast<FileData *>(list->data);
1049 filename = g_strdup(filename_from_path(fd->path));
1051 if (file_extension_match(filename, GQ_COLLECTION_EXT))
1053 name = remove_extension_from_path(filename);
1055 if (names_exc != nullptr)
1057 *names_exc = g_list_insert_sorted(*names_exc, g_strdup(name),
1058 collection_manager_sort_cb);
1059 *names_exc = g_list_first(*names_exc);
1061 if (names_inc != nullptr)
1063 *names_inc = g_list_insert_sorted(*names_inc,filename,
1064 collection_manager_sort_cb);
1065 *names_inc = g_list_first(*names_inc);
1067 if (paths != nullptr)
1069 *paths = g_list_insert_sorted(*paths, g_strdup(fd->path),
1070 collection_manager_sort_cb);
1071 *paths = g_list_first(*paths);
1079 filelist_free(list);
1081 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */