Exemplo n.º 1
0
/* API function documented in wimlib.h  */
WIMLIBAPI int
wimlib_add_image_multisource(WIMStruct *wim,
			     const struct wimlib_capture_source *sources,
			     size_t num_sources,
			     const tchar *name,
			     const tchar *config_file,
			     int add_flags)
{
	int ret;
	struct wimlib_update_command *add_cmds;

	/* Make sure no reserved fields are set.  */
	for (size_t i = 0; i < num_sources; i++)
		if (sources[i].reserved != 0)
			return WIMLIB_ERR_INVALID_PARAM;

	/* Add the new image (initially empty).  */
	ret = wimlib_add_empty_image(wim, name, NULL);
	if (ret)
		return ret;

	/* Translate the "capture sources" into generic update commands.  */
	ret = WIMLIB_ERR_NOMEM;
	add_cmds = capture_sources_to_add_cmds(sources, num_sources,
					       add_flags, config_file);
	if (!add_cmds)
		goto out_delete_image;

	/* Delegate the work to wimlib_update_image().  */
	ret = wimlib_update_image(wim, wim->hdr.image_count, add_cmds,
				  num_sources, 0);
	FREE(add_cmds);
	if (ret)
		goto out_delete_image;

	/* If requested, set this image as the WIM's bootable image.  */
	if (add_flags & WIMLIB_ADD_FLAG_BOOT)
		wim->hdr.boot_idx = wim->hdr.image_count;

	/* If requested, mark new image as WIMBoot-compatible.  */
	if (add_flags & WIMLIB_ADD_FLAG_WIMBOOT)
		wim_info_set_wimboot(wim->wim_info, wim->hdr.image_count, true);

	return 0;

out_delete_image:
	/* Unsuccessful; rollback the WIM to its original state.  */

	/* wimlib_update_image() is now all-or-nothing, so no dentries remain
	 * and there's no need to pass the lookup table here.  */
	put_image_metadata(wim->image_metadata[wim->hdr.image_count - 1], NULL);

	xml_delete_image(&wim->wim_info, wim->hdr.image_count);
	wim->hdr.image_count--;
	return ret;
}
Exemplo n.º 2
0
WIMLIBAPI int
wimlib_delete_path(WIMStruct *wim, int image,
		   const tchar *path, int delete_flags)
{
	struct wimlib_update_command cmd;

	cmd.op = WIMLIB_UPDATE_OP_DELETE;
	cmd.delete_.wim_path = (tchar *)path;
	cmd.delete_.delete_flags = delete_flags;

	return wimlib_update_image(wim, image, &cmd, 1, 0);
}
Exemplo n.º 3
0
WIMLIBAPI int
wimlib_rename_path(WIMStruct *wim, int image,
		   const tchar *source_path, const tchar *dest_path)
{
	struct wimlib_update_command cmd;

	cmd.op = WIMLIB_UPDATE_OP_RENAME;
	cmd.rename.wim_source_path = (tchar *)source_path;
	cmd.rename.wim_target_path = (tchar *)dest_path;
	cmd.rename.rename_flags = 0;

	return wimlib_update_image(wim, image, &cmd, 1, 0);
}
Exemplo n.º 4
0
WIMLIBAPI int
wimlib_add_tree(WIMStruct *wim, int image,
		const tchar *fs_source_path, const tchar *wim_target_path,
		int add_flags)
{
	struct wimlib_update_command cmd;

	cmd.op = WIMLIB_UPDATE_OP_ADD;
	cmd.add.fs_source_path = (tchar *)fs_source_path;
	cmd.add.wim_target_path = (tchar *)wim_target_path;
	cmd.add.add_flags = add_flags;
	cmd.add.config_file = NULL;

	return wimlib_update_image(wim, image, &cmd, 1, 0);
}