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

int gp_filesystem_list_folders ( CameraFilesystem fs,
const char *  folder,
CameraList list,
GPContext context 
)

List all subfolders within a filesystem folder.

Parameters:
fs a CameraFilesystem
folder a folder
list a CameraList where subfolders should be listed
context a GPContext
Generates a list of subfolders of the supplied folder either using cached values (if there are any) or the folder_list_func if it has been supplied previously. If not, it is assumed that only a root folder exists (which is the case for many cameras).

Returns:
a gphoto2 error code.

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

References CHECK_NULL, _CameraFilesystem::folder_list_func, GP_ERROR_DIRECTORY_NOT_FOUND, gp_list_append(), gp_list_count(), gp_list_get_name(), gp_list_reset(), gp_log(), GP_LOG_DEBUG, GP_OK, _CameraFilesystem::list_data, and _CameraFilesystem::rootfolder.

Referenced by gp_camera_folder_list_folders().

{
      int y, count;
      const char *name;
      CameraFilesystemFolder  *f, *new;

      gp_log (GP_LOG_DEBUG, "gphoto2-filesystem", "Listing folders in %s", folder);

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

      gp_list_reset (list);

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


      /* If the folder is dirty, query the contents. */
      if (f->folders_dirty && fs->folder_list_func) {
            gp_log (GP_LOG_DEBUG, "gphoto2-filesystem", "... is dirty, getting from camera");
            CR (fs->folder_list_func (fs, folder, list,
                                fs->list_data, context));
            CR (delete_all_folders (fs, folder, context));

            CR (count = gp_list_count (list));
            for (y = 0; y < count; y++) {
                  CR (gp_list_get_name (list, y, &name));
                  CR (append_folder_one (f, name, NULL));
            }
            /* FIXME: why not just return (GP_OK); ? the list should be fine */
            gp_list_reset (list);
      }

      new = f->folders;
      while (new) {
            CR (gp_list_append (list, new->name, NULL));
            new = new->next;
      }
      /* The folder is clean now */
      f->folders_dirty = 0;
      gp_log (GP_LOG_DEBUG, "gphoto2-filesystem", "Folder %s contains %i "
            "subfolders.", folder, gp_list_count (list));
      return (GP_OK);
}


Generated by  Doxygen 1.6.0   Back to index