Logo Search packages:      
Sourcecode: libgphoto2 version File versions

int gp_filesystem_get_info ( CameraFilesystem fs,
const char *  folder,
const char *  filename,
CameraFileInfo info,
GPContext context 
)

Get information about the specified file.

Parameters:
fs a CameraFilesystem
folder the folder that contains the file
filename the filename
info pointer to CameraFileInfo that receives the information
context a GPContext
Returns:
a gphoto2 error code.

Definition at line 1855 of file gphoto2-filesys.c.

References CHECK_NULL, _CameraFilesystem::folder, _CameraFilesystem::get_info_func, GP_ERROR_NOT_SUPPORTED, GP_FILE_INFO_MTIME, gp_filesystem_number(), and _CameraFilesystem::info_data.

Referenced by gp_camera_file_get_info(), and gp_filesystem_set_file_noop().

{
      int x, y;
#ifdef HAVE_LIBEXIF
      time_t t;
#endif

      CHECK_NULL (fs && folder && filename && info);
      CC (context);
      CA (folder, context);

      GP_DEBUG ("Getting information about '%s' in '%s'...", filename,
              folder);

      if (!fs->get_info_func) {
            gp_context_error (context,
                  _("The filesystem doesn't support getting file "
                    "information"));
            return (GP_ERROR_NOT_SUPPORTED);
      }

      /* Search folder and file and get info if needed */
      CR (x = gp_filesystem_folder_number (fs, folder, context));
      CR (y = gp_filesystem_number (fs, folder, filename, context));
      if (fs->folder[x].file[y].info_dirty) {
            CR (fs->get_info_func (fs, folder, filename, 
                                    &fs->folder[x].file[y].info,
                                    fs->info_data, context));
            fs->folder[x].file[y].info_dirty = 0;
      }

      /*
       * If we didn't get GP_FILE_INFO_MTIME, we'll have a look if we
       * can get it from EXIF data.
       */
#ifdef HAVE_LIBEXIF
      if (!(fs->folder[x].file[y].info.file.fields & GP_FILE_INFO_MTIME)) {
            GP_DEBUG ("Did not get mtime. Trying EXIF information...");
            t = gp_filesystem_get_exif_mtime (fs, folder, filename);
            if (t) {
                  fs->folder[x].file[y].info.file.mtime = t;
                  fs->folder[x].file[y].info.file.fields |=
                                          GP_FILE_INFO_MTIME;
            }
      }
#endif

      memcpy (info, &fs->folder[x].file[y].info, sizeof (CameraFileInfo));

      return (GP_OK);
}


Generated by  Doxygen 1.6.0   Back to index