Sets *.* as default if no files to include are set by the user, checks whether both source and destination are set and introduces (the correct) exit codes
Signed-off-by: Florian Eder others.meder@gmail.com --- programs/robocopy/main.c | 21 ++++++++++++++++++--- programs/robocopy/robocopy.h | 5 +++++ programs/robocopy/robocopy.rc | 1 + 3 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/programs/robocopy/main.c b/programs/robocopy/main.c index 18bfe1b13f6..96fbdade6de 100644 --- a/programs/robocopy/main.c +++ b/programs/robocopy/main.c @@ -409,10 +409,25 @@ int __cdecl wmain(int argc, WCHAR *argv[]) { parse_arguments(argc, argv);
+ /* If no file filters are set, set *.* to include all files */ + if (options.files->size == 0) + { + options.files->array[options.files->size] = calloc(64, sizeof(WCHAR)); + wcscpy(options.files->array[0], L"*.*"); + options.files->size++; + } + print_header();
- perform_copy(); + /* Break if Source or Destination not set */ + if (!options.destination || !options.source) + { + output_message(STRING_MISSING_DESTINATION_OR_SOURCE); + return ROBOCOPY_ERROR_NO_FILES_COPIED; + } + + if (!perform_copy()) + return ROBOCOPY_ERROR_NO_FILES_COPIED;
- WINE_FIXME("robocopy stub"); - return 0; + return ROBOCOPY_NO_ERROR_FILES_COPIED; } \ No newline at end of file diff --git a/programs/robocopy/robocopy.h b/programs/robocopy/robocopy.h index 96901dfb597..bdce05fdcde 100644 --- a/programs/robocopy/robocopy.h +++ b/programs/robocopy/robocopy.h @@ -41,6 +41,10 @@ struct robocopy_options { BOOL copy_empty_subdirectories; };
+/* Exit codes */ +#define ROBOCOPY_NO_ERROR_FILES_COPIED 1 +#define ROBOCOPY_ERROR_NO_FILES_COPIED 16 + /* Resource strings */ #define STRING_HEADER 1000 #define STRING_SOURCE 1003 @@ -48,6 +52,7 @@ struct robocopy_options { #define STRING_FILES 1005 #define STRING_ADDITIONAL_INFO 1008 #define STRING_OPTIONS 1009 +#define STRING_MISSING_DESTINATION_OR_SOURCE 1010 #define STRING_ERROR_READ_DIRECTORY 1011 #define STRING_ERROR_WRITE_DIRECTORY 1012 #define STRING_ERROR_WRITE_FILE 1014 diff --git a/programs/robocopy/robocopy.rc b/programs/robocopy/robocopy.rc index 519deca3a4d..7c025b62b11 100644 --- a/programs/robocopy/robocopy.rc +++ b/programs/robocopy/robocopy.rc @@ -31,6 +31,7 @@ STRINGTABLE STRING_FILES, " Files: %1\n" STRING_ADDITIONAL_INFO, " %1\n" STRING_OPTIONS, "\n Options: %1\n\n" + STRING_MISSING_DESTINATION_OR_SOURCE, "No destination or source specified, can't copy anything\n" STRING_ERROR_READ_DIRECTORY, "[%1] Error %2 (%3) occurred reading directory "%4":\n%5\n" STRING_ERROR_WRITE_DIRECTORY, "[%1] Error %2 (%3) occurred writing directory "%4":\n%5\n" STRING_ERROR_WRITE_FILE, "[%1] Error %2 (%3) occurred writing file "%4":\n%5\n"