cmd.exe: Add prompting and COPYCMD plus /Y support to move.

This commit is contained in:
Jason Edmeades 2007-04-11 22:25:53 +01:00 committed by Alexandre Julliard
parent d0a6fe101a
commit 2f5bfc0f78
16 changed files with 60 additions and 1 deletions

View File

@ -236,4 +236,5 @@ Zadejte HELP <p
WCMD_NO, "N"
WCMD_NOASSOC, "File association missing for extension %s\n"
WCMD_NOFTYPE, "No open command associated with file type '%s'\n"
WCMD_OVERWRITE, "Overwrite"
}

View File

@ -253,4 +253,5 @@ obigen Befehle erhalten.\n"
WCMD_NO, "N"
WCMD_NOASSOC, "File association missing for extension %s\n"
WCMD_NOFTYPE, "No open command associated with file type '%s'\n"
WCMD_OVERWRITE, "Overwrite"
}

View File

@ -240,4 +240,5 @@ Enter HELP <command> for further information on any of the above commands\n"
WCMD_NO, "N"
WCMD_NOASSOC, "File association missing for extension %s\n"
WCMD_NOFTYPE, "No open command associated with file type '%s'\n"
WCMD_OVERWRITE, "Overwrite"
}

View File

@ -248,4 +248,5 @@ Introduzca HELP <comando> para m
WCMD_NO, "N"
WCMD_NOASSOC, "File association missing for extension %s\n"
WCMD_NOFTYPE, "No open command associated with file type '%s'\n"
WCMD_OVERWRITE, "Overwrite"
}

View File

@ -230,4 +230,5 @@ Entrez HELP <commande> pour plus d'informations sur les commandes ci-dessus\n"
WCMD_NO, "N"
WCMD_NOASSOC, "File association missing for extension %s\n"
WCMD_NOFTYPE, "No open command associated with file type '%s'\n"
WCMD_OVERWRITE, "Overwrite"
}

View File

@ -234,4 +234,5 @@ EXIT\t\tCMD
WCMD_NO, "N"
WCMD_NOASSOC, "File association missing for extension %s\n"
WCMD_NOFTYPE, "No open command associated with file type '%s'\n"
WCMD_OVERWRITE, "Overwrite"
}

View File

@ -232,4 +232,5 @@ HELP <
WCMD_NO, "아니오"
WCMD_NOASSOC, "이 파일확장자 %s에 연결된 풀그림이 없습니다. \n"
WCMD_NOFTYPE, "이 파일 형식 '%s'과 연결된 어떠한 명령도 없습니다.'\n"
WCMD_OVERWRITE, "Overwrite"
}

View File

@ -233,4 +233,5 @@ type HELP <opdracht> voor meer informatie over bovengenoemde opdrachten\n"
WCMD_NO, "N"
WCMD_NOASSOC, "File association missing for extension %s\n"
WCMD_NOFTYPE, "No open command associated with file type '%s'\n"
WCMD_OVERWRITE, "Overwrite"
}

View File

@ -231,4 +231,5 @@ Skriv
WCMD_NO, "N"
WCMD_NOASSOC, "File association missing for extension %s\n"
WCMD_NOFTYPE, "No open command associated with file type '%s'\n"
WCMD_OVERWRITE, "Overwrite"
}

View File

@ -235,4 +235,5 @@ Wpisz HELP <komenda> dla dok
WCMD_NO, "N"
WCMD_NOASSOC, "File association missing for extension %s\n"
WCMD_NOFTYPE, "No open command associated with file type '%s'\n"
WCMD_OVERWRITE, "Overwrite"
}

View File

@ -440,4 +440,5 @@ Digite HELP <comando> para mais informa
WCMD_NO, "N"
WCMD_NOASSOC, "File association missing for extension %s\n"
WCMD_NOFTYPE, "No open command associated with file type '%s'\n"
WCMD_OVERWRITE, "Overwrite"
}

View File

@ -246,4 +246,5 @@ EXIT\t\t
WCMD_NO, "N"
WCMD_NOASSOC, "File association missing for extension %s\n"
WCMD_NOFTYPE, "No open command associated with file type '%s'\n"
WCMD_OVERWRITE, "Overwrite"
}

View File

@ -232,4 +232,5 @@ Enter HELP <command> for further information on any of the above commands\n"
WCMD_NO, "N"
WCMD_NOASSOC, "File association missing for extension %s\n"
WCMD_NOFTYPE, "No open command associated with file type '%s'\n"
WCMD_OVERWRITE, "Overwrite"
}

View File

@ -234,4 +234,5 @@ Yukar
WCMD_NO, "N"
WCMD_NOASSOC, "File association missing for extension %s\n"
WCMD_NOFTYPE, "No open command associated with file type '%s'\n"
WCMD_OVERWRITE, "Overwrite"
}

View File

@ -783,7 +783,51 @@ void WCMD_move (void) {
SetLastError(ERROR_ACCESS_DENIED);
status = 0;
} else {
status = MoveFile (src, dest);
BOOL ok = TRUE;
/* If destination exists, prompt unless /Y supplied */
if (GetFileAttributesA(dest) != INVALID_FILE_ATTRIBUTES) {
BOOL force = FALSE;
char copycmd[MAXSTRING];
int len;
/* /-Y has the highest priority, then /Y and finally the COPYCMD env. variable */
if (strstr (quals, "/-Y"))
force = FALSE;
else if (strstr (quals, "/Y"))
force = TRUE;
else {
len = GetEnvironmentVariable ("COPYCMD", copycmd, sizeof(copycmd));
force = (len && len < sizeof(copycmd) && ! lstrcmpi (copycmd, "/Y"));
}
/* Prompt if overwriting */
if (!force) {
char question[MAXSTRING];
char overwrite[MAXSTRING];
LoadString (hinst, WCMD_OVERWRITE, overwrite, sizeof(overwrite));
/* Ask for confirmation */
sprintf(question, "%s %s? ", overwrite, dest);
ok = WCMD_ask_confirm(question, TRUE);
/* So delete the destination prior to the move */
if (ok) {
if (!DeleteFile (dest)) {
WCMD_print_error ();
errorlevel = 1;
ok = FALSE;
}
}
}
}
if (ok) {
status = MoveFile (src, dest);
} else {
status = 1; /* Anything other than 0 to prevent error msg below */
}
}
if (!status) {

View File

@ -179,6 +179,7 @@ extern const char anykey[];
#define WCMD_NO 1003
#define WCMD_NOASSOC 1004
#define WCMD_NOFTYPE 1005
#define WCMD_OVERWRITE 1006
/* msdn specified max for Win XP */
#define MAXSTRING 8192