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

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

Get the index of a file in specified folder.

fs a CameraFilesystem
folder the folder where to look for file called filename
filename the file to look for
context a GPContext
Looks for a file called filename in the given folder. See gp_filesystem_name for exactly the opposite functionality.

a gphoto2 error code.

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

References CHECK_NULL, _CameraFilesystem::folder, GP_ERROR_FILE_NOT_FOUND, gp_filesystem_list_files(), gp_filesystem_number(), gp_list_free(), and gp_list_new().

Referenced by gp_filesystem_delete_file(), gp_filesystem_delete_file_noop(), gp_filesystem_get_info(), gp_filesystem_number(), gp_filesystem_set_file_noop(), 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