From 225bc0cfbb8c45db7d76fde2630ef3a1ebfbb6fc Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Sat, 28 Feb 2009 09:44:16 +0000 Subject: [PATCH] handle easy case by just returning strdup(basename) git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@11833 67ed7778-7388-44ab-90cf-0a291f65f57c --- libgphoto2/gphoto2-file.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libgphoto2/gphoto2-file.c b/libgphoto2/gphoto2-file.c index fd0449304..89df3ea68 100644 --- a/libgphoto2/gphoto2-file.c +++ b/libgphoto2/gphoto2-file.c @@ -822,6 +822,14 @@ gp_file_get_name_by_type (CameraFile *file, const char *basename, CameraFileType CHECK_NULL (file && basename && newname); *newname = NULL; + /* the easy case, always map 1:1 */ + if (type == GP_FILE_TYPE_NORMAL) { + *newname = strdup (basename); + if (!*newname) + return GP_ERROR_NO_MEMORY; + return GP_OK; + } + for (i=0;mime_table[i];i+=2) { if (!strcmp (mime_table[i+1],file->mime_type)) { suffix = mime_table[i]; @@ -830,10 +838,6 @@ gp_file_get_name_by_type (CameraFile *file, const char *basename, CameraFileType } s = strrchr(basename,'.'); switch (type) { - 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;