From d9eb4a2e37ff4d294cab030eb40b39d7d3543113 Mon Sep 17 00:00:00 2001 From: Lutz Mueller Date: Tue, 5 Feb 2002 08:39:54 +0000 Subject: [PATCH] =?UTF-8?q?2002-02-05=20=20Lutz=20M=EF=BF=BDller=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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. git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@4075 67ed7778-7388-44ab-90cf-0a291f65f57c --- camlibs/sierra/ChangeLog | 7 +++++++ camlibs/sierra/library.c | 27 +++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) 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,