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.
22 #include "collect-io.h"
27 #include <gdk-pixbuf/gdk-pixbuf.h>
29 #include <glib-object.h>
37 #include "layout-util.h"
38 #include "main-defines.h"
40 #include "secure-save.h"
42 #include "ui-fileops.h"
44 #define GQ_COLLECTION_MARKER "#" GQ_APPNAME
47 GQ_COLLECTION_FAIL_MIN = 300,
48 GQ_COLLECTION_FAIL_PERCENT = 98,
49 GQ_COLLECTION_READ_BUFSIZE = 4096
52 struct CollectManagerEntry;
54 static void collection_load_thumb_step(CollectionData *cd);
55 static gboolean collection_save_private(CollectionData *cd, const gchar *path);
57 static CollectManagerEntry *collect_manager_get_entry(const gchar *path);
58 static void collect_manager_entry_reset(CollectManagerEntry *entry);
59 static gint collect_manager_process_action(CollectManagerEntry *entry, gchar **path_ptr);
64 gboolean scan_geometry(gchar *buffer, GdkRectangle &window)
71 if (sscanf(buffer, "%d %d %d %d", &nx, &ny, &nw, &nh) != 4) return FALSE;
83 static gboolean collection_load_private(CollectionData *cd, const gchar *path, CollectionLoadFlags flags)
85 gchar s_buf[GQ_COLLECTION_READ_BUFSIZE];
88 gboolean limit_failures = TRUE;
89 gboolean success = TRUE;
90 gboolean has_official_header = FALSE;
91 gboolean has_geometry_header = FALSE;
92 gboolean has_gqview_header = FALSE;
93 gboolean need_header = TRUE;
96 gboolean changed = FALSE;
97 CollectManagerEntry *entry = nullptr;
98 guint flush = !!(flags & COLLECTION_LOAD_FLUSH);
99 guint append = !!(flags & COLLECTION_LOAD_APPEND);
100 guint only_geometry = !!(flags & COLLECTION_LOAD_GEOMETRY);
101 gboolean reading_extended_filename = FALSE;
106 collection_load_stop(cd);
109 collect_manager_flush();
111 entry = collect_manager_get_entry(path);
115 g_list_free_full(cd->list, reinterpret_cast<GDestroyNotify>(collection_info_free));
120 if (!path && !cd->path) return FALSE;
122 if (!path) path = cd->path;
124 pathl = path_from_utf8(path);
126 DEBUG_1("collection load: append=%d flush=%d only_geometry=%d path=%s",
127 append, flush, only_geometry, pathl);
130 f = fopen(pathl, "r");
134 log_printf("Failed to open collection file: \"%s\"\n", path);
138 GString *extended_filename_buffer = g_string_new(nullptr);
139 while (fgets(s_buf, sizeof(s_buf), f))
144 if (!reading_extended_filename)
146 /* Skip whitespaces and empty lines */
147 while (*p && g_ascii_isspace(*p)) p++;
148 if (*p == '\n' || *p == '\r') continue;
153 if (!need_header) continue;
154 if (g_ascii_strncasecmp(p, GQ_COLLECTION_MARKER, strlen(GQ_COLLECTION_MARKER)) == 0)
156 /* Looks like an official collection, allow unchecked input.
157 * All this does is allow adding files that may not exist,
158 * which is needed for the collection manager to work.
159 * Also unofficial files abort after too many invalid entries.
161 has_official_header = TRUE;
162 limit_failures = FALSE;
164 else if (strncmp(p, "#geometry:", 10 ) == 0 &&
165 scan_geometry(p + 10, cd->window))
167 has_geometry_header = TRUE;
168 cd->window_read = TRUE;
169 if (only_geometry) break;
171 else if (g_ascii_strncasecmp(p, "#GQview collection", strlen("#GQview collection")) == 0)
173 /* As 2008/04/15 there is no difference between our collection file format
174 * and GQview 2.1.5 collection file format so ignore failures as well. */
175 has_gqview_header = TRUE;
176 limit_failures = FALSE;
178 need_header = (!has_official_header && !has_gqview_header) || !has_geometry_header;
182 if (only_geometry) continue;
186 /** @todo This is not safe! */
187 /* Updated: anything within double quotes is considered a filename */
188 if (!reading_extended_filename)
190 /* not yet reading filename */
191 while (*p && *p != '"') p++;
193 /* start of filename read */
195 while (*p && *p != '"') p++;
198 /* first part of extended filename */
199 g_string_append(extended_filename_buffer, buf);
200 reading_extended_filename = TRUE;
207 while (*p && *p != '"') p++;
210 /* end of extended filename still not found */
211 g_string_append(extended_filename_buffer, buf);
215 /* end of extended filename found */
216 g_string_append_len(extended_filename_buffer, buf, p - buf);
217 reading_extended_filename = FALSE;
220 if (extended_filename_buffer->len > 0)
222 buffer2 = g_strdup(extended_filename_buffer->str);
223 g_string_erase(extended_filename_buffer, 0, -1);
228 buffer2 = g_strdup(buf);
236 changed |= collect_manager_process_action(entry, &buffer2);
238 valid = (buffer2[0] == G_DIR_SEPARATOR && collection_add_check(cd, file_data_new_simple(buffer2), FALSE, TRUE));
239 if (!valid) DEBUG_1("collection invalid file: %s", buffer2);
245 if (limit_failures &&
246 fail > GQ_COLLECTION_FAIL_MIN &&
247 fail * 100 / total > GQ_COLLECTION_FAIL_PERCENT)
249 log_printf("%d invalid filenames in unofficial collection file, closing: %s\n", fail, path);
258 g_string_free(extended_filename_buffer, TRUE);
260 DEBUG_1("collection files: total = %d fail = %d official=%d gqview=%d geometry=%d",
261 total, fail, has_official_header, has_gqview_header, has_geometry_header);
264 if (only_geometry) return has_geometry_header;
268 gchar *buf = nullptr;
269 while (collect_manager_process_action(entry, &buf))
271 collection_add_check(cd, file_data_new_group(buf), FALSE, TRUE);
278 cd->list = collection_list_sort(cd->list, cd->sort_method);
280 if (!flush && changed && success)
281 collection_save_private(cd, path);
284 collect_manager_entry_reset(entry);
286 if (!append) cd->changed = FALSE;
291 gboolean collection_load(CollectionData *cd, const gchar *path, CollectionLoadFlags flags)
293 if (collection_load_private(cd, path, static_cast<CollectionLoadFlags>(flags | COLLECTION_LOAD_FLUSH)))
295 layout_recent_add_path(cd->path);
302 static void collection_load_thumb_do(CollectionData *cd)
306 if (!cd->thumb_loader || !g_list_find(cd->list, cd->thumb_info)) return;
308 pixbuf = thumb_loader_get_pixbuf(cd->thumb_loader);
309 collection_info_set_thumb(cd->thumb_info, pixbuf);
310 g_object_unref(pixbuf);
312 if (cd->info_updated_func) cd->info_updated_func(cd, cd->thumb_info, cd->info_updated_data);
315 static void collection_load_thumb_error_cb(ThumbLoader *, gpointer data)
317 auto cd = static_cast<CollectionData *>(data);
319 collection_load_thumb_do(cd);
320 collection_load_thumb_step(cd);
323 static void collection_load_thumb_done_cb(ThumbLoader *, gpointer data)
325 auto cd = static_cast<CollectionData *>(data);
327 collection_load_thumb_do(cd);
328 collection_load_thumb_step(cd);
331 static void collection_load_thumb_step(CollectionData *cd)
338 collection_load_stop(cd);
343 ci = static_cast<CollectInfo *>(work->data);
345 /* find first unloaded thumb */
346 while (work && ci->pixbuf)
348 ci = static_cast<CollectInfo *>(work->data);
352 if (!ci || ci->pixbuf)
355 collection_load_stop(cd);
357 /* send a NULL CollectInfo to notify end */
358 if (cd->info_updated_func) cd->info_updated_func(cd, nullptr, cd->info_updated_data);
363 /* setup loader and call it */
365 thumb_loader_free(cd->thumb_loader);
366 cd->thumb_loader = thumb_loader_new(options->thumbnails.max_width, options->thumbnails.max_height);
367 thumb_loader_set_callbacks(cd->thumb_loader,
368 collection_load_thumb_done_cb,
369 collection_load_thumb_error_cb,
374 if (!thumb_loader_start(cd->thumb_loader, ci->fd))
376 /* error, handle it, do next */
377 DEBUG_1("error loading thumb for %s", ci->fd->path);
378 collection_load_thumb_do(cd);
379 collection_load_thumb_step(cd);
383 void collection_load_thumb_idle(CollectionData *cd)
385 if (!cd->thumb_loader) collection_load_thumb_step(cd);
388 gboolean collection_load_begin(CollectionData *cd, const gchar *path, CollectionLoadFlags flags)
390 if (!collection_load(cd, path, flags)) return FALSE;
392 collection_load_thumb_idle(cd);
397 void collection_load_stop(CollectionData *cd)
399 if (!cd->thumb_loader) return;
401 thumb_loader_free(cd->thumb_loader);
402 cd->thumb_loader = nullptr;
405 static gboolean collection_save_private(CollectionData *cd, const gchar *path)
411 if (!path && !cd->path) return FALSE;
419 pathl = path_from_utf8(path);
420 ssi = secure_open(pathl);
424 log_printf(_("failed to open collection (write) \"%s\"\n"), path);
428 secure_fprintf(ssi, "%s collection\n", GQ_COLLECTION_MARKER);
429 secure_fprintf(ssi, "#created with %s version %s\n", GQ_APPNAME, VERSION);
431 collection_update_geometry(cd);
434 secure_fprintf(ssi, "#geometry: %d %d %d %d\n", cd->window.x, cd->window.y, cd->window.width, cd->window.height);
438 while (work && secsave_errno == SS_ERR_NONE)
440 auto ci = static_cast<CollectInfo *>(work->data);
441 secure_fprintf(ssi, "\"%s\"\n", ci->fd->path);
445 secure_fprintf(ssi, "#end\n");
447 if (secure_close(ssi))
449 log_printf(_("error saving collection file: %s\nerror: %s\n"), path,
450 secsave_strerror(secsave_errno));
454 if (!cd->path || strcmp(path, cd->path) != 0)
456 gchar *buf = cd->path;
457 cd->path = g_strdup(path);
462 cd->name = g_strdup(filename_from_path(cd->path));
464 collection_path_changed(cd);
472 gboolean collection_save(CollectionData *cd, const gchar *path)
474 if (collection_save_private(cd, path))
476 layout_recent_add_path(cd->path);
483 gboolean collection_load_only_geometry(CollectionData *cd, const gchar *path)
485 return collection_load(cd, path, COLLECTION_LOAD_GEOMETRY);
490 *-------------------------------------------------------------------
492 *-------------------------------------------------------------------
496 COLLECT_MANAGER_ACTIONS_PER_IDLE = 1000,
497 COLLECT_MANAGER_FLUSH_DELAY = 10000
500 struct CollectManagerEntry
504 GHashTable *oldpath_hash;
505 GHashTable *newpath_hash;
509 enum CollectManagerType {
510 COLLECTION_MANAGER_UPDATE,
511 COLLECTION_MANAGER_ADD,
512 COLLECTION_MANAGER_REMOVE
515 struct CollectManagerAction
520 CollectManagerType type;
526 static GList *collection_manager_entry_list = nullptr;
527 static GList *collection_manager_action_list = nullptr;
528 static GList *collection_manager_action_tail = nullptr;
529 static guint collection_manager_timer_id = 0; /* event source id */
532 static CollectManagerAction *collect_manager_action_new(const gchar *oldpath, const gchar *newpath,
533 CollectManagerType type)
535 CollectManagerAction *action;
537 action = g_new0(CollectManagerAction, 1);
540 action->oldpath = g_strdup(oldpath);
541 action->newpath = g_strdup(newpath);
548 static void collect_manager_action_ref(CollectManagerAction *action)
553 static void collect_manager_action_unref(CollectManagerAction *action)
557 if (action->ref > 0) return;
559 g_free(action->oldpath);
560 g_free(action->newpath);
564 static void collect_manager_entry_free_data(CollectManagerEntry *entry)
566 g_list_free_full(entry->add_list, reinterpret_cast<GDestroyNotify>(collect_manager_action_unref));
567 if (g_hash_table_size(entry->oldpath_hash) > 0)
568 g_hash_table_destroy(entry->oldpath_hash);
570 g_hash_table_unref(entry->oldpath_hash);
571 if (g_hash_table_size(entry->newpath_hash) > 0)
572 g_hash_table_destroy(entry->newpath_hash);
574 g_hash_table_unref(entry->newpath_hash);
577 static void collect_manager_entry_init_data(CollectManagerEntry *entry)
579 entry->add_list = nullptr;
580 entry->oldpath_hash = g_hash_table_new_full(g_str_hash, g_str_equal, nullptr, reinterpret_cast<GDestroyNotify>(collect_manager_action_unref));
581 entry->newpath_hash = g_hash_table_new(g_str_hash, g_str_equal);
586 static CollectManagerEntry *collect_manager_entry_new(const gchar *path)
588 CollectManagerEntry *entry;
590 entry = g_new0(CollectManagerEntry, 1);
591 entry->path = g_strdup(path);
592 collect_manager_entry_init_data(entry);
594 collection_manager_entry_list = g_list_append(collection_manager_entry_list, entry);
600 static void collect_manager_entry_free(CollectManagerEntry *entry)
602 collection_manager_entry_list = g_list_remove(collection_manager_entry_list, entry);
604 collect_manager_entry_free_data(entry);
610 static void collect_manager_entry_reset(CollectManagerEntry *entry)
612 collect_manager_entry_free_data(entry);
613 collect_manager_entry_init_data(entry);
616 static CollectManagerEntry *collect_manager_get_entry(const gchar *path)
620 work = collection_manager_entry_list;
623 CollectManagerEntry *entry;
625 entry = static_cast<CollectManagerEntry *>(work->data);
627 if (strcmp(entry->path, path) == 0)
636 static void collect_manager_entry_add_action(CollectManagerEntry *entry, CollectManagerAction *action)
639 CollectManagerAction *orig_action;
641 entry->empty = FALSE;
643 if (action->oldpath == nullptr)
646 if (action->newpath == nullptr)
651 orig_action = static_cast<CollectManagerAction *>(g_hash_table_lookup(entry->newpath_hash, action->newpath));
654 /* target already exists */
655 log_printf("collection manager failed to add another action for target %s in collection %s\n",
656 action->newpath, entry->path);
659 entry->add_list = g_list_append(entry->add_list, action);
660 g_hash_table_insert(entry->newpath_hash, action->newpath, action);
661 collect_manager_action_ref(action);
665 orig_action = static_cast<CollectManagerAction *>(g_hash_table_lookup(entry->newpath_hash, action->oldpath));
668 /* new action with the same file */
669 CollectManagerAction *new_action = collect_manager_action_new(orig_action->oldpath, action->newpath, action->type);
671 if (new_action->oldpath)
673 g_hash_table_steal(entry->oldpath_hash, orig_action->oldpath);
674 g_hash_table_insert(entry->oldpath_hash, new_action->oldpath, new_action);
678 GList *work = g_list_find(entry->add_list, orig_action);
679 work->data = new_action;
682 g_hash_table_steal(entry->newpath_hash, orig_action->newpath);
683 if (new_action->newpath)
685 g_hash_table_insert(entry->newpath_hash, new_action->newpath, new_action);
687 collect_manager_action_unref(orig_action);
692 orig_action = static_cast<CollectManagerAction *>(g_hash_table_lookup(entry->oldpath_hash, action->oldpath));
695 /* another action for the same source, ignore */
696 log_printf("collection manager failed to add another action for source %s in collection %s\n",
697 action->oldpath, entry->path);
701 g_hash_table_insert(entry->oldpath_hash, action->oldpath, action);
704 g_hash_table_insert(entry->newpath_hash, action->newpath, action);
706 collect_manager_action_ref(action);
709 static gboolean collect_manager_process_action(CollectManagerEntry *entry, gchar **path_ptr)
711 gchar *path = *path_ptr;
712 CollectManagerAction *action;
719 action = static_cast<CollectManagerAction *>(entry->add_list->data);
720 g_assert(action->oldpath == nullptr);
721 entry->add_list = g_list_remove(entry->add_list, action);
722 path = g_strdup(action->newpath);
723 g_hash_table_remove(entry->newpath_hash, path);
724 collect_manager_action_unref(action);
727 return (path != nullptr);
730 action = static_cast<CollectManagerAction *>(g_hash_table_lookup(entry->oldpath_hash, path));
734 strcpy(*path_ptr, action->newpath);
738 return FALSE; /* no change */
741 static void collect_manager_refresh()
747 dir_fd = file_data_new_dir(get_collections_dir());
748 filelist_read(dir_fd, &list, nullptr);
749 file_data_unref(dir_fd);
751 work = collection_manager_entry_list;
754 CollectManagerEntry *entry;
757 entry = static_cast<CollectManagerEntry *>(work->data);
761 while (list_step && entry)
765 fd = static_cast<FileData *>(list_step->data);
766 list_step = list_step->next;
768 if (strcmp(fd->path, entry->path) == 0)
770 list = g_list_remove(list, fd);
777 collect_manager_entry_free(entry);
789 fd = static_cast<FileData *>(work->data);
792 collect_manager_entry_new(fd->path);
798 static void collect_manager_process_actions(gint max)
800 if (collection_manager_action_list) DEBUG_1("collection manager processing actions");
802 while (collection_manager_action_list != nullptr && max > 0)
804 CollectManagerAction *action;
807 action = static_cast<CollectManagerAction *>(collection_manager_action_list->data);
808 work = collection_manager_entry_list;
811 CollectManagerEntry *entry;
813 entry = static_cast<CollectManagerEntry *>(work->data);
816 if (action->type == COLLECTION_MANAGER_UPDATE)
818 collect_manager_entry_add_action(entry, action);
820 else if (action->oldpath && action->newpath &&
821 strcmp(action->newpath, entry->path) == 0)
823 /* convert action to standard add format */
824 g_free(action->newpath);
825 if (action->type == COLLECTION_MANAGER_ADD)
827 action->newpath = action->oldpath;
828 action->oldpath = nullptr;
830 else if (action->type == COLLECTION_MANAGER_REMOVE)
832 action->newpath = nullptr;
834 collect_manager_entry_add_action(entry, action);
840 if (action->type != COLLECTION_MANAGER_UPDATE &&
841 action->oldpath && action->newpath)
843 log_printf("collection manager failed to %s %s for collection %s\n",
844 (action->type == COLLECTION_MANAGER_ADD) ? "add" : "remove",
845 action->oldpath, action->newpath);
848 if (collection_manager_action_tail == collection_manager_action_list)
850 collection_manager_action_tail = nullptr;
852 collection_manager_action_list = g_list_remove(collection_manager_action_list, action);
853 collect_manager_action_unref(action);
857 static gboolean collect_manager_process_entry(CollectManagerEntry *entry)
861 if (entry->empty) return FALSE;
863 cd = collection_new(entry->path);
864 (void) collection_load_private(cd, entry->path, COLLECTION_LOAD_NONE);
866 collection_unref(cd);
871 static gboolean collect_manager_process_entry_list()
875 work = collection_manager_entry_list;
878 CollectManagerEntry *entry;
880 entry = static_cast<CollectManagerEntry *>(work->data);
882 if (collect_manager_process_entry(entry)) return TRUE;
890 static gboolean collect_manager_process_cb(gpointer)
892 if (collection_manager_action_list) collect_manager_refresh();
893 collect_manager_process_actions(COLLECT_MANAGER_ACTIONS_PER_IDLE);
894 if (collection_manager_action_list) return G_SOURCE_CONTINUE;
896 if (collect_manager_process_entry_list()) return G_SOURCE_CONTINUE;
898 DEBUG_1("collection manager is up to date");
899 return G_SOURCE_REMOVE;
902 static gboolean collect_manager_timer_cb(gpointer)
904 DEBUG_1("collection manager timer expired");
906 g_idle_add_full(G_PRIORITY_LOW, collect_manager_process_cb, nullptr, nullptr);
908 collection_manager_timer_id = 0;
912 static void collect_manager_timer_push(gint stop)
914 if (collection_manager_timer_id)
918 g_source_remove(collection_manager_timer_id);
919 collection_manager_timer_id = 0;
924 collection_manager_timer_id = g_timeout_add(COLLECT_MANAGER_FLUSH_DELAY,
925 collect_manager_timer_cb, nullptr);
926 DEBUG_1("collection manager timer started");
930 static void collect_manager_add_action(CollectManagerAction *action)
934 /* we keep track of the list's tail to keep this a n(1) operation */
936 if (collection_manager_action_tail)
938 collection_manager_action_tail = g_list_append(collection_manager_action_tail, action);
939 collection_manager_action_tail = collection_manager_action_tail->next;
943 collection_manager_action_list = g_list_append(collection_manager_action_list, action);
944 collection_manager_action_tail = collection_manager_action_list;
947 collect_manager_timer_push(FALSE);
950 void collect_manager_moved(FileData *fd)
952 CollectManagerAction *action;
953 const gchar *oldpath = fd->change->source;
954 const gchar *newpath = fd->change->dest;
956 action = collect_manager_action_new(oldpath, newpath, COLLECTION_MANAGER_UPDATE);
957 collect_manager_add_action(action);
960 void collect_manager_add(FileData *fd, const gchar *collection)
962 CollectManagerAction *action;
965 if (!fd || !collection) return;
967 cw = collection_window_find_by_path(collection);
970 if (collection_list_find_fd(cw->cd->list, fd) == nullptr)
972 collection_add(cw->cd, fd, FALSE);
977 action = collect_manager_action_new(fd->path, collection, COLLECTION_MANAGER_ADD);
978 collect_manager_add_action(action);
981 void collect_manager_remove(FileData *fd, const gchar *collection)
983 CollectManagerAction *action;
986 if (!fd || !collection) return;
988 cw = collection_window_find_by_path(collection);
991 while (collection_remove(cw->cd, fd));
995 action = collect_manager_action_new(fd->path, collection, COLLECTION_MANAGER_REMOVE);
996 collect_manager_add_action(action);
999 void collect_manager_flush()
1001 collect_manager_timer_push(TRUE);
1003 DEBUG_1("collection manager flushing");
1004 while (collect_manager_process_cb(nullptr));
1007 void collect_manager_notify_cb(FileData *fd, NotifyType type, gpointer)
1009 if (!(type & NOTIFY_CHANGE) || !fd->change) return;
1011 DEBUG_1("Notify collect_manager: %s %04x", fd->path, type);
1012 switch (fd->change->type)
1014 case FILEDATA_CHANGE_MOVE:
1015 collect_manager_moved(fd);
1017 case FILEDATA_CHANGE_COPY:
1019 case FILEDATA_CHANGE_RENAME:
1020 collect_manager_moved(fd);
1022 case FILEDATA_CHANGE_DELETE:
1023 case FILEDATA_CHANGE_UNSPECIFIED:
1024 case FILEDATA_CHANGE_WRITE_METADATA:
1029 static gint collection_manager_sort_cb(gconstpointer a, gconstpointer b)
1031 auto char_a = static_cast<const gchar *>(a);
1032 auto char_b = static_cast<const gchar *>(b);
1034 return g_strcmp0(char_a, char_b);
1038 * @brief Creates sorted list of collections
1039 * @param[out] names_exc sorted list of collections names excluding extension
1040 * @param[out] names_inc sorted list of collections names including extension
1041 * @param[out] paths sorted list of collection paths
1043 * Lists of type gchar.
1044 * Used lists must be freed with string_list_free()
1046 void collect_manager_list(GList **names_exc, GList **names_inc, GList **paths)
1049 GList *list = nullptr;
1054 if (names_exc == nullptr && names_inc == nullptr && paths == nullptr)
1059 dir_fd = file_data_new_dir((get_collections_dir()));
1061 filelist_read(dir_fd, &list, nullptr);
1065 fd = static_cast<FileData *>(list->data);
1066 filename = g_strdup(filename_from_path(fd->path));
1068 if (file_extension_match(filename, GQ_COLLECTION_EXT))
1070 name = remove_extension_from_path(filename);
1072 if (names_exc != nullptr)
1074 *names_exc = g_list_insert_sorted(*names_exc, g_strdup(name),
1075 collection_manager_sort_cb);
1076 *names_exc = g_list_first(*names_exc);
1078 if (names_inc != nullptr)
1080 *names_inc = g_list_insert_sorted(*names_inc,filename,
1081 collection_manager_sort_cb);
1082 *names_inc = g_list_first(*names_inc);
1084 if (paths != nullptr)
1086 *paths = g_list_insert_sorted(*paths, g_strdup(fd->path),
1087 collection_manager_sort_cb);
1088 *paths = g_list_first(*paths);
1096 filelist_free(list);
1098 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */