comparison src/filedata.c @ 783:d6a7fb4b8e7c

replaced directory path with FileData* dir_fd
author nadvornik
date Tue, 03 Jun 2008 19:44:19 +0000
parents 44128da39e13
children 16b3a5c8aedc
comparison
equal deleted inserted replaced
782:3f7a0420c293 783:d6a7fb4b8e7c
614 } 614 }
615 g_list_free(flist); 615 g_list_free(flist);
616 return flist_filtered; 616 return flist_filtered;
617 } 617 }
618 618
619 static gint filelist_read_real(const gchar *path, GList **files, GList **dirs, gint follow_symlinks) 619 static gint filelist_read_real(FileData *dir_fd, GList **files, GList **dirs, gint follow_symlinks)
620 { 620 {
621 DIR *dp; 621 DIR *dp;
622 struct dirent *dir; 622 struct dirent *dir;
623 gchar *pathl; 623 gchar *pathl;
624 GList *dlist = NULL; 624 GList *dlist = NULL;
628 g_assert(files || dirs); 628 g_assert(files || dirs);
629 629
630 if (files) *files = NULL; 630 if (files) *files = NULL;
631 if (dirs) *dirs = NULL; 631 if (dirs) *dirs = NULL;
632 632
633 pathl = path_from_utf8(path); 633 pathl = path_from_utf8(dir_fd->path);
634 if (!pathl) return FALSE; 634 if (!pathl) return FALSE;
635 635
636 dp = opendir(pathl); 636 dp = opendir(pathl);
637 if (dp == NULL) 637 if (dp == NULL)
638 { 638 {
688 if (files) *files = filelist_filter_out_sidecars(flist); 688 if (files) *files = filelist_filter_out_sidecars(flist);
689 689
690 return TRUE; 690 return TRUE;
691 } 691 }
692 692
693 gint filelist_read(const gchar *path, GList **files, GList **dirs) 693 gint filelist_read(FileData *dir_fd, GList **files, GList **dirs)
694 { 694 {
695 return filelist_read_real(path, files, dirs, TRUE); 695 return filelist_read_real(dir_fd, files, dirs, TRUE);
696 } 696 }
697 697
698 gint filelist_read_lstat(const gchar *path, GList **files, GList **dirs) 698 gint filelist_read_lstat(FileData *dir_fd, GList **files, GList **dirs)
699 { 699 {
700 return filelist_read_real(path, files, dirs, FALSE); 700 return filelist_read_real(dir_fd, files, dirs, FALSE);
701 } 701 }
702 702
703 void filelist_free(GList *list) 703 void filelist_free(GList *list)
704 { 704 {
705 GList *work; 705 GList *work;
826 826
827 work = dirs; 827 work = dirs;
828 while (work) 828 while (work)
829 { 829 {
830 FileData *fd = (FileData *)(work->data); 830 FileData *fd = (FileData *)(work->data);
831 const gchar *path = fd->path;
832 GList *f; 831 GList *f;
833 GList *d; 832 GList *d;
834 833
835 if (filelist_read(path, &f, &d)) 834 if (filelist_read(fd, &f, &d))
836 { 835 {
837 f = filelist_filter(f, FALSE); 836 f = filelist_filter(f, FALSE);
838 f = filelist_sort_path(f); 837 f = filelist_sort_path(f);
839 *list = g_list_concat(*list, f); 838 *list = g_list_concat(*list, f);
840 839
846 845
847 work = work->next; 846 work = work->next;
848 } 847 }
849 } 848 }
850 849
851 GList *filelist_recursive(const gchar *path) 850 GList *filelist_recursive(FileData *dir_fd)
852 { 851 {
853 GList *list; 852 GList *list;
854 GList *d; 853 GList *d;
855 854
856 if (!filelist_read(path, &list, &d)) return NULL; 855 if (!filelist_read(dir_fd, &list, &d)) return NULL;
857 list = filelist_filter(list, FALSE); 856 list = filelist_filter(list, FALSE);
858 list = filelist_sort_path(list); 857 list = filelist_sort_path(list);
859 858
860 d = filelist_filter(d, TRUE); 859 d = filelist_filter(d, TRUE);
861 d = filelist_sort_path(d); 860 d = filelist_sort_path(d);