John Thomson : shell32: Do not fail in SHCreateDirectoryExW for ERROR_ALREADY_EXISTS.
Alexandre Julliard
julliard at winehq.org
Wed Apr 24 16:33:30 CDT 2019
Module: wine
Branch: master
Commit: 9b6d198a3c7c8a02aa69c0d3d11829712e9778a6
URL: https://source.winehq.org/git/wine.git/?a=commit;h=9b6d198a3c7c8a02aa69c0d3d11829712e9778a6
Author: John Thomson <git at johnthomson.fastmail.com.au>
Date: Wed Apr 17 10:34:38 2019 +1000
shell32: Do not fail in SHCreateDirectoryExW for ERROR_ALREADY_EXISTS.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47023
Signed-off-by: John Thomson <git at johnthomson.fastmail.com.au>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/shell32/shlfileop.c | 4 +++-
dlls/shell32/tests/shlfileop.c | 15 +++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/dlls/shell32/shlfileop.c b/dlls/shell32/shlfileop.c
index c7bd54d..1515ad3 100644
--- a/dlls/shell32/shlfileop.c
+++ b/dlls/shell32/shlfileop.c
@@ -763,7 +763,9 @@ int WINAPI SHCreateDirectoryExW(HWND hWnd, LPCWSTR path, LPSECURITY_ATTRIBUTES s
}
}
- if (ret && hWnd && (ERROR_CANCELLED != ret))
+ if (ret && hWnd &&
+ ret != ERROR_CANCELLED &&
+ ret != ERROR_ALREADY_EXISTS)
{
/* We failed and should show a dialog box */
FIXME("Show system error message, creating path %s, failed with error %d\n", debugstr_w(path), ret);
diff --git a/dlls/shell32/tests/shlfileop.c b/dlls/shell32/tests/shlfileop.c
index 8fb4dcf..27c7244 100644
--- a/dlls/shell32/tests/shlfileop.c
+++ b/dlls/shell32/tests/shlfileop.c
@@ -2543,6 +2543,7 @@ static void test_unicode(void)
int ret;
HANDLE file;
static const WCHAR UNICODE_PATH_TO[] = {'c',':','\\',0x00ae,0x00ae,'\0'};
+ HWND hwnd;
shfoW.hwnd = NULL;
shfoW.wFunc = FO_DELETE;
@@ -2633,6 +2634,20 @@ static void test_unicode(void)
ok(GetLastError() == ERROR_SUCCESS ||
broken(GetLastError() == ERROR_INVALID_HANDLE), /* WinXp, win2k3 */
"Expected ERROR_SUCCESS, got %d\n", GetLastError());
+
+ /* Check SHCreateDirectoryExW with a Hwnd
+ * returns ERROR_ALREADY_EXISTS where a directory already exists */
+ /* Get any window handle */
+ hwnd = FindWindowA(NULL, NULL);
+ ok(hwnd != 0, "FindWindowA failed to produce a hwnd\n");
+ ret = SHCreateDirectoryExW(hwnd, UNICODE_PATH, NULL);
+ ok(!ret, "SHCreateDirectoryExW returned %d\n", ret);
+ /* Create already-existing directory */
+ ok(file_existsW(UNICODE_PATH), "The directory was not created\n");
+ ret = SHCreateDirectoryExW(hwnd, UNICODE_PATH, NULL);
+ ok(ret == ERROR_ALREADY_EXISTS,
+ "Expected ERROR_ALREADY_EXISTS, got %d\n", ret);
+ RemoveDirectoryW(UNICODE_PATH);
}
static void
More information about the wine-cvs
mailing list