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.

Parameters:
fsa CameraFilesystem
folderthe folder where to look for file called filename
filenamethe file to look for
contexta GPContext

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

Returns:
a gphoto2 error code.

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

References GP_ERROR_DIRECTORY_NOT_FOUND, GP_ERROR_FILE_NOT_FOUND, gp_filesystem_list_files(), gp_filesystem_number(), gp_list_free(), and gp_list_new().

Referenced by gp_filesystem_number(), and gp_filesystem_set_info().

{
      CameraFilesystemFolder  *f;
      CameraFilesystemFile    *file;
      CameraList *list;
      int num;

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

      f = lookup_folder (fs, fs->rootfolder, folder, context);
      if (!f) return (GP_ERROR_DIRECTORY_NOT_FOUND);

      file = f->files;
      num = 0;
      while (file) {
            if (!strcmp (file->name, filename))
                  return num;
            num++;
            file = file->next;
      }

      /* Ok, we didn't find the file. Is the folder dirty? */
      if (!f->files_dirty) {
            gp_context_error (context, _("File '%s' could not be found "
                  "in folder '%s'."), filename, folder);
            return (GP_ERROR_FILE_NOT_FOUND);
      }
      /* The folder is dirty. List all files to make it clean */
      CR (gp_list_new(&list));
      CL (gp_filesystem_list_files (fs, folder, list, context), list);
      gp_list_free(list);
      return (gp_filesystem_number (fs, folder, filename, context));
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index