diff options
author | Marcus Meissner <marcus@jet.franken.de> | 2009-02-18 20:22:59 +0000 |
---|---|---|
committer | Marcus Meissner <marcus@jet.franken.de> | 2009-02-18 20:22:59 +0000 |
commit | 6eb0aa04d29a2d942eb57ff17c2e44743aeaf6e0 (patch) | |
tree | baf57ba114e6e9eb91bc7fb8cb1b39c9238681aa /libgphoto2/gphoto2-file.c | |
parent | 406a9f37e25ec8b1cd4b94a75021f5778c5bc163 (diff) | |
download | libgphoto2-6eb0aa04d29a2d942eb57ff17c2e44743aeaf6e0.tar.gz |
redid basename converter
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@11823 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'libgphoto2/gphoto2-file.c')
-rw-r--r-- | libgphoto2/gphoto2-file.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/libgphoto2/gphoto2-file.c b/libgphoto2/gphoto2-file.c index ae59b4a32..c4f18dd5a 100644 --- a/libgphoto2/gphoto2-file.c +++ b/libgphoto2/gphoto2-file.c @@ -822,8 +822,18 @@ gp_file_get_name_by_type (CameraFile *file, const char *basename, CameraFileType CHECK_NULL (file && basename && newname); *newname = NULL; + for (i=0;mime_table[i];i+=2) { + if (!strcmp (mime_table[i+1],file->mime_type)) { + suffix = mime_table[i]; + break; + } + } + s = strrchr(basename,'.'); switch (type) { - case GP_FILE_TYPE_NORMAL: prefix = ""; break; + case GP_FILE_TYPE_NORMAL: + prefix = ""; + if (s) suffix = s+1; /* use original suffix */ + break; case GP_FILE_TYPE_RAW: prefix = "raw_";break; case GP_FILE_TYPE_EXIF: prefix = "exif_";break; case GP_FILE_TYPE_PREVIEW: prefix = "thumb_";break; @@ -831,13 +841,6 @@ gp_file_get_name_by_type (CameraFile *file, const char *basename, CameraFileType case GP_FILE_TYPE_AUDIO: prefix = "audio_";break; default: prefix = ""; break; } - for (i=0;mime_table[i];i+=2) { - if (!strcmp (mime_table[i+1],file->mime_type)) { - suffix = mime_table[i]; - break; - } - } - s = strrchr(basename,'.'); if (s) { if (!suffix) suffix = s+1; @@ -845,8 +848,8 @@ gp_file_get_name_by_type (CameraFile *file, const char *basename, CameraFileType if (!new) return GP_ERROR_NO_MEMORY; strcpy (new, prefix); - memcpy (new+strlen(new), basename, s-basename+1); - strcat(new+strlen(new)+(s-basename+1),suffix); + memcpy (new+strlen(new), basename, (s-basename)+1); + strcat (new, suffix); } else { /* no dot in basename? */ if (!suffix) suffix = ""; new = malloc (strlen(prefix) + strlen(basename) + 1 + strlen (suffix) + 1); |