static void node_deletedirectory(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, "path");
	if (!attr_node)
	{
		state->m_failed = 1;
		error_missingattribute("path");
		return;
	}

	err = imgtool_partition_delete_directory(state->m_partition, attr_node->value);
	if (err)
	{
		state->m_failed = 1;
		report_imgtoolerr(err);
		return;
	}
}
Exemple #2
0
static int cmd_rmdir(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_directory(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;
}