[PATCH 08/18] XCOPY: Add support for /R (Replace read only files)
Jason Edmeades
us at edmeades.me.uk
Thu Mar 29 16:21:06 CDT 2007
---
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 */
--
1.5.0
More information about the wine-patches
mailing list