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
35 GQ_COLLECTION_FAIL_MIN = 300,
36 GQ_COLLECTION_FAIL_PERCENT = 98,
37 GQ_COLLECTION_READ_BUFSIZE = 4096
40 struct CollectManagerEntry;
42 static void collection_load_thumb_step(CollectionData *cd);
43 static gboolean collection_save_private(CollectionData *cd, const gchar *path);
45 static CollectManagerEntry *collect_manager_get_entry(const gchar *path);
46 static void collect_manager_entry_reset(CollectManagerEntry *entry);
47 static gint collect_manager_process_action(CollectManagerEntry *entry, gchar **path_ptr);
52 gboolean scan_geometry(gchar *buffer, GdkRectangle &window)
59 if (sscanf(buffer, "%d %d %d %d", &nx, &ny, &nw, &nh) != 4) return FALSE;
71 static gboolean collection_load_private(CollectionData *cd, const gchar *path, CollectionLoadFlags flags)
73 gchar s_buf[GQ_COLLECTION_READ_BUFSIZE];
76 gboolean limit_failures = TRUE;
77 gboolean success = TRUE;
78 gboolean has_official_header = FALSE;
79 gboolean has_geometry_header = FALSE;
80 gboolean has_gqview_header = FALSE;
81 gboolean need_header = TRUE;
84 gboolean changed = FALSE;
85 CollectManagerEntry *entry = nullptr;
86 guint flush = !!(flags & COLLECTION_LOAD_FLUSH);
87 guint append = !!(flags & COLLECTION_LOAD_APPEND);
88 guint only_geometry = !!(flags & COLLECTION_LOAD_GEOMETRY);
89 gboolean reading_extended_filename = FALSE;
94 collection_load_stop(cd);
97 collect_manager_flush();
99 entry = collect_manager_get_entry(path);
103 g_list_free_full(cd->list, reinterpret_cast<GDestroyNotify>(collection_info_free));
108 if (!path && !cd->path) return FALSE;
110 if (!path) path = cd->path;
112 pathl = path_from_utf8(path);
114 DEBUG_1("collection load: append=%d flush=%d only_geometry=%d path=%s",
115 append, flush, only_geometry, pathl);
118 f = fopen(pathl, "r");
122 log_printf("Failed to open collection file: \"%s\"\n", path);
126 GString *extended_filename_buffer = g_string_new(nullptr);
127 while (fgets(s_buf, sizeof(s_buf), f))
132 if (!reading_extended_filename)
134 /* Skip whitespaces and empty lines */
135 while (*p && g_ascii_isspace(*p)) p++;
136 if (*p == '\n' || *p == '\r') continue;
141 if (!need_header) continue;
142 if (g_ascii_strncasecmp(p, GQ_COLLECTION_MARKER, strlen(GQ_COLLECTION_MARKER)) == 0)
144 /* Looks like an official collection, allow unchecked input.
145 * All this does is allow adding files that may not exist,
146 * which is needed for the collection manager to work.
147 * Also unofficial files abort after too many invalid entries.
149 has_official_header = TRUE;
150 limit_failures = FALSE;
152 else if (strncmp(p, "#geometry:", 10 ) == 0 &&
153 scan_geometry(p + 10, cd->window))
155 has_geometry_header = TRUE;
156 cd->window_read = TRUE;
157 if (only_geometry) break;
159 else if (g_ascii_strncasecmp(p, "#GQview collection", strlen("#GQview collection")) == 0)
161 /* As 2008/04/15 there is no difference between our collection file format
162 * and GQview 2.1.5 collection file format so ignore failures as well. */
163 has_gqview_header = TRUE;
164 limit_failures = FALSE;
166 need_header = (!has_official_header && !has_gqview_header) || !has_geometry_header;
170 if (only_geometry) continue;
174 /** @todo This is not safe! */
175 /* Updated: anything within double quotes is considered a filename */
176 if (!reading_extended_filename)
178 /* not yet reading filename */
179 while (*p && *p != '"') p++;
181 /* start of filename read */
183 while (*p && *p != '"') p++;
186 /* first part of extended filename */
187 g_string_append(extended_filename_buffer, buf);
188 reading_extended_filename = TRUE;
195 while (*p && *p != '"') p++;
198 /* end of extended filename still not found */
199 g_string_append(extended_filename_buffer, buf);
203 /* end of extended filename found */
204 g_string_append_len(extended_filename_buffer, buf, p - buf);
205 reading_extended_filename = FALSE;
208 if (extended_filename_buffer->len > 0)
210 buffer2 = g_strdup(extended_filename_buffer->str);
211 g_string_erase(extended_filename_buffer, 0, -1);
216 buffer2 = g_strdup(buf);
224 changed |= collect_manager_process_action(entry, &buffer2);
226 valid = (buffer2[0] == G_DIR_SEPARATOR && collection_add_check(cd, file_data_new_simple(buffer2), FALSE, TRUE));
227 if (!valid) DEBUG_1("collection invalid file: %s", buffer2);
233 if (limit_failures &&
234 fail > GQ_COLLECTION_FAIL_MIN &&
235 fail * 100 / total > GQ_COLLECTION_FAIL_PERCENT)
237 log_printf("%d invalid filenames in unofficial collection file, closing: %s\n", fail, path);
246 g_string_free(extended_filename_buffer, TRUE);
248 DEBUG_1("collection files: total = %d fail = %d official=%d gqview=%d geometry=%d",
249 total, fail, has_official_header, has_gqview_header, has_geometry_header);
252 if (only_geometry) return has_geometry_header;
256 gchar *buf = nullptr;
257 while (collect_manager_process_action(entry, &buf))
259 collection_add_check(cd, file_data_new_group(buf), FALSE, TRUE);
266 cd->list = collection_list_sort(cd->list, cd->sort_method);
268 if (!flush && changed && success)
269 collection_save_private(cd, path);
272 collect_manager_entry_reset(entry);
274 if (!append) cd->changed = FALSE;
279 gboolean collection_load(CollectionData *cd, const gchar *path, CollectionLoadFlags flags)
281 if (collection_load_private(cd, path, static_cast<CollectionLoadFlags>(flags | COLLECTION_LOAD_FLUSH)))
283 layout_recent_add_path(cd->path);
290 static void collection_load_thumb_do(CollectionData *cd)
294 if (!cd->thumb_loader || !g_list_find(cd->list, cd->thumb_info)) return;
296 pixbuf = thumb_loader_get_pixbuf(cd->thumb_loader);
297 collection_info_set_thumb(cd->thumb_info, pixbuf);
298 g_object_unref(pixbuf);
300 if (cd->info_updated_func) cd->info_updated_func(cd, cd->thumb_info, cd->info_updated_data);
303 static void collection_load_thumb_error_cb(ThumbLoader *, gpointer data)
305 auto cd = static_cast<CollectionData *>(data);
307 collection_load_thumb_do(cd);
308 collection_load_thumb_step(cd);
311 static void collection_load_thumb_done_cb(ThumbLoader *, gpointer data)
313 auto cd = static_cast<CollectionData *>(data);
315 collection_load_thumb_do(cd);
316 collection_load_thumb_step(cd);
319 static void collection_load_thumb_step(CollectionData *cd)
326 collection_load_stop(cd);
331 ci = static_cast<CollectInfo *>(work->data);
333 /* find first unloaded thumb */
334 while (work && ci->pixbuf)
336 ci = static_cast<CollectInfo *>(work->data);
340 if (!ci || ci->pixbuf)
343 collection_load_stop(cd);
345 /* send a NULL CollectInfo to notify end */
346 if (cd->info_updated_func) cd->info_updated_func(cd, nullptr, cd->info_updated_data);
351 /* setup loader and call it */
353 thumb_loader_free(cd->thumb_loader);
354 cd->thumb_loader = thumb_loader_new(options->thumbnails.max_width, options->thumbnails.max_height);
355 thumb_loader_set_callbacks(cd->thumb_loader,
356 collection_load_thumb_done_cb,
357 collection_load_thumb_error_cb,
362 if (!thumb_loader_start(cd->thumb_loader, ci->fd))
364 /* error, handle it, do next */
365 DEBUG_1("error loading thumb for %s", ci->fd->path);
366 collection_load_thumb_do(cd);
367 collection_load_thumb_step(cd);
371 void collection_load_thumb_idle(CollectionData *cd)
373 if (!cd->thumb_loader) collection_load_thumb_step(cd);
376 gboolean collection_load_begin(CollectionData *cd, const gchar *path, CollectionLoadFlags flags)
378 if (!collection_load(cd, path, flags)) return FALSE;
380 collection_load_thumb_idle(cd);
385 void collection_load_stop(CollectionData *cd)
387 if (!cd->thumb_loader) return;
389 thumb_loader_free(cd->thumb_loader);
390 cd->thumb_loader = nullptr;
393 static gboolean collection_save_private(CollectionData *cd, const gchar *path)
399 if (!path && !cd->path) return FALSE;
407 pathl = path_from_utf8(path);
408 ssi = secure_open(pathl);
412 log_printf(_("failed to open collection (write) \"%s\"\n"), path);
416 secure_fprintf(ssi, "%s collection\n", GQ_COLLECTION_MARKER);
417 secure_fprintf(ssi, "#created with %s version %s\n", GQ_APPNAME, VERSION);
419 collection_update_geometry(cd);
422 secure_fprintf(ssi, "#geometry: %d %d %d %d\n", cd->window.x, cd->window.y, cd->window.width, cd->window.height);
426 while (work && secsave_errno == SS_ERR_NONE)
428 auto ci = static_cast<CollectInfo *>(work->data);
429 secure_fprintf(ssi, "\"%s\"\n", ci->fd->path);
433 secure_fprintf(ssi, "#end\n");
435 if (secure_close(ssi))
437 log_printf(_("error saving collection file: %s\nerror: %s\n"), path,
438 secsave_strerror(secsave_errno));
442 if (!cd->path || strcmp(path, cd->path) != 0)
444 gchar *buf = cd->path;
445 cd->path = g_strdup(path);
450 cd->name = g_strdup(filename_from_path(cd->path));
452 collection_path_changed(cd);
460 gboolean collection_save(CollectionData *cd, const gchar *path)
462 if (collection_save_private(cd, path))
464 layout_recent_add_path(cd->path);
471 gboolean collection_load_only_geometry(CollectionData *cd, const gchar *path)
473 return collection_load(cd, path, COLLECTION_LOAD_GEOMETRY);
478 *-------------------------------------------------------------------
480 *-------------------------------------------------------------------
484 COLLECT_MANAGER_ACTIONS_PER_IDLE = 1000,
485 COLLECT_MANAGER_FLUSH_DELAY = 10000
488 struct CollectManagerEntry
492 GHashTable *oldpath_hash;
493 GHashTable *newpath_hash;
497 enum CollectManagerType {
498 COLLECTION_MANAGER_UPDATE,
499 COLLECTION_MANAGER_ADD,
500 COLLECTION_MANAGER_REMOVE
503 struct CollectManagerAction
508 CollectManagerType type;
514 static GList *collection_manager_entry_list = nullptr;
515 static GList *collection_manager_action_list = nullptr;
516 static GList *collection_manager_action_tail = nullptr;
517 static guint collection_manager_timer_id = 0; /* event source id */
520 static CollectManagerAction *collect_manager_action_new(const gchar *oldpath, const gchar *newpath,
521 CollectManagerType type)
523 CollectManagerAction *action;
525 action = g_new0(CollectManagerAction, 1);
528 action->oldpath = g_strdup(oldpath);
529 action->newpath = g_strdup(newpath);
536 static void collect_manager_action_ref(CollectManagerAction *action)
541 static void collect_manager_action_unref(CollectManagerAction *action)
545 if (action->ref > 0) return;
547 g_free(action->oldpath);
548 g_free(action->newpath);
552 static void collect_manager_entry_free_data(CollectManagerEntry *entry)
554 g_list_free_full(entry->add_list, reinterpret_cast<GDestroyNotify>(collect_manager_action_unref));
555 if (g_hash_table_size(entry->oldpath_hash) > 0)
556 g_hash_table_destroy(entry->oldpath_hash);
558 g_hash_table_unref(entry->oldpath_hash);
559 if (g_hash_table_size(entry->newpath_hash) > 0)
560 g_hash_table_destroy(entry->newpath_hash);
562 g_hash_table_unref(entry->newpath_hash);
565 static void collect_manager_entry_init_data(CollectManagerEntry *entry)
567 entry->add_list = nullptr;
568 entry->oldpath_hash = g_hash_table_new_full(g_str_hash, g_str_equal, nullptr, reinterpret_cast<GDestroyNotify>(collect_manager_action_unref));
569 entry->newpath_hash = g_hash_table_new(g_str_hash, g_str_equal);
574 static CollectManagerEntry *collect_manager_entry_new(const gchar *path)
576 CollectManagerEntry *entry;
578 entry = g_new0(CollectManagerEntry, 1);
579 entry->path = g_strdup(path);
580 collect_manager_entry_init_data(entry);
582 collection_manager_entry_list = g_list_append(collection_manager_entry_list, entry);
588 static void collect_manager_entry_free(CollectManagerEntry *entry)
590 collection_manager_entry_list = g_list_remove(collection_manager_entry_list, entry);
592 collect_manager_entry_free_data(entry);
598 static void collect_manager_entry_reset(CollectManagerEntry *entry)
600 collect_manager_entry_free_data(entry);
601 collect_manager_entry_init_data(entry);
604 static CollectManagerEntry *collect_manager_get_entry(const gchar *path)
608 work = collection_manager_entry_list;
611 CollectManagerEntry *entry;
613 entry = static_cast<CollectManagerEntry *>(work->data);
615 if (strcmp(entry->path, path) == 0)
624 static void collect_manager_entry_add_action(CollectManagerEntry *entry, CollectManagerAction *action)
627 CollectManagerAction *orig_action;
629 entry->empty = FALSE;
631 if (action->oldpath == nullptr)
634 if (action->newpath == nullptr)
639 orig_action = static_cast<CollectManagerAction *>(g_hash_table_lookup(entry->newpath_hash, action->newpath));
642 /* target already exists */
643 log_printf("collection manager failed to add another action for target %s in collection %s\n",
644 action->newpath, entry->path);
647 entry->add_list = g_list_append(entry->add_list, action);
648 g_hash_table_insert(entry->newpath_hash, action->newpath, action);
649 collect_manager_action_ref(action);
653 orig_action = static_cast<CollectManagerAction *>(g_hash_table_lookup(entry->newpath_hash, action->oldpath));
656 /* new action with the same file */
657 CollectManagerAction *new_action = collect_manager_action_new(orig_action->oldpath, action->newpath, action->type);
659 if (new_action->oldpath)
661 g_hash_table_steal(entry->oldpath_hash, orig_action->oldpath);
662 g_hash_table_insert(entry->oldpath_hash, new_action->oldpath, new_action);
666 GList *work = g_list_find(entry->add_list, orig_action);
667 work->data = new_action;
670 g_hash_table_steal(entry->newpath_hash, orig_action->newpath);
671 if (new_action->newpath)
673 g_hash_table_insert(entry->newpath_hash, new_action->newpath, new_action);
675 collect_manager_action_unref(orig_action);
680 orig_action = static_cast<CollectManagerAction *>(g_hash_table_lookup(entry->oldpath_hash, action->oldpath));
683 /* another action for the same source, ignore */
684 log_printf("collection manager failed to add another action for source %s in collection %s\n",
685 action->oldpath, entry->path);
689 g_hash_table_insert(entry->oldpath_hash, action->oldpath, action);
692 g_hash_table_insert(entry->newpath_hash, action->newpath, action);
694 collect_manager_action_ref(action);
697 static gboolean collect_manager_process_action(CollectManagerEntry *entry, gchar **path_ptr)
699 gchar *path = *path_ptr;
700 CollectManagerAction *action;
707 action = static_cast<CollectManagerAction *>(entry->add_list->data);
708 g_assert(action->oldpath == nullptr);
709 entry->add_list = g_list_remove(entry->add_list, action);
710 path = g_strdup(action->newpath);
711 g_hash_table_remove(entry->newpath_hash, path);
712 collect_manager_action_unref(action);
715 return (path != nullptr);
718 action = static_cast<CollectManagerAction *>(g_hash_table_lookup(entry->oldpath_hash, path));
722 strcpy(*path_ptr, action->newpath);
726 return FALSE; /* no change */
729 static void collect_manager_refresh()
735 dir_fd = file_data_new_dir(get_collections_dir());
736 filelist_read(dir_fd, &list, nullptr);
737 file_data_unref(dir_fd);
739 work = collection_manager_entry_list;
742 CollectManagerEntry *entry;
745 entry = static_cast<CollectManagerEntry *>(work->data);
749 while (list_step && entry)
753 fd = static_cast<FileData *>(list_step->data);
754 list_step = list_step->next;
756 if (strcmp(fd->path, entry->path) == 0)
758 list = g_list_remove(list, fd);
765 collect_manager_entry_free(entry);
777 fd = static_cast<FileData *>(work->data);
780 collect_manager_entry_new(fd->path);
786 static void collect_manager_process_actions(gint max)
788 if (collection_manager_action_list) DEBUG_1("collection manager processing actions");
790 while (collection_manager_action_list != nullptr && max > 0)
792 CollectManagerAction *action;
795 action = static_cast<CollectManagerAction *>(collection_manager_action_list->data);
796 work = collection_manager_entry_list;
799 CollectManagerEntry *entry;
801 entry = static_cast<CollectManagerEntry *>(work->data);
804 if (action->type == COLLECTION_MANAGER_UPDATE)
806 collect_manager_entry_add_action(entry, action);
808 else if (action->oldpath && action->newpath &&
809 strcmp(action->newpath, entry->path) == 0)
811 /* convert action to standard add format */
812 g_free(action->newpath);
813 if (action->type == COLLECTION_MANAGER_ADD)
815 action->newpath = action->oldpath;
816 action->oldpath = nullptr;
818 else if (action->type == COLLECTION_MANAGER_REMOVE)
820 action->newpath = nullptr;
822 collect_manager_entry_add_action(entry, action);
828 if (action->type != COLLECTION_MANAGER_UPDATE &&
829 action->oldpath && action->newpath)
831 log_printf("collection manager failed to %s %s for collection %s\n",
832 (action->type == COLLECTION_MANAGER_ADD) ? "add" : "remove",
833 action->oldpath, action->newpath);
836 if (collection_manager_action_tail == collection_manager_action_list)
838 collection_manager_action_tail = nullptr;
840 collection_manager_action_list = g_list_remove(collection_manager_action_list, action);
841 collect_manager_action_unref(action);
845 static gboolean collect_manager_process_entry(CollectManagerEntry *entry)
849 if (entry->empty) return FALSE;
851 cd = collection_new(entry->path);
852 (void) collection_load_private(cd, entry->path, COLLECTION_LOAD_NONE);
854 collection_unref(cd);
859 static gboolean collect_manager_process_entry_list()
863 work = collection_manager_entry_list;
866 CollectManagerEntry *entry;
868 entry = static_cast<CollectManagerEntry *>(work->data);
870 if (collect_manager_process_entry(entry)) return TRUE;
878 static gboolean collect_manager_process_cb(gpointer)
880 if (collection_manager_action_list) collect_manager_refresh();
881 collect_manager_process_actions(COLLECT_MANAGER_ACTIONS_PER_IDLE);
882 if (collection_manager_action_list) return G_SOURCE_CONTINUE;
884 if (collect_manager_process_entry_list()) return G_SOURCE_CONTINUE;
886 DEBUG_1("collection manager is up to date");
887 return G_SOURCE_REMOVE;
890 static gboolean collect_manager_timer_cb(gpointer)
892 DEBUG_1("collection manager timer expired");
894 g_idle_add_full(G_PRIORITY_LOW, collect_manager_process_cb, nullptr, nullptr);
896 collection_manager_timer_id = 0;
900 static void collect_manager_timer_push(gint stop)
902 if (collection_manager_timer_id)
906 g_source_remove(collection_manager_timer_id);
907 collection_manager_timer_id = 0;
912 collection_manager_timer_id = g_timeout_add(COLLECT_MANAGER_FLUSH_DELAY,
913 collect_manager_timer_cb, nullptr);
914 DEBUG_1("collection manager timer started");
918 static void collect_manager_add_action(CollectManagerAction *action)
922 /* we keep track of the list's tail to keep this a n(1) operation */
924 if (collection_manager_action_tail)
926 collection_manager_action_tail = g_list_append(collection_manager_action_tail, action);
927 collection_manager_action_tail = collection_manager_action_tail->next;
931 collection_manager_action_list = g_list_append(collection_manager_action_list, action);
932 collection_manager_action_tail = collection_manager_action_list;
935 collect_manager_timer_push(FALSE);
938 void collect_manager_moved(FileData *fd)
940 CollectManagerAction *action;
941 const gchar *oldpath = fd->change->source;
942 const gchar *newpath = fd->change->dest;
944 action = collect_manager_action_new(oldpath, newpath, COLLECTION_MANAGER_UPDATE);
945 collect_manager_add_action(action);
948 void collect_manager_add(FileData *fd, const gchar *collection)
950 CollectManagerAction *action;
953 if (!fd || !collection) return;
955 cw = collection_window_find_by_path(collection);
958 if (collection_list_find_fd(cw->cd->list, fd) == nullptr)
960 collection_add(cw->cd, fd, FALSE);
965 action = collect_manager_action_new(fd->path, collection, COLLECTION_MANAGER_ADD);
966 collect_manager_add_action(action);
969 void collect_manager_remove(FileData *fd, const gchar *collection)
971 CollectManagerAction *action;
974 if (!fd || !collection) return;
976 cw = collection_window_find_by_path(collection);
979 while (collection_remove(cw->cd, fd));
983 action = collect_manager_action_new(fd->path, collection, COLLECTION_MANAGER_REMOVE);
984 collect_manager_add_action(action);
987 void collect_manager_flush()
989 collect_manager_timer_push(TRUE);
991 DEBUG_1("collection manager flushing");
992 while (collect_manager_process_cb(nullptr));
995 void collect_manager_notify_cb(FileData *fd, NotifyType type, gpointer)
997 if (!(type & NOTIFY_CHANGE) || !fd->change) return;
999 DEBUG_1("Notify collect_manager: %s %04x", fd->path, type);
1000 switch (fd->change->type)
1002 case FILEDATA_CHANGE_MOVE:
1003 collect_manager_moved(fd);
1005 case FILEDATA_CHANGE_COPY:
1007 case FILEDATA_CHANGE_RENAME:
1008 collect_manager_moved(fd);
1010 case FILEDATA_CHANGE_DELETE:
1011 case FILEDATA_CHANGE_UNSPECIFIED:
1012 case FILEDATA_CHANGE_WRITE_METADATA:
1017 static gint collection_manager_sort_cb(gconstpointer a, gconstpointer b)
1019 auto char_a = static_cast<const gchar *>(a);
1020 auto char_b = static_cast<const gchar *>(b);
1022 return g_strcmp0(char_a, char_b);
1026 * @brief Creates sorted list of collections
1027 * @param[out] names_exc sorted list of collections names excluding extension
1028 * @param[out] names_inc sorted list of collections names including extension
1029 * @param[out] paths sorted list of collection paths
1031 * Lists of type gchar.
1032 * Used lists must be freed with string_list_free()
1034 void collect_manager_list(GList **names_exc, GList **names_inc, GList **paths)
1037 GList *list = nullptr;
1042 if (names_exc == nullptr && names_inc == nullptr && paths == nullptr)
1047 dir_fd = file_data_new_dir((get_collections_dir()));
1049 filelist_read(dir_fd, &list, nullptr);
1053 fd = static_cast<FileData *>(list->data);
1054 filename = g_strdup(filename_from_path(fd->path));
1056 if (file_extension_match(filename, GQ_COLLECTION_EXT))
1058 name = remove_extension_from_path(filename);
1060 if (names_exc != nullptr)
1062 *names_exc = g_list_insert_sorted(*names_exc, g_strdup(name),
1063 collection_manager_sort_cb);
1064 *names_exc = g_list_first(*names_exc);
1066 if (names_inc != nullptr)
1068 *names_inc = g_list_insert_sorted(*names_inc,filename,
1069 collection_manager_sort_cb);
1070 *names_inc = g_list_first(*names_inc);
1072 if (paths != nullptr)
1074 *paths = g_list_insert_sorted(*paths, g_strdup(fd->path),
1075 collection_manager_sort_cb);
1076 *paths = g_list_first(*paths);
1084 filelist_free(list);
1086 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */