Add wrappers around wimlib_update_image()
authorEric Biggers <ebiggers3@gmail.com>
Tue, 13 May 2014 17:45:45 +0000 (12:45 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Tue, 13 May 2014 18:05:02 +0000 (13:05 -0500)
* wimlib_add_tree()
* wimlib_rename_path()
* wimlib_delete_path()

include/wimlib.h
src/update_image.c

index 037f67d..5b85631 100644 (file)
@@ -2108,6 +2108,20 @@ wimlib_add_image_multisource(WIMStruct *wim,
                             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
  *
  * Creates a ::WIMStruct for a new WIM file.
@@ -2176,6 +2190,18 @@ 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
+ *
  * Exports an image, or all the images, from a WIM file, into another WIM file.
  *
  * The destination image is made to share the same dentry tree and security data
@@ -3352,6 +3378,19 @@ wimlib_reference_template_image(WIMStruct *wim, int new_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
  *
  * Translates a string specifying the name or number of an image in the WIM into
index a88ccd9..cda3797 100644 (file)
@@ -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);
+}