[PATCH 15/18] XCOPY: Rearrange code to closly match windows ordering

Jason Edmeades us at edmeades.me.uk
Thu Mar 29 16:21:13 CDT 2007


Effectively work out if we are interested in a file before worrying
about prompting for copy or overwrite!
---
 programs/xcopy/xcopy.c |   86 ++++++++++++++++++++++++------------------------
 1 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/programs/xcopy/xcopy.c b/programs/xcopy/xcopy.c
index b95d748..73d4306 100644
--- a/programs/xcopy/xcopy.c
+++ b/programs/xcopy/xcopy.c
@@ -585,25 +585,6 @@ static int XCOPY_DoCopy(WCHAR *srcstem, WCHAR *srcspec,
                 skipFile = TRUE;
             }
 
-            /* Prompt each file if necessary */
-            if (!skipFile && (flags & OPT_SRCPROMPT)) {
-                DWORD count;
-                char  answer[10];
-                BOOL  answered = FALSE;
-
-                while (!answered) {
-                    printf("%S? (Yes|No)\n", copyFrom);
-                    ReadFile (GetStdHandle(STD_INPUT_HANDLE), answer, sizeof(answer),
-                              &count, NULL);
-
-                    answered = TRUE;
-                    if (toupper(answer[0]) == 'N')
-                        skipFile = TRUE;
-                    else if (toupper(answer[0]) != 'Y')
-                        answered = FALSE;
-                }
-            }
-
             /* See if file exists */
             destAttribs = GetFileAttributesW(copyTo);
             WINE_TRACE("Dest attribs: %d\n", srcAttribs);
@@ -633,6 +614,49 @@ static int XCOPY_DoCopy(WCHAR *srcstem, WCHAR *srcspec,
                 }
             }
 
+            /* See if exclude list provided. Note since filenames are case
+               insensitive, need to uppercase the filename before doing
+               strstr                                                     */
+            if (!skipFile && (flags & OPT_EXCLUDELIST)) {
+                EXCLUDELIST *pos = excludeList;
+                WCHAR copyFromUpper[MAX_PATH];
+
+                /* Uppercase source filename */
+                lstrcpyW(copyFromUpper, copyFrom);
+                CharUpperBuff(copyFromUpper, lstrlenW(copyFromUpper));
+
+                /* Loop through testing each exclude line */
+                while (pos) {
+                    if (wcsstr(copyFromUpper, pos->name) != NULL) {
+                        WINE_TRACE("Skipping file as matches exclude '%s'\n",
+                                   wine_dbgstr_w(pos->name));
+                        skipFile = TRUE;
+                        pos = NULL;
+                    } else {
+                        pos = pos->next;
+                    }
+                }
+            }
+
+            /* Prompt each file if necessary */
+            if (!skipFile && (flags & OPT_SRCPROMPT)) {
+                DWORD count;
+                char  answer[10];
+                BOOL  answered = FALSE;
+
+                while (!answered) {
+                    printf("%S? (Yes|No)\n", copyFrom);
+                    ReadFile (GetStdHandle(STD_INPUT_HANDLE), answer, sizeof(answer),
+                              &count, NULL);
+
+                    answered = TRUE;
+                    if (toupper(answer[0]) == 'N')
+                        skipFile = TRUE;
+                    else if (toupper(answer[0]) != 'Y')
+                        answered = FALSE;
+                }
+            }
+
             if (!skipFile &&
                 destAttribs != INVALID_FILE_ATTRIBUTES && !(flags & OPT_NOPROMPT)) {
                 DWORD count;
@@ -659,30 +683,6 @@ static int XCOPY_DoCopy(WCHAR *srcstem, WCHAR *srcspec,
                 skipFile = TRUE;
             }
 
-            /* See if exclude list provided. Note since filenames are case
-               insensitive, need to uppercase the filename before doing
-               strstr                                                     */
-            if (!skipFile && (flags & OPT_EXCLUDELIST)) {
-                EXCLUDELIST *pos = excludeList;
-                WCHAR copyFromUpper[MAX_PATH];
-
-                /* Uppercase source filename */
-                lstrcpyW(copyFromUpper, copyFrom);
-                CharUpperBuff(copyFromUpper, lstrlenW(copyFromUpper));
-
-                /* Loop through testing each exclude line */
-                while (pos) {
-                    if (wcsstr(copyFromUpper, pos->name) != NULL) {
-                        WINE_TRACE("Skipping file as matches exclude '%s'\n",
-                                   wine_dbgstr_w(pos->name));
-                        skipFile = TRUE;
-                        pos = NULL;
-                    } else {
-                        pos = pos->next;
-                    }
-                }
-            }
-
             /* Output a status message */
             if (!skipFile) {
                 if (flags & OPT_QUIET) {
-- 
1.5.0




More information about the wine-patches mailing list