+ if (ret != 0) {
+ perror_inf("Failed to get image");
+ return ret;
+ }
+
+ ret = gp_camera_file_delete(camera, camera_file_path.folder, camera_file_path.name, context);
+ if (ret != 0) {
+ perror_inf("Failed to delete image from camera");
+ return ret;
+ }
+
+ gp_file_get_data_and_size(file, (const char **)&buf->base, &buf->size);
+ if (ret != 0) {
+ perror_inf("Failed to get data and size");
+ return ret;
+ }
+
+ return 0;
+}
+*/
+
+int pb_ph_capture_file(const char *fn)
+{
+ int ret, fd;
+ CameraFile *file;
+ CameraFilePath camera_file_path;
+
+ ret = gp_camera_capture(camera, GP_CAPTURE_IMAGE, &camera_file_path, context);
+ if (ret != GP_OK)
+ return ret;
+
+ fd = open(fn, O_CREAT | O_WRONLY, 0644);
+ if (fd == -1) {
+ ret = GP_ERROR;
+ perror("Failed to open/create file");
+ goto error_delete;
+ }
+
+ ret = gp_file_new_from_fd(&file, fd);
+ if (ret != GP_OK)
+ goto error_fd;
+
+ //
+ ret = gp_camera_file_get(camera, camera_file_path.folder,
+ camera_file_path.name, GP_FILE_TYPE_NORMAL, file, context);