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

int gp_filesystem_delete_all ( CameraFilesystem fs,
const char *  folder,
GPContext context 
)

gp_filesystem_delete_all : a CameraFilesystem : the folder in which to delete all files : a GPContext

Deletes all files in the given from the . If the has not been supplied with a delete_all_func, it tries to delete the files one by one using the delete_file_func. If that function has not been supplied neither, an error is returned.

Return value: a gphoto2 error code.

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

References _CameraFilesystem::delete_all_func, _CameraFilesystem::folder, and _CameraFilesystem::folder_data.

Referenced by gp_camera_folder_delete_all().

{
      int x, r;

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

      /* Make sure this folder exists */
      CR (x = gp_filesystem_folder_number (fs, folder, context));

      if (!fs->delete_all_func)
            CR (gp_filesystem_delete_all_one_by_one (fs, folder, context))
      else {

            /*
             * Mark the folder dirty - it could be that an error
             * happens, and then we don't know which files have been
             * deleted and which not.
             */
            fs->folder[x].files_dirty = 1;

            /*
             * First try to use the delete_all function. If that fails,
             * fall back to deletion one-by-one.
             */
            r = fs->delete_all_func (fs, folder, fs->folder_data, context);
            if (r < 0) {
                  gp_log (GP_LOG_DEBUG, "gphoto2-filesystem",
                        "delete_all failed (%s). Falling back to "
                        "deletion one-by-one.",
                        gp_result_as_string (r));
                  CR (gp_filesystem_delete_all_one_by_one (fs, folder,
                                                 context));
            } else
                  CR (delete_all_files (fs, x));

            /*
             * No error happened. We can be sure that all files have been
             * deleted.
             */
            fs->folder[x].files_dirty = 0;
      }

      return (GP_OK);
}


Generated by  Doxygen 1.6.0   Back to index