Implements the /S switch, which copies all subdirectories of a directory
Signed-off-by: Florian Eder others.meder@gmail.com --- However, /LEV has a higher priority than /S, so "/S /LEV:2" limits to depth 2 --- programs/robocopy/main.c | 10 +++++++++- programs/robocopy/robocopy.h | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/programs/robocopy/main.c b/programs/robocopy/main.c index 747c242e7de..6ebb0e721c4 100644 --- a/programs/robocopy/main.c +++ b/programs/robocopy/main.c @@ -142,14 +142,22 @@ static void parse_arguments(int argc, WCHAR *argv[]) for (i = 1; i < argc; i++) { if (is_valid_robocopy_flag(argv[i])) + /* s - Copy Subdirectories */ + if (!wcsicmp(argv[i], L"/s")) + { + options.copy_subdirectories = TRUE; + if (!options.user_limited_subdirectories_depth) + options.max_subdirectories_depth = 0; + } /* lev - Limit depth of subdirectories */ - if (!wcsnicmp(argv[i], L"/lev:", 5)) + else if (!wcsnicmp(argv[i], L"/lev:", 5)) { long value = 0; value = wcstol(&(argv[i][5]), NULL, 10); if (value >= 0) { options.max_subdirectories_depth = (UINT)value; + options.user_limited_subdirectories_depth = TRUE; } } else diff --git a/programs/robocopy/robocopy.h b/programs/robocopy/robocopy.h index 0e33effe331..4b322f8b6f9 100644 --- a/programs/robocopy/robocopy.h +++ b/programs/robocopy/robocopy.h @@ -36,6 +36,8 @@ struct robocopy_options { WCHAR *source; struct path_array* files; UINT max_subdirectories_depth; + BOOL user_limited_subdirectories_depth; + BOOL copy_subdirectories; };
/* Resource strings */