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

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

gp_filesystem_list_files: : a CameraFilesystem : a folder of which a file list should be generated : a CameraList where to put the list of files into : a GPContext

Lists the files in using either cached values or (if there aren't any) the file_list_func which (hopefully) has been previously supplied.

Return value: a gphoto2 error code.

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

References _CameraFilesystem::file_list_func, _CameraFilesystem::folder, gp_filesystem_append(), and _CameraFilesystem::list_data.

Referenced by gp_camera_folder_list_files(), and gp_filesystem_number().

{
      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