Module: wine Branch: oldstable Commit: b88242df969df34be7e2e253736420dfbd0f98af URL: https://source.winehq.org/git/wine.git/?a=commit;h=b88242df969df34be7e2e2537...
Author: Myah Caron qsniyg@protonmail.com Date: Thu Sep 10 19:10:55 2020 +0000
cmd.exe: Fix /Y flag for move builtin.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48397 Signed-off-by: Myah Caron qsniyg@protonmail.com Signed-off-by: Alexandre Julliard julliard@winehq.org (cherry picked from commit 81fe7a2165ed244cc0ac24b133e49ce596e77710) Signed-off-by: Michael Stefaniuc mstefani@winehq.org
---
programs/cmd/builtins.c | 15 +++++---------- programs/cmd/tests/test_builtins.cmd.exp | 4 ++-- 2 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index 8911a597eb9..291b76dae90 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -3003,6 +3003,7 @@ void WCMD_move (void) WCHAR src[MAX_PATH]; DWORD attribs; BOOL ok = TRUE; + DWORD flags = 0;
WINE_TRACE("Processing file '%s'\n", wine_dbgstr_w(fd.cFileName));
@@ -3051,20 +3052,14 @@ void WCMD_move (void) question = WCMD_format_string(WCMD_LoadMessage(WCMD_OVERWRITE), dest); ok = WCMD_ask_confirm(question, FALSE, NULL); LocalFree(question); - - /* So delete the destination prior to the move */ - if (ok) { - if (!DeleteFileW(dest)) { - WCMD_print_error (); - errorlevel = 1; - ok = FALSE; - } - } } + + if (ok) + flags |= MOVEFILE_REPLACE_EXISTING; }
if (ok) { - status = MoveFileW(src, dest); + status = MoveFileExW(src, dest, flags); } else { status = TRUE; } diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index 5bcd29b917c..36e986e8ad9 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -1341,8 +1341,8 @@ original file still present ------------ Testing move ------------ --- file move file move succeeded -@todo_wine@file move with overwrite succeeded@or_broken@file overwrite impossible! -@todo_wine@bar@or_broken@baz +file move with overwrite succeeded@or_broken@file overwrite impossible! +bar@or_broken@baz read-only files are moveable file moved in subdirectory moving a file to itself is a no-op@or_broken@moving a file to itself should be a no-op!