Logo Search packages:      
Sourcecode: libgphoto2 version File versions

int gp_filesystem_number ( CameraFilesystem fs,
const char *  folder,
const char *  filename,
GPContext context 

gp_filesystem_number: : a CameraFilesystem : the folder where to look for file called : the file to look for : a GPContext

Looks for a file called in the given . See gp_filesystem_name for exactly the opposite functionality.

Return value: a gphoto2 error code.

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

References _CameraFilesystem::folder, and gp_filesystem_list_files().

Referenced by gp_filesystem_delete_file(), gp_filesystem_get_info(), gp_filesystem_set_info(), and gp_filesystem_set_info_noop().

      CameraList *list;
        int x, y;

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

      CR (gp_list_new(&list));

      CL (x = gp_filesystem_folder_number (fs, folder, context), list);

      for (y = 0; y < fs->folder[x].count; y++)
            if (!strcmp (fs->folder[x].file[y].name, filename)) {
                  gp_list_free (list);
                  return (y);

      /* Ok, we didn't find the file. Is the folder dirty? */
      if (!fs->folder[x].files_dirty) {
            gp_context_error (context, _("File '%s' could not be found "
                  "in folder '%s'."), filename, folder);
            gp_list_free (list);
            return (GP_ERROR_FILE_NOT_FOUND);

      /* The folder is dirty. List all files to make it clean */
      CL (gp_filesystem_list_files (fs, folder, list, context), list);
        return (gp_filesystem_number (fs, folder, filename, context));

Generated by  Doxygen 1.6.0   Back to index