Logo Search packages:      
Sourcecode: libgphoto2 version File versions

int gp_file_adjust_name_for_mime_type ( CameraFile file  ) 

Parameters:
file a CameraFile
Returns:
a gphoto2 error code.

Definition at line 552 of file gphoto2-file.c.

References CHECK_NULL.

{
      int x;
      char *suffix;
      const char *table[] = {
            GP_MIME_RAW,  "raw",
            GP_MIME_JPEG, "jpg",
            GP_MIME_PNG,  "png",
            GP_MIME_PPM,  "ppm",
            GP_MIME_PGM,  "pgm",
            GP_MIME_PNM,  "pnm",
            GP_MIME_TIFF, "tif",
            GP_MIME_WAV,  "wav",
            GP_MIME_BMP,  "bmp",
            GP_MIME_AVI,  "avi",
            NULL};

      CHECK_NULL (file);

      gp_log (GP_LOG_DEBUG, "gphoto2-file", "Adjusting file name for "
            "mime type '%s'...", file->mime_type);
      for (x = 0; table[x]; x += 2)
                if (!strcmp (file->mime_type, table[x])) {

                  /* Search the current suffix and erase it */
#ifdef HAVE_STRCHR
                  suffix = strrchr (file->name, '.');
#else
                  suffix = rindex (file->name, '.');
#endif
                  if (suffix++)
                        *suffix = '\0';
                  strcat (file->name, table[x + 1]);
                  break;
            }
      gp_log (GP_LOG_DEBUG, "gphoto2-file", "Name adjusted to '%s'.",
            file->name);
      
      return (GP_OK);
}


Generated by  Doxygen 1.6.0   Back to index