Implements the /MIR switch, which is mostly an alias of /S /E /PURGE
Signed-off-by: Florian Eder others.meder@gmail.com --- programs/robocopy/main.c | 16 +++++++++++++++- programs/robocopy/robocopy.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/programs/robocopy/main.c b/programs/robocopy/main.c index 0bb0e83783c..3036776339d 100644 --- a/programs/robocopy/main.c +++ b/programs/robocopy/main.c @@ -162,6 +162,16 @@ static void parse_arguments(int argc, WCHAR *argv[]) { options.purge_destination = TRUE; } + /* mirror - Mirror Source in Destination */ + else if (!wcsicmp(argv[i], L"/mir")) + { + options.copy_empty_subdirectories = TRUE; + options.copy_subdirectories = TRUE; + options.purge_destination = TRUE; + options.mirror = TRUE; + if (!options.user_limited_subdirectories_depth) + options.max_subdirectories_depth = 0; + } /* mov - Delete files (but not folders) after copying them */ else if (!wcsicmp(argv[i], L"/mov")) { @@ -363,7 +373,7 @@ static BOOL perform_copy(struct robocopy_statistics *statistics) if ((PathIsDirectoryEmptyW(current_absolute_path) && !options.copy_empty_subdirectories)) continue;
/* Create the directory path and then create the directory itself */ - if (!create_directory_path(target_path)) + if (!create_directory_path(target_path) || (!CreateDirectoryW(target_path, NULL) && GetLastError() != ERROR_ALREADY_EXISTS)) output_error(STRING_ERROR_WRITE_DIRECTORY, GetLastError(), strip_path_prefix(target_path)); else statistics->copied_directories++; } @@ -428,6 +438,10 @@ static WCHAR *get_option_string(void) if (options.files->size == 0) wcscat(temp_string, L"*.* ");
+ /* Mirror */ + if (options.mirror) + wcscat(temp_string, L"/MIR "); + /* Subdirectories */ if (options.copy_subdirectories) wcscat(temp_string, L"/S "); diff --git a/programs/robocopy/robocopy.h b/programs/robocopy/robocopy.h index 1417f8b0e1c..e6779248aa5 100644 --- a/programs/robocopy/robocopy.h +++ b/programs/robocopy/robocopy.h @@ -41,6 +41,7 @@ struct robocopy_options { BOOL copy_empty_subdirectories; BOOL purge_source_files; BOOL purge_destination; + BOOL mirror; };
struct robocopy_statistics {