static int get_sony_file_id(Camera *camera, const char *folder, const char *filename, GPContext *context, int *sony_id, SonyFileType *sony_type) { int num = gp_filesystem_number(camera->fs, folder, filename, context); if (num < 0) return (num); num++; if (sony_is_mpeg_file_name(filename)) { const char *name_found; int mpeg_num = 0; do { mpeg_num++; gp_filesystem_name(camera->fs, folder, num-mpeg_num, &name_found, context); } while (sony_is_mpeg_file_name(name_found) && (mpeg_num<=num)); mpeg_num--; *sony_type = SONY_FILE_MPEG; *sony_id = mpeg_num; } else { *sony_type = SONY_FILE_IMAGE; *sony_id = num; } return GP_OK; }
static int delete_file_func (CameraFilesystem *fs, const char *folder, const char *filename, void *data, GPContext *context) { Camera *camera = data; int n, c, flash_file_count; /* FIXME deleting a single file for flash/card cams should work */ /* Get the file number from the CameraFileSystem */ CHECK (n = gp_filesystem_number (camera->fs, folder, filename, context)); if (cam_has_flash(camera->pl) || cam_has_card(camera->pl) ) { CHECK (spca50x_flash_get_filecount (camera->pl, &flash_file_count)); } else { /* should not happen really */ return GP_ERROR; } if (n < flash_file_count) { return spca500_flash_delete_file (camera->pl, n); } CHECK (c = gp_filesystem_count (camera->fs, folder, context)); if (n + 1 != c) { const char *name; gp_filesystem_name (fs, "/", c - 1, &name, context); gp_context_error (context, _("Your camera only supports deleting the " "last file on the camera. In this case, this " "is file '%s'."), name); return (GP_ERROR); } CHECK (spca50x_sdram_delete_file (camera->pl, n)); return GP_OK; }
static int delete_file_func (CameraFilesystem *fs, const char *folder, const char *filename, void *data, GPContext *context) { Camera *camera = data; int n, c; /* Get the file number from the CameraFileSystem */ CHECK (n = gp_filesystem_number (camera->fs, folder, filename, context)); CHECK (c = gp_filesystem_count (camera->fs, folder, context)); if (n + 1 != c) { const char *name; gp_filesystem_name (fs, "/", c - 1, &name, context); gp_context_error (context, _("Your camera only supports deleting " "the last file on the camera. In this " "case, this is file '%s'."), name); return (GP_ERROR); } CHECK (gsmart300_delete_file (camera->pl, n)); return GP_OK; }