Logo Search packages:      
Sourcecode: libgphoto2 version File versions

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

Get the list of files in a folder.

fs a CameraFilesystem
folder a folder of which a file list should be generated
list a CameraList where to put the list of files into
context a GPContext
Lists the files in folder using either cached values or (if there aren't any) the file_list_func which (hopefully) has been previously supplied.

a gphoto2 error code.

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

References CHECK_NULL, _CameraFilesystem::file_list_func, _CameraFilesystem::folder, gp_filesystem_append(), gp_list_append(), gp_list_count(), gp_list_get_name(), gp_list_reset(), gp_log(), GP_LOG_DEBUG, and _CameraFilesystem::list_data.

Referenced by gp_camera_folder_list_files(), gp_filesystem_number(), and gp_filesystem_remove_dir().

      int x, y, count;
      const char *name;

      gp_log (GP_LOG_DEBUG, "gphoto2-filesystem",
            "Listing files in '%s'...", folder);

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

      gp_list_reset (list);

      /* Search the folder */
      CR (x = gp_filesystem_folder_number (fs, folder, context));

      /* If the folder is dirty, delete the contents and query the camera */
      if (fs->folder[x].files_dirty && fs->file_list_func) {

            gp_log (GP_LOG_DEBUG, "gphoto2-filesystem",
                  "Querying folder %s...", folder);
            CR (delete_all_files (fs, x));
            CR (fs->file_list_func (fs, folder, list,
                              fs->list_data, context));

            CR (count = gp_list_count (list));
            for (y = 0; y < count; y++) {
                  CR (gp_list_get_name (list, y, &name));
                  gp_log (GP_LOG_DEBUG, "gphoto2-filesystem",
                               "Added '%s'", name);
                  CR (gp_filesystem_append (fs, folder, name, context));
            gp_list_reset (list);

      /* The folder is clean now */
      fs->folder[x].files_dirty = 0;

      for (y = 0; y < fs->folder[x].count; y++) {
            gp_log (GP_LOG_DEBUG, "filesys",
                  "Listed '%s'", fs->folder[x].file[y].name);
            CR (gp_list_append (list, fs->folder[x].file[y].name, NULL));

      return (GP_OK);

Generated by  Doxygen 1.6.0   Back to index