X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fupdate_image.c;h=6779a127b7997aa0b162ecfc6ee54cbdeb37e701;hp=df0ab99049721bc62d4fa327da33e18d00c1d7b7;hb=cc7b6ee47d4037ae8fa11b4c2d5154091d543704;hpb=ced16a28e197645a40fa04a54793d117a04526d7 diff --git a/src/update_image.c b/src/update_image.c index df0ab990..6779a127 100644 --- a/src/update_image.c +++ b/src/update_image.c @@ -401,8 +401,10 @@ journaled_change_name(struct update_command_journal *j, prim.name.subject = dentry; prim.name.old_name = dentry->file_name; ret = record_update_primitive(j, prim); - if (ret) + if (ret) { + FREE(new_name); return ret; + } dentry->file_name = new_name; dentry->file_name_nbytes = new_name_nbytes; @@ -917,7 +919,7 @@ free_dentry_full_path(struct wim_dentry *dentry, void *_ignore) /* Is @d1 a (possibly nonproper) ancestor of @d2? */ static bool -is_ancestor(struct wim_dentry *d1, struct wim_dentry *d2) +is_ancestor(const struct wim_dentry *d1, const struct wim_dentry *d2) { for (;;) { if (d2 == d1) @@ -1106,7 +1108,7 @@ execute_update_commands(WIMStruct *wim, if (ret) goto out; - ret = init_sd_set(sd_set, wim_security_data(wim)); + ret = init_sd_set(sd_set, wim_get_current_security_data(wim)); if (ret) goto out_destroy_inode_table; @@ -1266,7 +1268,7 @@ check_add_command(struct wimlib_update_command *cmd, if (!is_entire_image) { if (add_flags & WIMLIB_ADD_FLAG_NTFS) { - ERROR("Cannot add directly from a NTFS volume " + ERROR("Cannot add directly from an NTFS volume " "when not capturing a full image!"); return WIMLIB_ERR_INVALID_PARAM; } @@ -1471,3 +1473,52 @@ out_free_cmds_copy: out: return ret; } + +static int +update1(WIMStruct *wim, int image, const struct wimlib_update_command *cmd) +{ + return wimlib_update_image(wim, image, cmd, 1, 0, NULL); +} + +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 update1(wim, image, &cmd); +} + +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 update1(wim, image, &cmd); +} + +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 update1(wim, image, &cmd); +}