Module: wine Branch: master Commit: 60e79adb53b78d6e78d90fb191ca62cd78fab13a URL: http://source.winehq.org/git/wine.git/?a=commit;h=60e79adb53b78d6e78d90fb191...
Author: Jason Edmeades us@edmeades.me.uk Date: Thu Mar 29 22:21:09 2007 +0100
xcopy: Add support for /P (Prompt).
---
programs/xcopy/xcopy.c | 26 +++++++++++++++++++++++++- 1 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/programs/xcopy/xcopy.c b/programs/xcopy/xcopy.c index 97348dd..0539716 100644 --- a/programs/xcopy/xcopy.c +++ b/programs/xcopy/xcopy.c @@ -54,6 +54,7 @@ #define OPT_REPLACEREAD 0x00000800 #define OPT_COPYHIDSYS 0x00001000 #define OPT_IGNOREERRORS 0x00002000 +#define OPT_SRCPROMPT 0x00004000
#define MAXSTRING 8192
@@ -145,7 +146,10 @@ int main (int argc, char *argv[]) return RC_INITERROR; } } else { - /* Process all the switch options */ + /* Process all the switch options + Note: Windows docs say /P prompts when dest is created + but tests show it is done for each src file + regardless of the destination */ switch (toupper(argvW[0][1])) { case 'I': flags |= OPT_ASSUMEDIR; break; case 'S': flags |= OPT_RECURSIVE; break; @@ -161,6 +165,7 @@ int main (int argc, char *argv[]) case 'R': flags |= OPT_REPLACEREAD; break; case 'H': flags |= OPT_COPYHIDSYS; break; case 'C': flags |= OPT_IGNOREERRORS; break; + case 'P': flags |= OPT_SRCPROMPT; break; case '-': if (toupper(argvW[0][2])=='Y') flags &= ~OPT_NOPROMPT; break; default: @@ -457,6 +462,25 @@ static int XCOPY_DoCopy(WCHAR *srcstem, WCHAR *srcspec, } }
+ /* Prompt each file if necessary */ + if (!skipFile && (flags & OPT_SRCPROMPT)) { + DWORD count; + char answer[10]; + BOOL answered = FALSE; + + while (!answered) { + printf("%S? (Yes|No)\n", copyFrom); + ReadFile (GetStdHandle(STD_INPUT_HANDLE), answer, sizeof(answer), + &count, NULL); + + answered = TRUE; + if (toupper(answer[0]) == 'N') + skipFile = TRUE; + else if (toupper(answer[0]) != 'Y') + answered = FALSE; + } + } + /* See if file exists */ destAttribs = GetFileAttributesW(copyTo); if (!skipFile &&