diff --git a/camlibs/sierra/ChangeLog b/camlibs/sierra/ChangeLog index 7a32763a6..75bbc4073 100644 --- a/camlibs/sierra/ChangeLog +++ b/camlibs/sierra/ChangeLog @@ -1,3 +1,10 @@ +2002-02-05 Lutz Müller + + * library.c (sierra_list_files): For cameras that don't support + filenames, it is useless to try to get a filename for each + file. Just try on the first one. If this fails, come up with + dummy filenames for each file. + 2002-02-05 Lutz Müller * library.c (sierra_read_packet): Hopefully this fixes problems diff --git a/camlibs/sierra/library.c b/camlibs/sierra/library.c index b8fe81871..28f0e1925 100644 --- a/camlibs/sierra/library.c +++ b/camlibs/sierra/library.c @@ -144,14 +144,33 @@ int sierra_list_files (Camera *camera, const char *folder, CameraList *list, GPC /* Then, we count the files */ GP_DEBUG ("Counting files in '%s'...", folder); CHECK (sierra_get_int_register (camera, 10, &count, context)); - GP_DEBUG ("... done. Found %i files.", count); + GP_DEBUG ("... done. Found %i file(s).", count); + + /* No files? Then, we are done. */ + if (!count) + return (GP_OK); /* - * Finally, we get the filename of each file. Not that some cameras + * Get the filename of the first picture. Note that some cameras * that don't support filenames return 8 blanks instead of - * reporting an error. + * reporting an error. If this is indeed the case, just fill + * the list with dummy entries and return. */ - for (i = 0; i < count; i++) { + GP_DEBUG ("Getting filename of first file..."); + CHECK (sierra_set_int_register (camera, 4, 1, context)); + CHECK (sierra_get_string_register (camera, 79, 0, NULL, + filename, &len, context)); + if ((len <= 0) || !strcmp (filename, " ")) { + CHECK (gp_list_populate (list, "P101%04i.JPG", count)); + return (GP_OK); + } + + /* + * The camera supports filenames. Append the first one to the list + * and get the remaining ones. + */ + CHECK (gp_list_append (list, filename, NULL)); + for (i = 1; i < count; i++) { GP_DEBUG ("Getting filename of file %i...", i + 1); CHECK (sierra_set_int_register (camera, 4, i + 1, context)); CHECK (sierra_get_string_register (camera, 79, 0, NULL,