Skip to content

Commit

Permalink
improved directory scanning a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
nadvornik committed Nov 22, 2007
1 parent 106211b commit 5c3c806
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/filelist.c
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,24 @@ GList *filelist_insert_sort(GList *list, FileData *fd, SortType method, gint asc
}


static GList *filelist_filter_out_sidecars(GList *flist)
{
GList *work = flist;
GList *flist_filtered = NULL;

while (work)
{
FileData *fd = work->data;
work = work->next;
if (fd->parent) /* remove fd's that are children */
file_data_unref(fd);
else
flist_filtered = g_list_prepend(flist_filtered, fd);
}
g_list_free(flist);
return flist_filtered;
}

static gint filelist_read_real(const gchar *path, GList **files, GList **dirs, gint follow_symlinks)
{
DIR *dp;
Expand Down Expand Up @@ -1112,12 +1130,7 @@ static gint filelist_read_real(const gchar *path, GList **files, GList **dirs, g
{
if ((files) && filter_name_exists(name))
{
FileData *fd = file_data_new_local(filepath, &ent_sbuf, TRUE);

if (fd->parent)
file_data_unref(fd);
else
flist = g_list_prepend(flist, fd);
flist = g_list_prepend(flist, file_data_new_local(filepath, &ent_sbuf, TRUE));
}
}
}
Expand All @@ -1129,6 +1142,8 @@ static gint filelist_read_real(const gchar *path, GList **files, GList **dirs, g

g_free(pathl);

flist = filelist_filter_out_sidecars(flist);

if (dirs) *dirs = dlist;
if (files) *files = flist;

Expand Down

0 comments on commit 5c3c806

Please sign in to comment.