static void node_deletefile(struct imgtooltest_state *state, xml_data_node *node) { imgtoolerr_t err; xml_attribute_node *attr_node; if (!state->m_partition) { state->m_failed = 1; report_message(MSG_FAILURE, "Partition not loaded"); return; } attr_node = xml_get_attribute(node, "name"); if (!attr_node) { state->m_failed = 1; error_missingattribute("name"); return; } err = imgtool_partition_delete_file(state->m_partition, attr_node->value); if (err) { state->m_failed = 1; report_imgtoolerr(err); return; } }
static int cmd_del(const struct command *c, int argc, char *argv[]) { imgtoolerr_t err; imgtool_image *image = NULL; imgtool_partition *partition = NULL; int partition_index = 0; err = imgtool_image_open_byname(argv[0], argv[1], OSD_FOPEN_RW, &image); if (err) goto done; err = imgtool_partition_open(image, partition_index, &partition); if (err) goto done; err = imgtool_partition_delete_file(partition, argv[2]); if (err) goto done; done: if (partition) imgtool_partition_close(partition); if (image) imgtool_image_close(image); if (err) reporterror(err, c, argv[0], argv[1], argv[2], NULL, NULL); return err ? -1 : 0; }