Jason Edmeades : cmd.exe: Support rd dir1 dir2.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Mar 5 06:23:41 CST 2007


Module: wine
Branch: master
Commit: 0efa91de15c393dc403994049292c1fa9313146f
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0efa91de15c393dc403994049292c1fa9313146f

Author: Jason Edmeades <us at edmeades.me.uk>
Date:   Sun Mar  4 22:33:27 2007 +0000

cmd.exe: Support rd dir1 dir2.

---

 programs/cmd/builtins.c |   74 +++++++++++++++++++++++++++++------------------
 programs/cmd/wcmd.h     |    2 +-
 programs/cmd/wcmdmain.c |    2 +-
 3 files changed, 48 insertions(+), 30 deletions(-)

diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index 243a589..3aeac71 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -36,6 +36,9 @@
 
 #include "wcmd.h"
 #include <shellapi.h>
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(cmd);
 
 void WCMD_execute (char *orig_command, char *parameter, char *substitution);
 
@@ -752,44 +755,59 @@ void WCMD_pause (void) {
  * Delete a directory.
  */
 
-void WCMD_remove_dir (void) {
+void WCMD_remove_dir (char *command) {
 
-  if (param1[0] == 0x00) {
-    WCMD_output ("Argument missing\n");
-    return;
-  }
+  int   argno         = 0;
+  int   argsProcessed = 0;
+  char *argN          = command;
 
-  /* If subdirectory search not supplied, just try to remove
-     and report error if it fails (eg if it contains a file) */
-  if (strstr (quals, "/S") == NULL) {
-    if (!RemoveDirectory (param1)) WCMD_print_error ();
+  /* Loop through all args */
+  while (argN) {
+    char *thisArg = WCMD_parameter (command, argno++, &argN);
+    if (argN && argN[0] != '/') {
+      WINE_TRACE("rd: Processing arg %s (quals:%s)\n", thisArg, quals);
+      argsProcessed++;
 
-  /* Otherwise use ShFileOp to recursively remove a directory */
-  } else {
+      /* If subdirectory search not supplied, just try to remove
+         and report error if it fails (eg if it contains a file) */
+      if (strstr (quals, "/S") == NULL) {
+        if (!RemoveDirectory (thisArg)) WCMD_print_error ();
 
-    SHFILEOPSTRUCT lpDir;
+      /* Otherwise use ShFileOp to recursively remove a directory */
+      } else {
 
-    /* Ask first */
-    if (strstr (quals, "/Q") == NULL) {
-      BOOL  ok;
-      char  question[MAXSTRING];
+        SHFILEOPSTRUCT lpDir;
 
-      /* Ask for confirmation */
-      sprintf(question, "%s, ", param1);
-      ok = WCMD_ask_confirm(question, TRUE);
+        /* Ask first */
+        if (strstr (quals, "/Q") == NULL) {
+          BOOL  ok;
+          char  question[MAXSTRING];
 
-      /* Abort if answer is 'N' */
-      if (!ok) return;
+          /* Ask for confirmation */
+          sprintf(question, "%s, ", thisArg);
+          ok = WCMD_ask_confirm(question, TRUE);
+
+          /* Abort if answer is 'N' */
+          if (!ok) return;
+        }
+
+        /* Do the delete */
+        lpDir.hwnd   = NULL;
+        lpDir.pTo    = NULL;
+        lpDir.pFrom  = thisArg;
+        lpDir.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI;
+        lpDir.wFunc  = FO_DELETE;
+        if (SHFileOperationA(&lpDir)) WCMD_print_error ();
+      }
     }
+  }
 
-    /* Do the delete */
-    lpDir.hwnd   = NULL;
-    lpDir.pTo    = NULL;
-    lpDir.pFrom  = param1;
-    lpDir.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI;
-    lpDir.wFunc  = FO_DELETE;
-    if (SHFileOperationA(&lpDir)) WCMD_print_error ();
+  /* Handle no valid args */
+  if (argsProcessed == 0) {
+    WCMD_output ("Argument missing\n");
+    return;
   }
+
 }
 
 /****************************************************************************
diff --git a/programs/cmd/wcmd.h b/programs/cmd/wcmd.h
index d6357f0..61e3044 100644
--- a/programs/cmd/wcmd.h
+++ b/programs/cmd/wcmd.h
@@ -55,7 +55,7 @@ void WCMD_print_error (void);
 void WCMD_process_command (char *command);
 void WCMD_pushd (void);
 int  WCMD_read_console (char *string, int str_len);
-void WCMD_remove_dir (void);
+void WCMD_remove_dir (char *command);
 void WCMD_rename (void);
 void WCMD_run_program (char *command, int called);
 void WCMD_setlocal (const char *command);
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index 40dad28..f0331c5 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -530,7 +530,7 @@ void WCMD_process_command (char *command)
 	break;
       case WCMD_RD:
       case WCMD_RMDIR:
-        WCMD_remove_dir ();
+        WCMD_remove_dir (p);
         break;
       case WCMD_SETLOCAL:
         WCMD_setlocal(p);




More information about the wine-cvs mailing list