cmd.exe: Add support for del file1 file2.

This commit is contained in:
Jason Edmeades 2007-03-04 22:35:09 +00:00 committed by Alexandre Julliard
parent 79aa1a009f
commit a97d1200f3
3 changed files with 151 additions and 133 deletions

View File

@ -239,17 +239,25 @@ void WCMD_create_dir (void) {
* non-hidden files
*/
void WCMD_delete (int recurse) {
void WCMD_delete (char *command) {
int argno = 0;
int argsProcessed = 0;
char *argN = command;
/* Loop through all args */
while (argN) {
char *thisArg = WCMD_parameter (command, argno++, &argN);
if (argN && argN[0] != '/') {
WIN32_FIND_DATA fd;
HANDLE hff;
char fpath[MAX_PATH];
char *p;
if (param1[0] == 0x00) {
WCMD_output ("Argument missing\n");
return;
}
WINE_TRACE("del: Processing arg %s (quals:%s)\n", thisArg, quals);
argsProcessed++;
/* If filename part of parameter is * or *.*, prompt unless
/Q supplied. */
@ -261,7 +269,7 @@ void WCMD_delete (int recurse) {
char ext[MAX_PATH];
/* Convert path into actual directory spec */
GetFullPathName (param1, sizeof(fpath), fpath, NULL);
GetFullPathName (thisArg, sizeof(fpath), fpath, NULL);
WCMD_splitpath(fpath, drive, dir, fname, ext);
/* Only prompt for * and *.*, not *a, a*, *.a* etc */
@ -275,27 +283,29 @@ void WCMD_delete (int recurse) {
ok = WCMD_ask_confirm(question, TRUE);
/* Abort if answer is 'N' */
if (!ok) return;
if (!ok) continue;
}
}
hff = FindFirstFile (param1, &fd);
hff = FindFirstFile (thisArg, &fd);
if (hff == INVALID_HANDLE_VALUE) {
WCMD_output ("%s :File Not Found\n",param1);
return;
WCMD_output ("%s :File Not Found\n", thisArg);
continue;
}
/* Support del <dirname> by just deleting all files dirname\* */
if ((strchr(param1,'*') == NULL) && (strchr(param1,'?') == NULL)
&& (!recurse) && (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
strcat (param1, "\\*");
if ((strchr(thisArg,'*') == NULL) && (strchr(thisArg,'?') == NULL)
&& (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
char modifiedParm[MAX_PATH];
strcpy(modifiedParm, thisArg);
strcat(modifiedParm, "\\*");
FindClose(hff);
WCMD_delete (1);
return;
WCMD_delete(modifiedParm);
continue;
} else {
/* Build the filename to delete as <supplied directory>\<findfirst filename> */
strcpy (fpath, param1);
strcpy (fpath, thisArg);
do {
p = strrchr (fpath, '\\');
if (p != NULL) {
@ -390,6 +400,14 @@ void WCMD_delete (int recurse) {
FindClose (hff);
}
}
}
/* Handle no valid args */
if (argsProcessed == 0) {
WCMD_output ("Argument missing\n");
return;
}
}
/****************************************************************************
* WCMD_echo

View File

@ -34,7 +34,7 @@ void WCMD_change_tty (void);
void WCMD_clear_screen (void);
void WCMD_copy (void);
void WCMD_create_dir (void);
void WCMD_delete (int recurse);
void WCMD_delete (char *);
void WCMD_directory (void);
void WCMD_echo (const char *);
void WCMD_endlocal (void);

View File

@ -488,7 +488,7 @@ void WCMD_process_command (char *command)
break;
case WCMD_DEL:
case WCMD_ERASE:
WCMD_delete (0);
WCMD_delete (p);
break;
case WCMD_DIR:
WCMD_directory ();