Module: wine Branch: master Commit: 2f5bfc0f786e86412aeb8ce166ec1e209f44a291 URL: http://source.winehq.org/git/wine.git/?a=commit;h=2f5bfc0f786e86412aeb8ce166...
Author: Jason Edmeades us@edmeades.me.uk Date: Wed Apr 11 22:25:53 2007 +0100
cmd.exe: Add prompting and COPYCMD plus /Y support to move.
---
programs/cmd/Cs.rc | 1 + programs/cmd/De.rc | 1 + programs/cmd/En.rc | 1 + programs/cmd/Es.rc | 1 + programs/cmd/Fr.rc | 1 + programs/cmd/Ja.rc | 1 + programs/cmd/Ko.rc | 1 + programs/cmd/Nl.rc | 1 + programs/cmd/No.rc | 1 + programs/cmd/Pl.rc | 1 + programs/cmd/Pt.rc | 1 + programs/cmd/Ru.rc | 1 + programs/cmd/Si.rc | 1 + programs/cmd/Tr.rc | 1 + programs/cmd/builtins.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- programs/cmd/wcmd.h | 1 + 16 files changed, 60 insertions(+), 1 deletions(-)
diff --git a/programs/cmd/Cs.rc b/programs/cmd/Cs.rc index 7939fd4..83d01b2 100644 --- a/programs/cmd/Cs.rc +++ b/programs/cmd/Cs.rc @@ -236,4 +236,5 @@ Zadejte HELP <p��kaz> pro podrobn�j�� informace o n�kter�m z v��e uveden�ch p��k 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" } diff --git a/programs/cmd/De.rc b/programs/cmd/De.rc index a8ad3b5..b60cd2a 100644 --- a/programs/cmd/De.rc +++ b/programs/cmd/De.rc @@ -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" } diff --git a/programs/cmd/En.rc b/programs/cmd/En.rc index e542bcb..7fd28a6 100644 --- a/programs/cmd/En.rc +++ b/programs/cmd/En.rc @@ -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" } diff --git a/programs/cmd/Es.rc b/programs/cmd/Es.rc index 9feac82..0933496 100644 --- a/programs/cmd/Es.rc +++ b/programs/cmd/Es.rc @@ -248,4 +248,5 @@ Introduzca HELP <comando> para m�s informaci�n sobre cualquiera de los comandos\ 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" } diff --git a/programs/cmd/Fr.rc b/programs/cmd/Fr.rc index e4c0c42..6897438 100644 --- a/programs/cmd/Fr.rc +++ b/programs/cmd/Fr.rc @@ -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" } diff --git a/programs/cmd/Ja.rc b/programs/cmd/Ja.rc index 7762e80..f7435a6 100644 --- a/programs/cmd/Ja.rc +++ b/programs/cmd/Ja.rc @@ -234,4 +234,5 @@ EXIT\t\tCMD���I��\n\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" } diff --git a/programs/cmd/Ko.rc b/programs/cmd/Ko.rc index ebc3116..0a5b2fd 100644 --- a/programs/cmd/Ko.rc +++ b/programs/cmd/Ko.rc @@ -232,4 +232,5 @@ HELP <����>�� ġ�� �� ������ ���� ������ ������\n" WCMD_NO, "�ƴϿ�" WCMD_NOASSOC, "�� ����Ȯ���� %s�� ����� Ǯ���� �����ϴ�. \n" WCMD_NOFTYPE, "�� ���� ���� '%s'�� ����� ��� ���ɵ� �����ϴ�.'\n" + WCMD_OVERWRITE, "Overwrite" } diff --git a/programs/cmd/Nl.rc b/programs/cmd/Nl.rc index 3a94d92..ef6c7e2 100644 --- a/programs/cmd/Nl.rc +++ b/programs/cmd/Nl.rc @@ -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" } diff --git a/programs/cmd/No.rc b/programs/cmd/No.rc index 6bf129d..87e84d2 100644 --- a/programs/cmd/No.rc +++ b/programs/cmd/No.rc @@ -231,4 +231,5 @@ Skriv �HELP <kommando>� for mer informasjon om kommandoene ovenfor\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" } diff --git a/programs/cmd/Pl.rc b/programs/cmd/Pl.rc index 2c797e0..59afcf0 100644 --- a/programs/cmd/Pl.rc +++ b/programs/cmd/Pl.rc @@ -235,4 +235,5 @@ Wpisz HELP <komenda> dla dok�adniejszych informacji o komendzie\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" } diff --git a/programs/cmd/Pt.rc b/programs/cmd/Pt.rc index f4a28ce..3c9809f 100644 --- a/programs/cmd/Pt.rc +++ b/programs/cmd/Pt.rc @@ -440,4 +440,5 @@ Digite HELP <comando> para mais informa��es sobre alguns dos comandos acima\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" } diff --git a/programs/cmd/Ru.rc b/programs/cmd/Ru.rc index 6f3f01a..781aa26 100644 --- a/programs/cmd/Ru.rc +++ b/programs/cmd/Ru.rc @@ -246,4 +246,5 @@ EXIT\t\t����� �� CMD\n\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" } diff --git a/programs/cmd/Si.rc b/programs/cmd/Si.rc index f7224c5..f70c915 100644 --- a/programs/cmd/Si.rc +++ b/programs/cmd/Si.rc @@ -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" } diff --git a/programs/cmd/Tr.rc b/programs/cmd/Tr.rc index 1d8d67f..8b4820b 100644 --- a/programs/cmd/Tr.rc +++ b/programs/cmd/Tr.rc @@ -234,4 +234,5 @@ Yukar�daki komutlar hakk�nda daha fazla bilgi i�in HELP <komut> girin\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" } diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index 832da83..3d4f034 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -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) { diff --git a/programs/cmd/wcmd.h b/programs/cmd/wcmd.h index 29efbe4..2873ea2 100644 --- a/programs/cmd/wcmd.h +++ b/programs/cmd/wcmd.h @@ -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