Logo Search packages:      
Sourcecode: libgphoto2 version File versions

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 1339 of file gphoto2-filesys.c.

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

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;
            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);
      return (gp_filesystem_number (fs, folder, filename, context));

Generated by  Doxygen 1.6.0   Back to index