From 2e73310ddc51cdb69920308e7ddb2a0afca9ed6f Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Fri, 5 Sep 2003 20:47:49 +0000 Subject: [PATCH] correctly determine audio file name git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@6723 67ed7778-7388-44ab-90cf-0a291f65f57c --- camlibs/canon/canon.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/camlibs/canon/canon.c b/camlibs/canon/canon.c index 77c6de765..8cd291ac7 100644 --- a/camlibs/canon/canon.c +++ b/camlibs/canon/canon.c @@ -251,17 +251,23 @@ filename_to_audio(const char *filename, const char *newext) __FILE__, __LINE__); return NULL; } - if (strlen(buf) > 3) { - buf[0] = 'S'; - buf[1] = 'N'; - buf[2] = 'D'; + if ((p = strrchr (buf, '_')) == NULL) { + GP_DEBUG ("filename_to_audio: No '.' found in filename '%s' " + "in %s line %i.", filename, __FILE__, __LINE__); + return NULL; + } + if ((p - buf) > 3) { + p -= 3; + p[0] = 'S'; + p[1] = 'N'; + p[2] = 'D'; } if ((p = strrchr (buf, '.')) == NULL) { GP_DEBUG ("filename_to_audio: No '.' found in filename '%s' " "in %s line %i.", filename, __FILE__, __LINE__); return NULL; } - if (((p - buf) < sizeof (buf) - 4) && strncpy (p, ".THM", 4)) { + if (((p - buf) < sizeof (buf) - 4) && strncpy (p, ".WAV", 4)) { GP_DEBUG ("filename_to_audio: New name for '%s' is '%s'", filename, buf); return buf; @@ -290,6 +296,9 @@ const char * canon_int_filename2audioname (Camera *camera, const char *filename) { /* FIXME: I want capabilities */ + /* FIXME: Do we really have to check the model here? Someone + * could just have inserted the CF card into another camera... + * */ switch (camera->pl->md->model) { case CANON_PS_S30: case CANON_PS_S40: