Mercurial > geeqie.yaz
comparison src/filelist.c @ 148:a8b4b99c9359
improved directory scanning a bit
author | nadvornik |
---|---|
date | Thu, 22 Nov 2007 21:15:35 +0000 |
parents | b2266996fa83 |
children | f8bd5d49eed8 |
comparison
equal
deleted
inserted
replaced
147:b2266996fa83 | 148:a8b4b99c9359 |
---|---|
1055 GList *filelist_insert_sort(GList *list, FileData *fd, SortType method, gint ascend) | 1055 GList *filelist_insert_sort(GList *list, FileData *fd, SortType method, gint ascend) |
1056 { | 1056 { |
1057 return filelist_insert_sort_full(list, fd, method, ascend, (GCompareFunc) filelist_sort_file_cb); | 1057 return filelist_insert_sort_full(list, fd, method, ascend, (GCompareFunc) filelist_sort_file_cb); |
1058 } | 1058 } |
1059 | 1059 |
1060 | |
1061 static GList *filelist_filter_out_sidecars(GList *flist) | |
1062 { | |
1063 GList *work = flist; | |
1064 GList *flist_filtered = NULL; | |
1065 | |
1066 while (work) | |
1067 { | |
1068 FileData *fd = work->data; | |
1069 work = work->next; | |
1070 if (fd->parent) /* remove fd's that are children */ | |
1071 file_data_unref(fd); | |
1072 else | |
1073 flist_filtered = g_list_prepend(flist_filtered, fd); | |
1074 } | |
1075 g_list_free(flist); | |
1076 return flist_filtered; | |
1077 } | |
1060 | 1078 |
1061 static gint filelist_read_real(const gchar *path, GList **files, GList **dirs, gint follow_symlinks) | 1079 static gint filelist_read_real(const gchar *path, GList **files, GList **dirs, gint follow_symlinks) |
1062 { | 1080 { |
1063 DIR *dp; | 1081 DIR *dp; |
1064 struct dirent *dir; | 1082 struct dirent *dir; |
1110 } | 1128 } |
1111 else | 1129 else |
1112 { | 1130 { |
1113 if ((files) && filter_name_exists(name)) | 1131 if ((files) && filter_name_exists(name)) |
1114 { | 1132 { |
1115 FileData *fd = file_data_new_local(filepath, &ent_sbuf, TRUE); | 1133 flist = g_list_prepend(flist, file_data_new_local(filepath, &ent_sbuf, TRUE)); |
1116 | |
1117 if (fd->parent) | |
1118 file_data_unref(fd); | |
1119 else | |
1120 flist = g_list_prepend(flist, fd); | |
1121 } | 1134 } |
1122 } | 1135 } |
1123 } | 1136 } |
1124 g_free(filepath); | 1137 g_free(filepath); |
1125 } | 1138 } |
1126 } | 1139 } |
1127 | 1140 |
1128 closedir(dp); | 1141 closedir(dp); |
1129 | 1142 |
1130 g_free(pathl); | 1143 g_free(pathl); |
1144 | |
1145 flist = filelist_filter_out_sidecars(flist); | |
1131 | 1146 |
1132 if (dirs) *dirs = dlist; | 1147 if (dirs) *dirs = dlist; |
1133 if (files) *files = flist; | 1148 if (files) *files = flist; |
1134 | 1149 |
1135 return TRUE; | 1150 return TRUE; |