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
This commit is contained in:
Marcus Meissner
2009-02-28 09:44:16 +00:00
parent 74ba80a065
commit 225bc0cfbb

View File

@@ -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;