cmd: MOVEing a file to itself is a no-op
Frédéric Delanoy
frederic.delanoy at gmail.com
Wed Oct 19 16:51:32 CDT 2011
For directory files, this still gives errors (as windows does)
---
programs/cmd/builtins.c | 7 +++++++
programs/cmd/tests/test_builtins.cmd.exp | 4 ++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index 79e1ced..eaad4e2 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -1590,6 +1590,13 @@ void WCMD_move (void)
if (hff == INVALID_HANDLE_VALUE)
return;
+ /* Moving a file to itself is a no-op */
+ if (!strcmpW(input, output)) {
+ DWORD attribs = GetFileAttributesW(input);
+ if (attribs != INVALID_FILE_ATTRIBUTES && !(attribs & FILE_ATTRIBUTE_DIRECTORY))
+ return;
+ }
+
do {
WCHAR dest[MAX_PATH];
WCHAR src[MAX_PATH];
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp
index 20e5d12..d61b75b 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -616,8 +616,8 @@ file move succeeded
@todo_wine at bar@or_broken at baz
read-only files are moveable
file moved in subdirectory
- at todo_wine@moving a file to itself is a no-op at or_broken@moving a file to itself should be a no-op!
- at todo_wine@ErrorLevel: 0 at or_broken@ErrorLevel: 1
+moving a file to itself is a no-op at or_broken@moving a file to itself should be a no-op!
+ErrorLevel: 0 at or_broken@ErrorLevel: 1
... directory move ...
simple directory move succeeded
moving a directory to itself gives error; errlevel 1
--
1.7.7
More information about the wine-patches
mailing list