Implements the /E switch, which sets whether empty subdirectories are copied or not
Signed-off-by: Florian Eder others.meder@gmail.com --- programs/robocopy/main.c | 11 +++++++++++ programs/robocopy/robocopy.h | 1 + 2 files changed, 12 insertions(+)
diff --git a/programs/robocopy/main.c b/programs/robocopy/main.c index 6ebb0e721c4..fe550134508 100644 --- a/programs/robocopy/main.c +++ b/programs/robocopy/main.c @@ -149,6 +149,14 @@ static void parse_arguments(int argc, WCHAR *argv[]) if (!options.user_limited_subdirectories_depth) options.max_subdirectories_depth = 0; } + /* e - Copy Subdirectories, including empty ones */ + else if (!wcsicmp(argv[i], L"/e")) + { + options.copy_subdirectories = TRUE; + options.copy_empty_subdirectories = TRUE; + if (!options.user_limited_subdirectories_depth) + options.max_subdirectories_depth = 0; + } /* lev - Limit depth of subdirectories */ else if (!wcsnicmp(argv[i], L"/lev:", 5)) { @@ -327,6 +335,9 @@ static BOOL perform_copy(void)
if (PathIsDirectoryW(current_absolute_path)) { + /* ignore empty directories if empty subdirectories are not copied */ + 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)) output_error(STRING_ERROR_WRITE_DIRECTORY, GetLastError(), strip_path_prefix(target_path)); diff --git a/programs/robocopy/robocopy.h b/programs/robocopy/robocopy.h index 4b322f8b6f9..57797c7df69 100644 --- a/programs/robocopy/robocopy.h +++ b/programs/robocopy/robocopy.h @@ -38,6 +38,7 @@ struct robocopy_options { UINT max_subdirectories_depth; BOOL user_limited_subdirectories_depth; BOOL copy_subdirectories; + BOOL copy_empty_subdirectories; };
/* Resource strings */