void ImageManager::remove_image(const string& filename, void *builtin_data, InterpolationType interpolation, ExtensionType extension) { size_t slot; for(int type = 0; type < IMAGE_DATA_NUM_TYPES; type++) { for(slot = 0; slot < images[type].size(); slot++) { if(images[type][slot] && image_equals(images[type][slot], filename, builtin_data, interpolation, extension)) { remove_image(type_index_to_flattened_slot(slot, (ImageDataType)type)); return; } } } }
static int remove_cmd(int argc, char *argv[]) { struct option opts[toc_entries_len + 2]; char outfile[FILENAME_MAX] = { 0 }; fip_toc_header_t toc_header; toc_entry_t *toc_entry; int fflag = 0; int i; if (argc < 2) usage(); i = fill_common_opts(opts, no_argument); add_opt(opts, i, "force", no_argument, 'f'); add_opt(opts, ++i, "out", required_argument, 'o'); add_opt(opts, ++i, NULL, 0, 0); while (1) { int c, opt_index; c = getopt_long(argc, argv, "fo:", opts, &opt_index); if (c == -1) break; switch (c) { case OPT_TOC_ENTRY: toc_entry = &toc_entries[opt_index]; toc_entry->action = DO_REMOVE; break; case 'f': fflag = 1; break; case 'o': snprintf(outfile, sizeof(outfile), "%s", optarg); break; default: usage(); } } argc -= optind; argv += optind; if (argc == 0) usage(); if (outfile[0] != '\0' && access(outfile, F_OK) == 0 && !fflag) log_errx("File %s already exists, use --force to overwrite it", outfile); if (outfile[0] == '\0') snprintf(outfile, sizeof(outfile), "%s", argv[0]); parse_fip(argv[0], &toc_header); for (toc_entry = toc_entries; toc_entry->cmdline_name != NULL; toc_entry++) { if (toc_entry->action != DO_REMOVE) continue; if (toc_entry->image != NULL) { if (verbose) log_dbgx("Removing %s.bin", toc_entry->cmdline_name); remove_image(toc_entry->image); } else { log_warnx("Requested image %s.bin is not in %s", toc_entry->cmdline_name, argv[0]); } } pack_images(outfile, toc_header.flags); free_images(); return 0; }