From 94f9e789c94f90dad3d771cdabded15aeeedba8f Mon Sep 17 00:00:00 2001 From: Jason Edmeades Date: Mon, 3 Sep 2012 22:03:58 +0100 Subject: [PATCH] cmd: Fix rmdir error during recursive delete. --- programs/cmd/builtins.c | 4 ++++ programs/cmd/tests/test_builtins.cmd | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index a83947b0c3d..c92822b9d8c 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -1827,6 +1827,10 @@ void WCMD_remove_dir (WCHAR *command) { lpDir.pFrom = thisArg; lpDir.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI; lpDir.wFunc = FO_DELETE; + + /* SHFileOperationW needs file list with a double null termination */ + thisArg[lstrlenW(thisArg) + 1] = 0x00; + if (SHFileOperationW(&lpDir)) WCMD_print_error (); } } diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd index 36bc73fadd3..13b53c53722 100644 --- a/programs/cmd/tests/test_builtins.cmd +++ b/programs/cmd/tests/test_builtins.cmd @@ -1163,7 +1163,7 @@ if not exist foo ( ) mkdir foo\bar\baz echo foo > foo\bar\brol -rmdir /s /Q foo +rmdir /s /Q foo 2>&1 if not exist foo ( echo recursive rmdir succeeded ) else (