xcopy: Add support for /R (Replace read only files).
This commit is contained in:
parent
5f8f5eb5be
commit
432d81d704
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue