Module: wine Branch: master Commit: 432d81d704438570921b54b8e7697fd0dff27599 URL: http://source.winehq.org/git/wine.git/?a=commit;h=432d81d704438570921b54b8e7...
Author: Jason Edmeades us@edmeades.me.uk Date: Thu Mar 29 22:21:06 2007 +0100
xcopy: Add support for /R (Replace read only files).
---
programs/xcopy/xcopy.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/programs/xcopy/xcopy.c b/programs/xcopy/xcopy.c index 2f2e7f9..8baa92f 100644 --- a/programs/xcopy/xcopy.c +++ b/programs/xcopy/xcopy.c @@ -51,6 +51,7 @@ #define OPT_NOPROMPT 0x00000100 #define OPT_SHORTNAME 0x00000200 #define OPT_MUSTEXIST 0x00000400 +#define OPT_REPLACEREAD 0x00000800
#define MAXSTRING 8192
@@ -155,6 +156,7 @@ int main (int argc, char *argv[]) case 'Y': flags |= OPT_NOPROMPT; break; case 'N': flags |= OPT_SHORTNAME; break; case 'U': flags |= OPT_MUSTEXIST; break; + case 'R': flags |= OPT_REPLACEREAD; break; case '-': if (toupper(argvW[0][2])=='Y') flags &= ~OPT_NOPROMPT; break; default: @@ -475,6 +477,13 @@ static int XCOPY_DoCopy(WCHAR *srcstem, WCHAR *srcspec, printf("%S\n", copyFrom); }
+ /* If allowing overwriting of read only files, remove any + write protection */ + if ((destAttribs & FILE_ATTRIBUTE_READONLY) && + (flags & OPT_REPLACEREAD)) { + SetFileAttributes(copyTo, destAttribs & ~FILE_ATTRIBUTE_READONLY); + } + copiedFile = TRUE; if (flags & OPT_SIMULATE || flags & OPT_NOCOPY) { /* Skip copy */