Mercurial > geeqie
comparison src/filelist.c @ 442:4b2d7f9af171
Big whitespaces cleanup:
- drop whitespaces at end of lines
- convert eight spaces to tab at start of lines
- drop spurious spaces mixed with tabs
- remove empty lines at end of files
author | zas_ |
---|---|
date | Sun, 20 Apr 2008 13:04:57 +0000 |
parents | 10efd67e5d3c |
children | 48c8e49b571c |
comparison
equal
deleted
inserted
replaced
441:08eb7137cd94 | 442:4b2d7f9af171 |
---|---|
51 fe->key = g_strdup(key); | 51 fe->key = g_strdup(key); |
52 fe->description = g_strdup(description); | 52 fe->description = g_strdup(description); |
53 fe->extensions = g_strdup(extensions); | 53 fe->extensions = g_strdup(extensions); |
54 fe->enabled = enabled; | 54 fe->enabled = enabled; |
55 fe->file_class = file_class; | 55 fe->file_class = file_class; |
56 | 56 |
57 return fe; | 57 return fe; |
58 } | 58 } |
59 | 59 |
60 static void filter_entry_free(FilterEntry *fe) | 60 static void filter_entry_free(FilterEntry *fe) |
61 { | 61 { |
172 gchar *name; | 172 gchar *name; |
173 gchar *desc; | 173 gchar *desc; |
174 gchar **extensions; | 174 gchar **extensions; |
175 GString *filter = NULL; | 175 GString *filter = NULL; |
176 gint i; | 176 gint i; |
177 | 177 |
178 format = work->data; | 178 format = work->data; |
179 work = work->next; | 179 work = work->next; |
180 | 180 |
181 name = gdk_pixbuf_format_get_name(format); | 181 name = gdk_pixbuf_format_get_name(format); |
182 desc = gdk_pixbuf_format_get_description(format); | 182 desc = gdk_pixbuf_format_get_description(format); |
219 filter_add_if_missing("xpm", "X pixmap", ".xpm", FORMAT_CLASS_IMAGE, FALSE); | 219 filter_add_if_missing("xpm", "X pixmap", ".xpm", FORMAT_CLASS_IMAGE, FALSE); |
220 filter_add_if_missing("bmp", "Bitmap", ".bmp", FORMAT_CLASS_IMAGE, FALSE); | 220 filter_add_if_missing("bmp", "Bitmap", ".bmp", FORMAT_CLASS_IMAGE, FALSE); |
221 filter_add_if_missing("ico", "Icon file", ".ico;.cur", FORMAT_CLASS_IMAGE, FALSE); | 221 filter_add_if_missing("ico", "Icon file", ".ico;.cur", FORMAT_CLASS_IMAGE, FALSE); |
222 filter_add_if_missing("ras", "Raster", ".ras", FORMAT_CLASS_IMAGE, FALSE); | 222 filter_add_if_missing("ras", "Raster", ".ras", FORMAT_CLASS_IMAGE, FALSE); |
223 filter_add_if_missing("svg", "Scalable Vector Graphics", ".svg", FORMAT_CLASS_IMAGE, FALSE); | 223 filter_add_if_missing("svg", "Scalable Vector Graphics", ".svg", FORMAT_CLASS_IMAGE, FALSE); |
224 | 224 |
225 /* non-image files that might be desirable to show */ | 225 /* non-image files that might be desirable to show */ |
226 filter_add_if_missing("xmp", "XMP sidecar", ".xmp", FORMAT_CLASS_META, TRUE); | 226 filter_add_if_missing("xmp", "XMP sidecar", ".xmp", FORMAT_CLASS_META, TRUE); |
227 | 227 |
228 /* These are the raw camera formats with embedded jpeg/exif. | 228 /* These are the raw camera formats with embedded jpeg/exif. |
229 * (see format_raw.c and/or exiv2.cc) | 229 * (see format_raw.c and/or exiv2.cc) |
297 { | 297 { |
298 GList *ext; | 298 GList *ext; |
299 | 299 |
300 ext = filter_to_list(fe->extensions); | 300 ext = filter_to_list(fe->extensions); |
301 if (ext) extension_list = g_list_concat(extension_list, ext); | 301 if (ext) extension_list = g_list_concat(extension_list, ext); |
302 | 302 |
303 if (fe->file_class >= 0 && fe->file_class < FILE_FORMAT_CLASSES) | 303 if (fe->file_class >= 0 && fe->file_class < FILE_FORMAT_CLASSES) |
304 { | 304 { |
305 ext = filter_to_list(fe->extensions); | 305 ext = filter_to_list(fe->extensions); |
306 if (ext) file_class_extension_list[fe->file_class] = g_list_concat(file_class_extension_list[fe->file_class], ext); | 306 if (ext) file_class_extension_list[fe->file_class] = g_list_concat(file_class_extension_list[fe->file_class], ext); |
307 } | 307 } |
372 work = filter_list; | 372 work = filter_list; |
373 while (work) | 373 while (work) |
374 { | 374 { |
375 FilterEntry *fe = work->data; | 375 FilterEntry *fe = work->data; |
376 work = work->next; | 376 work = work->next; |
377 | 377 |
378 gchar *extensions = escquote_value(fe->extensions); | 378 gchar *extensions = escquote_value(fe->extensions); |
379 gchar *description = escquote_value(fe->description); | 379 gchar *description = escquote_value(fe->description); |
380 | 380 |
381 secure_fprintf(ssi, "file_filter.ext: \"%s%s\" %s %s %d\n", | 381 secure_fprintf(ssi, "file_filter.ext: \"%s%s\" %s %s %d\n", |
382 (fe->enabled) ? "" : "#", | 382 (fe->enabled) ? "" : "#", |
400 key = quoted_value(text, &p); | 400 key = quoted_value(text, &p); |
401 if (!key) return; | 401 if (!key) return; |
402 | 402 |
403 ext = quoted_value(p, &p); | 403 ext = quoted_value(p, &p); |
404 desc = quoted_value(p, &p); | 404 desc = quoted_value(p, &p); |
405 | 405 |
406 file_class = strtol(p, NULL, 10); | 406 file_class = strtol(p, NULL, 10); |
407 | 407 |
408 if (file_class < 0 || file_class >= FILE_FORMAT_CLASSES) file_class = FORMAT_CLASS_UNKNOWN; | 408 if (file_class < 0 || file_class >= FILE_FORMAT_CLASSES) file_class = FORMAT_CLASS_UNKNOWN; |
409 | 409 |
410 if (key && key[0] == '#') | 410 if (key && key[0] == '#') |
411 { | 411 { |
412 gchar *tmp; | 412 gchar *tmp; |
482 work = work->next; | 482 work = work->next; |
483 g_free(ext); | 483 g_free(ext); |
484 } | 484 } |
485 g_list_free(sidecar_ext_list); | 485 g_list_free(sidecar_ext_list); |
486 sidecar_ext_list = NULL; | 486 sidecar_ext_list = NULL; |
487 | 487 |
488 if (quoted) | 488 if (quoted) |
489 value = quoted_value(text, NULL); | 489 value = quoted_value(text, NULL); |
490 else | 490 else |
491 value = g_strdup(text); | 491 value = g_strdup(text); |
492 | 492 |
493 if (value == NULL) return; | 493 if (value == NULL) return; |
494 | 494 |
495 sidecar_ext_list = filter_to_list(value); | 495 sidecar_ext_list = filter_to_list(value); |
496 | 496 |
497 g_free(value); | 497 g_free(value); |
498 } | 498 } |
499 | 499 |
500 void sidecar_ext_write(SecureSaveInfo *ssi) | 500 void sidecar_ext_write(SecureSaveInfo *ssi) |
501 { | 501 { |
708 fd->path = g_strdup(path); | 708 fd->path = g_strdup(path); |
709 fd->name = filename_from_path(fd->path); | 709 fd->name = filename_from_path(fd->path); |
710 | 710 |
711 if (strcmp(fd->name, "..") == 0) | 711 if (strcmp(fd->name, "..") == 0) |
712 { | 712 { |
713 gchar *dir = remove_level_from_path(path); | 713 gchar *dir = remove_level_from_path(path); |
714 g_free(fd->path); | 714 g_free(fd->path); |
715 fd->path = remove_level_from_path(dir); | 715 fd->path = remove_level_from_path(dir); |
716 g_free(dir); | 716 g_free(dir); |
717 fd->name = ".."; | 717 fd->name = ".."; |
718 fd->extension = fd->name + 2; | 718 fd->extension = fd->name + 2; |
719 return; | 719 return; |
720 } | 720 } |
721 else if (strcmp(fd->name, ".") == 0) | 721 else if (strcmp(fd->name, ".") == 0) |
722 { | 722 { |
723 g_free(fd->path); | 723 g_free(fd->path); |
724 fd->path = remove_level_from_path(path); | 724 fd->path = remove_level_from_path(path); |
726 fd->extension = fd->name + 1; | 726 fd->extension = fd->name + 1; |
727 return; | 727 return; |
728 } | 728 } |
729 | 729 |
730 fd->extension = extension_from_path(fd->path); | 730 fd->extension = extension_from_path(fd->path); |
731 if (fd->extension == NULL) | 731 if (fd->extension == NULL) |
732 fd->extension = fd->name + strlen(fd->name); | 732 fd->extension = fd->name + strlen(fd->name); |
733 } | 733 } |
734 | 734 |
735 static void file_data_check_changed_files(FileData *fd, struct stat *st) | 735 static void file_data_check_changed_files(FileData *fd, struct stat *st) |
736 { | 736 { |
752 | 752 |
753 if (!stat_utf8(sfd->path, &st)) | 753 if (!stat_utf8(sfd->path, &st)) |
754 { | 754 { |
755 file_data_disconnect_sidecar_file(fd, sfd); | 755 file_data_disconnect_sidecar_file(fd, sfd); |
756 } | 756 } |
757 | 757 |
758 file_data_check_changed_files(sfd, &st); | 758 file_data_check_changed_files(sfd, &st); |
759 work = work->next; | 759 work = work->next; |
760 } | 760 } |
761 } | 761 } |
762 | 762 |
765 static FileData *file_data_new(const gchar *path_utf8, struct stat *st, gboolean check_sidecars) | 765 static FileData *file_data_new(const gchar *path_utf8, struct stat *st, gboolean check_sidecars) |
766 { | 766 { |
767 FileData *fd; | 767 FileData *fd; |
768 | 768 |
769 if (debug) printf("file_data_new: '%s' %d\n", path_utf8, check_sidecars); | 769 if (debug) printf("file_data_new: '%s' %d\n", path_utf8, check_sidecars); |
770 | 770 |
771 if (!file_data_pool) | 771 if (!file_data_pool) |
772 file_data_pool = g_hash_table_new (g_str_hash, g_str_equal); | 772 file_data_pool = g_hash_table_new (g_str_hash, g_str_equal); |
773 | 773 |
774 fd = g_hash_table_lookup(file_data_pool, path_utf8); | 774 fd = g_hash_table_lookup(file_data_pool, path_utf8); |
775 if (fd) | 775 if (fd) |
776 { | 776 { |
777 file_data_check_changed_files(fd, st); | 777 file_data_check_changed_files(fd, st); |
778 if (debug) printf("file_data_pool hit: '%s'\n", fd->path); | 778 if (debug) printf("file_data_pool hit: '%s'\n", fd->path); |
779 return file_data_ref(fd); | 779 return file_data_ref(fd); |
780 } | 780 } |
781 | 781 |
782 fd = g_new0(FileData, 1); | 782 fd = g_new0(FileData, 1); |
783 | 783 |
784 file_data_set_path(fd, path_utf8); | 784 file_data_set_path(fd, path_utf8); |
785 | 785 |
786 fd->original_path = g_strdup(path_utf8); | 786 fd->original_path = g_strdup(path_utf8); |
787 fd->size = st->st_size; | 787 fd->size = st->st_size; |
788 fd->date = st->st_mtime; | 788 fd->date = st->st_mtime; |
789 fd->pixbuf = NULL; | 789 fd->pixbuf = NULL; |
790 fd->sidecar_files = NULL; | 790 fd->sidecar_files = NULL; |
791 fd->ref = 1; | 791 fd->ref = 1; |
792 fd->magick = 0x12345678; | 792 fd->magick = 0x12345678; |
793 | 793 |
794 g_hash_table_insert(file_data_pool, fd->original_path, fd); | 794 g_hash_table_insert(file_data_pool, fd->original_path, fd); |
795 | 795 |
796 if (check_sidecars && sidecar_file_priority(fd->extension)) | 796 if (check_sidecars && sidecar_file_priority(fd->extension)) |
797 file_data_check_sidecars(fd); | 797 file_data_check_sidecars(fd); |
798 return fd; | 798 return fd; |
799 } | 799 } |
800 | 800 |
801 static void file_data_check_sidecars(FileData *fd) | 801 static void file_data_check_sidecars(FileData *fd) |
802 { | 802 { |
803 int base_len = fd->extension - fd->path; | 803 int base_len = fd->extension - fd->path; |
804 GString *fname = g_string_new_len(fd->path, base_len); | 804 GString *fname = g_string_new_len(fd->path, base_len); |
805 FileData *parent_fd = NULL; | 805 FileData *parent_fd = NULL; |
806 GList *work = sidecar_ext_get_list(); | 806 GList *work = sidecar_ext_get_list(); |
807 while (work) | 807 while (work) |
808 { | 808 { |
809 /* check for possible sidecar files; | 809 /* check for possible sidecar files; |
810 the sidecar files created here are referenced only via fd->sidecar_files or fd->parent, | 810 the sidecar files created here are referenced only via fd->sidecar_files or fd->parent, |
811 they have fd->ref set to 0 and file_data unref must chack and free them all together | 811 they have fd->ref set to 0 and file_data unref must chack and free them all together |
812 (using fd->ref would cause loops and leaks) | 812 (using fd->ref would cause loops and leaks) |
813 */ | 813 */ |
814 | 814 |
815 FileData *new_fd; | 815 FileData *new_fd; |
816 | 816 |
817 gchar *ext = work->data; | 817 gchar *ext = work->data; |
818 work = work->next; | 818 work = work->next; |
819 | 819 |
820 if (strcmp(ext, fd->extension) == 0) | 820 if (strcmp(ext, fd->extension) == 0) |
821 { | 821 { |
822 new_fd = fd; /* processing the original file */ | 822 new_fd = fd; /* processing the original file */ |
823 } | 823 } |
824 else | 824 else |
825 { | 825 { |
826 struct stat nst; | 826 struct stat nst; |
827 g_string_truncate(fname, base_len); | 827 g_string_truncate(fname, base_len); |
828 g_string_append(fname, ext); | 828 g_string_append(fname, ext); |
829 | 829 |
830 if (!stat_utf8(fname->str, &nst)) | 830 if (!stat_utf8(fname->str, &nst)) |
831 continue; | 831 continue; |
832 | 832 |
833 new_fd = file_data_new(fname->str, &nst, FALSE); | 833 new_fd = file_data_new(fname->str, &nst, FALSE); |
834 new_fd->ref--; /* do not use ref here */ | 834 new_fd->ref--; /* do not use ref here */ |
835 } | 835 } |
836 | 836 |
837 if (!parent_fd) | 837 if (!parent_fd) |
838 parent_fd = new_fd; /* parent is the one with the highest prio, found first */ | 838 parent_fd = new_fd; /* parent is the one with the highest prio, found first */ |
839 else | 839 else |
840 file_data_merge_sidecar_files(parent_fd, new_fd); | 840 file_data_merge_sidecar_files(parent_fd, new_fd); |
841 } | 841 } |
875 | 875 |
876 FileData *file_data_merge_sidecar_files(FileData *target, FileData *source) | 876 FileData *file_data_merge_sidecar_files(FileData *target, FileData *source) |
877 { | 877 { |
878 GList *work; | 878 GList *work; |
879 file_data_add_sidecar_file(target, source); | 879 file_data_add_sidecar_file(target, source); |
880 | 880 |
881 work = source->sidecar_files; | 881 work = source->sidecar_files; |
882 while (work) | 882 while (work) |
883 { | 883 { |
884 FileData *sfd = work->data; | 884 FileData *sfd = work->data; |
885 file_data_add_sidecar_file(target, sfd); | 885 file_data_add_sidecar_file(target, sfd); |
887 } | 887 } |
888 | 888 |
889 g_list_free(source->sidecar_files); | 889 g_list_free(source->sidecar_files); |
890 source->sidecar_files = NULL; | 890 source->sidecar_files = NULL; |
891 | 891 |
892 target->sidecar_files = filelist_sort(target->sidecar_files, SORT_NAME, TRUE); | 892 target->sidecar_files = filelist_sort(target->sidecar_files, SORT_NAME, TRUE); |
893 return target; | 893 return target; |
894 } | 894 } |
895 | 895 |
896 | 896 |
897 | 897 |
907 | 907 |
908 static void file_data_free(FileData *fd) | 908 static void file_data_free(FileData *fd) |
909 { | 909 { |
910 g_assert(fd->magick == 0x12345678); | 910 g_assert(fd->magick == 0x12345678); |
911 g_assert(fd->ref == 0); | 911 g_assert(fd->ref == 0); |
912 | 912 |
913 g_hash_table_remove(file_data_pool, fd->original_path); | 913 g_hash_table_remove(file_data_pool, fd->original_path); |
914 | 914 |
915 g_free(fd->path); | 915 g_free(fd->path); |
916 g_free(fd->original_path); | 916 g_free(fd->original_path); |
917 if (fd->pixbuf) g_object_unref(fd->pixbuf); | 917 if (fd->pixbuf) g_object_unref(fd->pixbuf); |
918 | 918 |
919 | 919 |
920 g_assert(fd->sidecar_files == NULL); /* sidecar files must be freed before calling this */ | 920 g_assert(fd->sidecar_files == NULL); /* sidecar files must be freed before calling this */ |
921 | 921 |
922 file_data_change_info_free(NULL, fd); | 922 file_data_change_info_free(NULL, fd); |
923 g_free(fd); | 923 g_free(fd); |
924 } | 924 } |
925 | 925 |
926 void file_data_unref(FileData *fd) | 926 void file_data_unref(FileData *fd) |
927 { | 927 { |
928 if (fd == NULL) return; | 928 if (fd == NULL) return; |
929 g_assert(fd->magick == 0x12345678); | 929 g_assert(fd->magick == 0x12345678); |
930 | 930 |
931 fd->ref--; | 931 fd->ref--; |
932 if (debug) printf("file_data_unref (%d): '%s'\n", fd->ref, fd->path); | 932 if (debug) printf("file_data_unref (%d): '%s'\n", fd->ref, fd->path); |
933 | 933 |
934 if (fd->ref == 0) | 934 if (fd->ref == 0) |
935 { | 935 { |
936 FileData *parent = fd->parent ? fd->parent : fd; | 936 FileData *parent = fd->parent ? fd->parent : fd; |
937 | 937 |
938 GList *work; | 938 GList *work; |
939 | 939 |
940 if (parent->ref > 0) | 940 if (parent->ref > 0) |
941 return; | 941 return; |
942 | 942 |
943 work = parent->sidecar_files; | 943 work = parent->sidecar_files; |
944 while (work) | 944 while (work) |
945 { | 945 { |
946 FileData *sfd = work->data; | 946 FileData *sfd = work->data; |
947 if (sfd->ref > 0) | 947 if (sfd->ref > 0) |
948 return; | 948 return; |
949 work = work->next; | 949 work = work->next; |
950 } | 950 } |
951 | 951 |
952 /* none of parent/children is referenced, we can free everything */ | 952 /* none of parent/children is referenced, we can free everything */ |
953 | 953 |
954 if (debug) printf("file_data_unref: deleting '%s', parent '%s'\n", fd->path, parent->path); | 954 if (debug) printf("file_data_unref: deleting '%s', parent '%s'\n", fd->path, parent->path); |
955 | 955 |
956 work = parent->sidecar_files; | 956 work = parent->sidecar_files; |
957 while (work) | 957 while (work) |
958 { | 958 { |
959 FileData *sfd = work->data; | 959 FileData *sfd = work->data; |
960 file_data_free(sfd); | 960 file_data_free(sfd); |
961 work = work->next; | 961 work = work->next; |
962 } | 962 } |
963 | 963 |
964 g_list_free(parent->sidecar_files); | 964 g_list_free(parent->sidecar_files); |
965 parent->sidecar_files = NULL; | 965 parent->sidecar_files = NULL; |
966 | 966 |
967 file_data_free(parent); | 967 file_data_free(parent); |
968 | 968 |
969 } | 969 } |
970 } | 970 } |
971 | 971 |
972 FileData *file_data_disconnect_sidecar_file(FileData *target, FileData *sfd) | 972 FileData *file_data_disconnect_sidecar_file(FileData *target, FileData *sfd) |
973 { | 973 { |
991 size_t len1 = fd1->extension - fd1->name; | 991 size_t len1 = fd1->extension - fd1->name; |
992 size_t len2 = fd2->extension - fd2->name; | 992 size_t len2 = fd2->extension - fd2->name; |
993 | 993 |
994 if (len1 < len2) return -1; | 994 if (len1 < len2) return -1; |
995 if (len1 > len2) return 1; | 995 if (len1 > len2) return 1; |
996 | 996 |
997 return strncmp(fd1->name, fd2->name, len1); | 997 return strncmp(fd1->name, fd2->name, len1); |
998 } | 998 } |
999 | 999 |
1000 void file_data_do_change(FileData *fd) | 1000 void file_data_do_change(FileData *fd) |
1001 { | 1001 { |
1012 | 1012 |
1013 gboolean file_data_add_change_info(FileData *fd, FileDataChangeType type, const gchar *src, const gchar *dest) | 1013 gboolean file_data_add_change_info(FileData *fd, FileDataChangeType type, const gchar *src, const gchar *dest) |
1014 { | 1014 { |
1015 | 1015 |
1016 FileDataChangeInfo *fdci; | 1016 FileDataChangeInfo *fdci; |
1017 | 1017 |
1018 if (fd->change) return FALSE; | 1018 if (fd->change) return FALSE; |
1019 | 1019 |
1020 fdci = g_new0(FileDataChangeInfo, 1); | 1020 fdci = g_new0(FileDataChangeInfo, 1); |
1021 | 1021 |
1022 fdci->type = type; | 1022 fdci->type = type; |
1023 | 1023 |
1024 if (src) | 1024 if (src) |
1025 fdci->source = g_strdup(src); | 1025 fdci->source = g_strdup(src); |
1026 else | 1026 else |
1027 fdci->source = g_strdup(fd->path); | 1027 fdci->source = g_strdup(fd->path); |
1028 | 1028 |
1029 if (dest) | 1029 if (dest) |
1030 fdci->dest = g_strdup(dest); | 1030 fdci->dest = g_strdup(dest); |
1031 | 1031 |
1032 fd->change = fdci; | 1032 fd->change = fdci; |
1033 return TRUE; | 1033 return TRUE; |
1034 } | 1034 } |
1035 | 1035 |
1036 void file_data_change_info_free(FileDataChangeInfo *fdci, FileData *fd) | 1036 void file_data_change_info_free(FileDataChangeInfo *fdci, FileData *fd) |
1037 { | 1037 { |
1038 if (!fdci && fd) | 1038 if (!fdci && fd) |
1039 fdci = fd->change; | 1039 fdci = fd->change; |
1040 | 1040 |
1041 if (!fdci) | 1041 if (!fdci) |
1042 return; | 1042 return; |
1043 | 1043 |
1044 g_free(fdci->source); | 1044 g_free(fdci->source); |
1045 g_free(fdci->dest); | 1045 g_free(fdci->dest); |
1046 | 1046 |
1047 g_free(fdci); | 1047 g_free(fdci); |
1048 | 1048 |
1049 if (fd) | 1049 if (fd) |
1050 fd->change = NULL; | 1050 fd->change = NULL; |
1051 } | 1051 } |
1052 | 1052 |
1053 | 1053 |
1054 | 1054 |
1055 | 1055 |
1056 /* | 1056 /* |
1057 *----------------------------------------------------------------------------- | 1057 *----------------------------------------------------------------------------- |
1058 * sidecar file info struct | 1058 * sidecar file info struct |
1059 *----------------------------------------------------------------------------- | 1059 *----------------------------------------------------------------------------- |
1060 */ | 1060 */ |
1066 const char *extension = extension_from_path(path); | 1066 const char *extension = extension_from_path(path); |
1067 int i = 1; | 1067 int i = 1; |
1068 GList *work; | 1068 GList *work; |
1069 if (extension == NULL) | 1069 if (extension == NULL) |
1070 return 0; | 1070 return 0; |
1071 | 1071 |
1072 work = sidecar_ext_get_list(); | 1072 work = sidecar_ext_get_list(); |
1073 | 1073 |
1074 while (work) { | 1074 while (work) { |
1075 gchar *ext = work->data; | 1075 gchar *ext = work->data; |
1076 work = work->next; | 1076 work = work->next; |
1077 if (strcmp(extension, ext) == 0) return i; | 1077 if (strcmp(extension, ext) == 0) return i; |
1078 i++; | 1078 i++; |
1079 } | 1079 } |
1080 return 0; | 1080 return 0; |
1081 } | 1081 } |
1082 | 1082 |
1083 gchar *sidecar_file_data_list_to_string(FileData *fd) | 1083 gchar *sidecar_file_data_list_to_string(FileData *fd) |
1084 { | 1084 { |
1180 | 1180 |
1181 static GList *filelist_filter_out_sidecars(GList *flist) | 1181 static GList *filelist_filter_out_sidecars(GList *flist) |
1182 { | 1182 { |
1183 GList *work = flist; | 1183 GList *work = flist; |
1184 GList *flist_filtered = NULL; | 1184 GList *flist_filtered = NULL; |
1185 | 1185 |
1186 while (work) | 1186 while (work) |
1187 { | 1187 { |
1188 FileData *fd = work->data; | 1188 FileData *fd = work->data; |
1189 work = work->next; | 1189 work = work->next; |
1190 if (fd->parent) /* remove fd's that are children */ | 1190 if (fd->parent) /* remove fd's that are children */ |
1191 file_data_unref(fd); | 1191 file_data_unref(fd); |
1192 else | 1192 else |
1193 flist_filtered = g_list_prepend(flist_filtered, fd); | 1193 flist_filtered = g_list_prepend(flist_filtered, fd); |
1194 } | 1194 } |
1195 g_list_free(flist); | 1195 g_list_free(flist); |
1196 return flist_filtered; | 1196 return flist_filtered; |
1228 { | 1228 { |
1229 gchar *name = dir->d_name; | 1229 gchar *name = dir->d_name; |
1230 if (options->file_filter.show_hidden_files || !ishidden(name)) | 1230 if (options->file_filter.show_hidden_files || !ishidden(name)) |
1231 { | 1231 { |
1232 gchar *filepath = g_strconcat(pathl, "/", name, NULL); | 1232 gchar *filepath = g_strconcat(pathl, "/", name, NULL); |
1233 if ((follow_symlinks ? | 1233 if ((follow_symlinks ? |
1234 stat(filepath, &ent_sbuf) : | 1234 stat(filepath, &ent_sbuf) : |
1235 lstat(filepath, &ent_sbuf)) >= 0) | 1235 lstat(filepath, &ent_sbuf)) >= 0) |
1236 { | 1236 { |
1237 if (S_ISDIR(ent_sbuf.st_mode)) | 1237 if (S_ISDIR(ent_sbuf.st_mode)) |
1238 { | 1238 { |
1302 | 1302 |
1303 work = list; | 1303 work = list; |
1304 while (work) | 1304 while (work) |
1305 { | 1305 { |
1306 FileData *fd; | 1306 FileData *fd; |
1307 | 1307 |
1308 fd = work->data; | 1308 fd = work->data; |
1309 work = work->next; | 1309 work = work->next; |
1310 | 1310 |
1311 new_list = g_list_prepend(new_list, file_data_ref(fd)); | 1311 new_list = g_list_prepend(new_list, file_data_ref(fd)); |
1312 } | 1312 } |
1313 | 1313 |
1314 return g_list_reverse(new_list); | 1314 return g_list_reverse(new_list); |
1315 } | 1315 } |
1316 | 1316 |
1317 GList *filelist_from_path_list(GList *list) | 1317 GList *filelist_from_path_list(GList *list) |
1318 { | 1318 { |
1321 | 1321 |
1322 work = list; | 1322 work = list; |
1323 while (work) | 1323 while (work) |
1324 { | 1324 { |
1325 gchar *path; | 1325 gchar *path; |
1326 | 1326 |
1327 path = work->data; | 1327 path = work->data; |
1328 work = work->next; | 1328 work = work->next; |
1329 | 1329 |
1330 new_list = g_list_prepend(new_list, file_data_new_simple(path)); | 1330 new_list = g_list_prepend(new_list, file_data_new_simple(path)); |
1331 } | 1331 } |
1332 | 1332 |
1333 return g_list_reverse(new_list); | 1333 return g_list_reverse(new_list); |
1334 } | 1334 } |
1335 | 1335 |
1336 GList *filelist_to_path_list(GList *list) | 1336 GList *filelist_to_path_list(GList *list) |
1337 { | 1337 { |
1340 | 1340 |
1341 work = list; | 1341 work = list; |
1342 while (work) | 1342 while (work) |
1343 { | 1343 { |
1344 FileData *fd; | 1344 FileData *fd; |
1345 | 1345 |
1346 fd = work->data; | 1346 fd = work->data; |
1347 work = work->next; | 1347 work = work->next; |
1348 | 1348 |
1349 new_list = g_list_prepend(new_list, g_strdup(fd->path)); | 1349 new_list = g_list_prepend(new_list, g_strdup(fd->path)); |
1350 } | 1350 } |
1351 | 1351 |
1352 return g_list_reverse(new_list); | 1352 return g_list_reverse(new_list); |
1353 } | 1353 } |
1354 | 1354 |
1355 GList *filelist_filter(GList *list, gint is_dir_list) | 1355 GList *filelist_filter(GList *list, gint is_dir_list) |
1356 { | 1356 { |