]> wimlib.net Git - wimlib/blobdiff - src/update_image.c
mount_image.c: add fallback definitions of RENAME_* constants
[wimlib] / src / update_image.c
index fb5356338b7e174dfbc578b16c671c236ff75724..c4a2d571e2e7d4febd98963d942ce683fc639d0e 100644 (file)
@@ -16,7 +16,7 @@
  * details.
  *
  * You should have received a copy of the GNU Lesser General Public License
- * along with this file; if not, see http://www.gnu.org/licenses/.
+ * along with this file; if not, see https://www.gnu.org/licenses/.
  */
 
 /*
@@ -64,6 +64,7 @@
 #include "wimlib/paths.h"
 #include "wimlib/progress.h"
 #include "wimlib/scan.h"
+#include "wimlib/test_support.h"
 #include "wimlib/xml_windows.h"
 
 /* Saved specification of a "primitive" update operation that was performed.  */
@@ -715,6 +716,8 @@ static const char wincfg[] =
 "/swapfile.sys\n"
 "/System Volume Information\n"
 "/RECYCLER\n"
+"/$RECYCLE.BIN\n"
+"/$Recycle.Bin\n"
 "/Windows/CSC\n";
 
 static const tchar *wimboot_cfgfile =
@@ -739,9 +742,12 @@ get_capture_config(const tchar *config_file, struct capture_config *config,
 
                size_t len = tstrlen(fs_source_path) +
                             tstrlen(wimboot_cfgfile);
-               tmp_config_file = MALLOC((len + 1) * sizeof(tchar));
                struct stat st;
 
+               tmp_config_file = MALLOC((len + 1) * sizeof(tchar));
+               if (!tmp_config_file)
+                       return WIMLIB_ERR_NOMEM;
+
                tsprintf(tmp_config_file, T("%"TS"%"TS),
                         fs_source_path, wimboot_cfgfile);
                if (!tstat(tmp_config_file, &st)) {
@@ -803,6 +809,11 @@ execute_add_command(struct update_command_journal *j,
                scan_tree = ntfs_3g_build_dentry_tree;
 #endif
 
+#ifdef ENABLE_TEST_SUPPORT
+       if (add_flags & WIMLIB_ADD_FLAG_GENERATE_TEST_DATA)
+               scan_tree = generate_dentry_tree;
+#endif
+
        ret = get_capture_config(config_file, &config,
                                 add_flags, fs_source_path);
        if (ret)
@@ -880,6 +891,7 @@ execute_add_command(struct update_command_journal *j,
 out_destroy_config:
        destroy_capture_config(&config);
 out:
+       FREE(params.cur_path);
        return ret;
 }
 
@@ -946,7 +958,7 @@ is_ancestor(const struct wim_dentry *d1, const struct wim_dentry *d2)
  */
 int
 rename_wim_path(WIMStruct *wim, const tchar *from, const tchar *to,
-               CASE_SENSITIVITY_TYPE case_type,
+               CASE_SENSITIVITY_TYPE case_type, bool noreplace,
                struct update_command_journal *j)
 {
        struct wim_dentry *src;
@@ -966,6 +978,9 @@ rename_wim_path(WIMStruct *wim, const tchar *from, const tchar *to,
        if (dst) {
                /* Destination file exists */
 
+               if (noreplace)
+                       return -EEXIST;
+
                if (src == dst) /* Same file */
                        return 0;
 
@@ -1033,7 +1048,7 @@ execute_rename_command(struct update_command_journal *j,
 
        ret = rename_wim_path(wim, rename_cmd->rename.wim_source_path,
                              rename_cmd->rename.wim_target_path,
-                             WIMLIB_CASE_PLATFORM_DEFAULT, j);
+                             WIMLIB_CASE_PLATFORM_DEFAULT, false, j);
        if (ret) {
                ret = -ret;
                errno = ret;
@@ -1206,6 +1221,9 @@ check_add_command(struct wimlib_update_command *cmd,
                          WIMLIB_ADD_FLAG_NO_REPLACE |
                          WIMLIB_ADD_FLAG_TEST_FILE_EXCLUSION |
                          WIMLIB_ADD_FLAG_SNAPSHOT |
+               #ifdef ENABLE_TEST_SUPPORT
+                         WIMLIB_ADD_FLAG_GENERATE_TEST_DATA |
+               #endif
                          WIMLIB_ADD_FLAG_FILE_PATHS_UNNEEDED))
                return WIMLIB_ERR_INVALID_PARAM;
 
@@ -1219,7 +1237,7 @@ check_add_command(struct wimlib_update_command *cmd,
        }
 #endif
 
-#ifdef __WIN32__
+#ifdef _WIN32
        /* Check for flags not supported on Windows.  */
        if (add_flags & WIMLIB_ADD_FLAG_UNIX_DATA) {
                ERROR("Capturing UNIX-specific data is not supported on Windows");