static int delete_file_func (CameraFilesystem *fs, const char *folder, const char *filename, void *data, GPContext *context) { Camera *camera = data; int r; char *path = get_path (camera, folder, filename); struct tf_packet reply; r = send_cmd_hdd_del(camera, path, context); free (path); if(r < 0) return r; r = get_tf_packet(camera, &reply, context); if(r < 0) return r; switch (get_u32(&reply.cmd)) { case SUCCESS: return GP_OK; break; case FAIL: gp_log (GP_LOG_ERROR, "topfield", "ERROR: Device reports %s\n", decode_error(&reply)); break; default: gp_log (GP_LOG_ERROR, "topfield", "ERROR: Unhandled packet\n"); break; } return GP_ERROR_IO; }
int do_hdd_del(int fd, char *path) { int r; r = send_cmd_hdd_del(fd, path); if(r < 0) { return -EPROTO; } r = get_tf_packet(fd, &reply); if(r < 0) { return -EPROTO; } switch (get_u32(&reply.cmd)) { case SUCCESS: return 0; break; case FAIL: fprintf(stderr, "ERROR: Device reports %s\n", decode_error(&reply)); break; default: fprintf(stderr, "ERROR: Unhandled packet\n"); } return -EPROTO; }