Jason Edmeades : xcopy: Add support for xcopy /A and /M (archive
copies).
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Mar 30 06:20:34 CDT 2007
Module: wine
Branch: master
Commit: 4794bec1c1266ce907507d699f391204069e7074
URL: http://source.winehq.org/git/wine.git/?a=commit;h=4794bec1c1266ce907507d699f391204069e7074
Author: Jason Edmeades <us at edmeades.me.uk>
Date: Thu Mar 29 22:21:10 2007 +0100
xcopy: Add support for xcopy /A and /M (archive copies).
---
programs/xcopy/xcopy.c | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/programs/xcopy/xcopy.c b/programs/xcopy/xcopy.c
index 0539716..f957c83 100644
--- a/programs/xcopy/xcopy.c
+++ b/programs/xcopy/xcopy.c
@@ -55,6 +55,8 @@
#define OPT_COPYHIDSYS 0x00001000
#define OPT_IGNOREERRORS 0x00002000
#define OPT_SRCPROMPT 0x00004000
+#define OPT_ARCHIVEONLY 0x00008000
+#define OPT_REMOVEARCH 0x00010000
#define MAXSTRING 8192
@@ -166,6 +168,9 @@ int main (int argc, char *argv[])
case 'H': flags |= OPT_COPYHIDSYS; break;
case 'C': flags |= OPT_IGNOREERRORS; break;
case 'P': flags |= OPT_SRCPROMPT; break;
+ case 'A': flags |= OPT_ARCHIVEONLY; break;
+ case 'M': flags |= OPT_ARCHIVEONLY |
+ OPT_REMOVEARCH; break;
case '-': if (toupper(argvW[0][2])=='Y')
flags &= ~OPT_NOPROMPT; break;
default:
@@ -454,6 +459,8 @@ static int XCOPY_DoCopy(WCHAR *srcstem, WCHAR *srcspec,
/* See if allowed to copy it */
srcAttribs = GetFileAttributesW(copyFrom);
+ WINE_TRACE("Source attribs: %d\n", srcAttribs);
+
if ((srcAttribs & FILE_ATTRIBUTE_HIDDEN) ||
(srcAttribs & FILE_ATTRIBUTE_SYSTEM)) {
@@ -462,6 +469,11 @@ static int XCOPY_DoCopy(WCHAR *srcstem, WCHAR *srcspec,
}
}
+ if (!(srcAttribs & FILE_ATTRIBUTE_ARCHIVE) &&
+ (flags & OPT_ARCHIVEONLY)) {
+ skipFile = TRUE;
+ }
+
/* Prompt each file if necessary */
if (!skipFile && (flags & OPT_SRCPROMPT)) {
DWORD count;
@@ -483,6 +495,8 @@ static int XCOPY_DoCopy(WCHAR *srcstem, WCHAR *srcspec,
/* See if file exists */
destAttribs = GetFileAttributesW(copyTo);
+ WINE_TRACE("Dest attribs: %d\n", srcAttribs);
+
if (!skipFile &&
destAttribs != INVALID_FILE_ATTRIBUTES && !(flags & OPT_NOPROMPT)) {
DWORD count;
@@ -551,7 +565,15 @@ static int XCOPY_DoCopy(WCHAR *srcstem, WCHAR *srcspec,
return RC_WRITEERROR;
}
}
- filesCopied++;
+
+ /* If /M supplied, remove the archive bit after successful copy */
+ if (!skipFile) {
+ if ((srcAttribs & FILE_ATTRIBUTE_ARCHIVE) &&
+ (flags & OPT_REMOVEARCH)) {
+ SetFileAttributes(copyFrom, (srcAttribs & ~FILE_ATTRIBUTE_ARCHIVE));
+ }
+ filesCopied++;
+ }
}
}
More information about the wine-cvs
mailing list