cmd.exe: Support del /p.

This commit is contained in:
Jason Edmeades 2007-02-27 23:20:05 +00:00 committed by Alexandre Julliard
parent 409368eb4c
commit fe29ed41cc
2 changed files with 22 additions and 7 deletions

View File

@ -240,7 +240,7 @@ char *p;
/* If filename part of parameter is * or *.*, prompt unless /* If filename part of parameter is * or *.*, prompt unless
/Q supplied. */ /Q supplied. */
if (strstr (quals, "/Q") == NULL) { if ((strstr (quals, "/Q") == NULL) && (strstr (quals, "/P") == NULL)) {
char drive[10]; char drive[10];
char dir[MAX_PATH]; char dir[MAX_PATH];
@ -259,7 +259,7 @@ char *p;
/* Ask for confirmation */ /* Ask for confirmation */
sprintf(question, "%s, ", fpath); sprintf(question, "%s, ", fpath);
ok = WCMD_ask_confirm(question); ok = WCMD_ask_confirm(question, TRUE);
/* Abort if answer is 'N' */ /* Abort if answer is 'N' */
if (!ok) return; if (!ok) return;
@ -288,8 +288,21 @@ char *p;
} }
else strcpy (fpath, fd.cFileName); else strcpy (fpath, fd.cFileName);
if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
/* /P means prompt for each file */
if (strstr (quals, "/P") != NULL) {
BOOL ok;
char question[MAXSTRING];
/* Ask for confirmation */
sprintf(question, "%s, Delete", fpath);
ok = WCMD_ask_confirm(question, FALSE);
/* Only delete if answer is 'Y' */
if (ok && !DeleteFile (fpath)) WCMD_print_error ();
} else {
if (!DeleteFile (fpath)) WCMD_print_error (); if (!DeleteFile (fpath)) WCMD_print_error ();
} }
}
} while (FindNextFile(hff, &fd) != 0); } while (FindNextFile(hff, &fd) != 0);
FindClose (hff); FindClose (hff);
} }
@ -681,7 +694,7 @@ void WCMD_remove_dir (void) {
/* Ask for confirmation */ /* Ask for confirmation */
sprintf(question, "%s, ", param1); sprintf(question, "%s, ", param1);
ok = WCMD_ask_confirm(question); ok = WCMD_ask_confirm(question, TRUE);
/* Abort if answer is 'N' */ /* Abort if answer is 'N' */
if (!ok) return; if (!ok) return;
@ -1313,7 +1326,7 @@ void WCMD_exit (void) {
* Returns True if Y answer is selected * Returns True if Y answer is selected
* *
*/ */
BOOL WCMD_ask_confirm (char *message) { BOOL WCMD_ask_confirm (char *message, BOOL showSureText) {
char msgbuffer[MAXSTRING]; char msgbuffer[MAXSTRING];
char Ybuffer[MAXSTRING]; char Ybuffer[MAXSTRING];
@ -1329,7 +1342,9 @@ BOOL WCMD_ask_confirm (char *message) {
/* Loop waiting on a Y or N */ /* Loop waiting on a Y or N */
while (answer[0] != Ybuffer[0] && answer[0] != Nbuffer[0]) { while (answer[0] != Ybuffer[0] && answer[0] != Nbuffer[0]) {
WCMD_output_asis (message); WCMD_output_asis (message);
if (showSureText) {
WCMD_output_asis (msgbuffer); WCMD_output_asis (msgbuffer);
}
WCMD_output_asis (" ("); WCMD_output_asis (" (");
WCMD_output_asis (Ybuffer); WCMD_output_asis (Ybuffer);
WCMD_output_asis ("/"); WCMD_output_asis ("/");

View File

@ -80,7 +80,7 @@ char *WCMD_strtrim_leading_spaces (char *string);
void WCMD_strtrim_trailing_spaces (char *string); void WCMD_strtrim_trailing_spaces (char *string);
void WCMD_opt_s_strip_quotes(char *cmd); void WCMD_opt_s_strip_quotes(char *cmd);
void WCMD_HandleTildaModifiers(char **start, char *forVariable); void WCMD_HandleTildaModifiers(char **start, char *forVariable);
BOOL WCMD_ask_confirm (char *message); BOOL WCMD_ask_confirm (char *message, BOOL showSureText);
void WCMD_splitpath(const CHAR* path, CHAR* drv, CHAR* dir, CHAR* name, CHAR* ext); void WCMD_splitpath(const CHAR* path, CHAR* drv, CHAR* dir, CHAR* name, CHAR* ext);