From 147ac5db9840bcca2c35f37b90289621063551ed Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Tue, 13 May 2014 12:45:45 -0500 Subject: [PATCH] Add wrappers around wimlib_update_image() * wimlib_add_tree() * wimlib_rename_path() * wimlib_delete_path() --- include/wimlib.h | 39 ++++++++++++++++++++++++++++++++++++ src/update_image.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) diff --git a/include/wimlib.h b/include/wimlib.h index 037f67d6..5b856315 100644 --- a/include/wimlib.h +++ b/include/wimlib.h @@ -2107,6 +2107,20 @@ wimlib_add_image_multisource(WIMStruct *wim, int add_flags, wimlib_progress_func_t progress_func); +/** + * @ingroup G_modifying_wims + * + * Add the file or directory tree at @p fs_source_path on the filesystem to the + * location @p wim_target_path within the specified @p image of the @p wim. + * + * This just builds an appropriate ::wimlib_add_command and passes it to + * wimlib_update_image(). + */ +extern int +wimlib_add_tree(WIMStruct *wim, int image, + const wimlib_tchar *fs_source_path, + const wimlib_tchar *wim_target_path, int add_flags); + /** * @ingroup G_creating_and_opening_wims * @@ -2173,6 +2187,18 @@ wimlib_create_new_wim(int ctype, WIMStruct **wim_ret); extern int wimlib_delete_image(WIMStruct *wim, int image); +/** + * @ingroup G_modifying_wims + * + * Delete the @p path from the specified @p image of the @p wim. + * + * This just builds an appropriate ::wimlib_delete_command and passes it to + * wimlib_update_image(). + */ +extern int +wimlib_delete_path(WIMStruct *wim, int image, + const wimlib_tchar *path, int delete_flags); + /** * @ingroup G_modifying_wims * @@ -3351,6 +3377,19 @@ wimlib_reference_template_image(WIMStruct *wim, int new_image, WIMStruct *template_wim, int template_image, int flags, wimlib_progress_func_t progress_func); +/** + * @ingroup G_modifying_wims + * + * Rename the @p source_path to the @p dest_path in the specified @p image of + * the @p wim. + * + * This just builds an appropriate ::wimlib_rename_command and passes it to + * wimlib_update_image(). + */ +extern int +wimlib_rename_path(WIMStruct *wim, int image, + const wimlib_tchar *source_path, const wimlib_tchar *dest_path); + /** * @ingroup G_wim_information * diff --git a/src/update_image.c b/src/update_image.c index a88ccd92..cda3797d 100644 --- a/src/update_image.c +++ b/src/update_image.c @@ -1471,3 +1471,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); +} -- 2.43.0