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

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

References CHECK_NULL, _CameraFilesystem::file_list_func, GP_ERROR_DIRECTORY_NOT_FOUND, gp_filesystem_append(), 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_files(), and gp_filesystem_number().

      int count, y;
      const char *name;
      CameraFilesystemFolder  *f;
      CameraFilesystemFile    *file;

      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 */
      f = lookup_folder (fs, fs->rootfolder, folder, context);
      if (!f) return (GP_ERROR_DIRECTORY_NOT_FOUND);

      /* If the folder is dirty, delete the contents and query the camera */
      if (f->files_dirty && fs->file_list_func) {
            gp_log (GP_LOG_DEBUG, "gphoto2-filesystem",
                  "Querying folder %s...", folder);
            CR (delete_all_files (fs, f));
            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 */
      f->files_dirty = 0;

      file = f->files;
      while (file) {
            gp_log (GP_LOG_DEBUG, "filesys",
                  "Listed '%s'", file->name);
            CR (gp_list_append (list, file->name, NULL));
            file = file->next;
      return (GP_OK);

Generated by  Doxygen 1.6.0   Back to index