Logo Search packages:      
Sourcecode: libgphoto2 version File versions  Download package

int gp_camera_file_get_info ( Camera camera,
const char *  folder,
const char *  file,
CameraFileInfo info,
GPContext context 
)

Retrieves information about a file.

Parameters:
camera a Camera
folder a folder
file the name of the file
info 
context a GPContext
Returns:
a gphoto2 error code

Definition at line 1173 of file gphoto2-camera.c.

References CHECK_NULL, _CameraFileInfoPreview::fields, _CameraFileInfoFile::fields, _CameraFileInfo::file, gp_camera_file_get(), GP_ERROR_NOT_SUPPORTED, gp_file_get_data_and_size(), gp_file_get_mime_type(), GP_FILE_INFO_NAME, GP_FILE_INFO_NONE, GP_FILE_INFO_SIZE, GP_FILE_INFO_TYPE, gp_file_new(), GP_FILE_TYPE_PREVIEW, gp_file_unref(), gp_filesystem_get_info(), gp_log(), GP_LOG_DEBUG, GP_OK, _CameraFileInfoFile::name, _CameraFileInfo::preview, _CameraFileInfoPreview::size, and _CameraFileInfoPreview::type.

{
      int result = GP_OK;
      const char *mime_type;
      const char *data;
      /* long int size; */
      CameraFile *cfile;

      gp_log (GP_LOG_DEBUG, "gphoto2-camera", "Getting file info for '%s' "
            "in '%s'...", file, folder);

      CHECK_NULL (camera && folder && file && info);
      CHECK_INIT (camera, context);

      memset (info, 0, sizeof (CameraFileInfo));

      /* Check first if the camera driver supports the filesystem */
      CHECK_OPEN (camera, context);
      result = gp_filesystem_get_info (camera->fs, folder, file, info,
                               context);
      CHECK_CLOSE (camera, context);
      if (result != GP_ERROR_NOT_SUPPORTED) {
            CAMERA_UNUSED (camera, context);
            return (result);
      }

      /*
       * The CameraFilesystem doesn't support file info. We simply get
       * the preview and the file and look for ourselves...
       */

      /* It takes too long to get the file */
      info->file.fields = GP_FILE_INFO_NONE;

      /* Get the preview */
      info->preview.fields = GP_FILE_INFO_NONE;
      CRS (camera, gp_file_new (&cfile), context);
      if (gp_camera_file_get (camera, folder, file, GP_FILE_TYPE_PREVIEW,
                                    cfile, context) == GP_OK) {
            unsigned long size;
            info->preview.fields |= GP_FILE_INFO_SIZE | GP_FILE_INFO_TYPE;
            gp_file_get_data_and_size (cfile, &data, &size);
            info->preview.size = size;
            gp_file_get_mime_type (cfile, &mime_type);
            strncpy (info->preview.type, mime_type,
                   sizeof (info->preview.type));
      }
      gp_file_unref (cfile);

      /* We don't trust the camera libraries */
      info->file.fields |= GP_FILE_INFO_NAME;
      strncpy (info->file.name, file, sizeof (info->file.name));
      info->preview.fields &= ~GP_FILE_INFO_NAME;

      CAMERA_UNUSED (camera, context);
      return (GP_OK);
}


Generated by  Doxygen 1.6.0   Back to index