diff --git a/dlls/shell32/shlfileop.c b/dlls/shell32/shlfileop.c index 4ef7803..07c76de 100644 --- a/dlls/shell32/shlfileop.c +++ b/dlls/shell32/shlfileop.c @@ -352,10 +352,16 @@ static BOOL SHELL_DeleteDirectoryW(HWND hwnd, LPCWSTR pszDir, BOOL bShowUI) WCHAR szTemp[MAX_PATH]; /* Make sure the directory exists before eventually prompting the user */ - PathCombineW(szTemp, pszDir, wWildcardFile); + hFind = FindFirstFileW(pszDir, &wfd); + if (hFind == INVALID_HANDLE_VALUE){ + if (GetLastError() == ERROR_PATH_NOT_FOUND) + SetLastError(0x7c); /* DE_INVALIDFILES */ + return FALSE; + } + FindClose(hFind); + + PathCombineW(szTemp, pszDir, wWildcardFile); hFind = FindFirstFileW(szTemp, &wfd); - if (hFind == INVALID_HANDLE_VALUE) - return FALSE; if (!bShowUI || (ret = SHELL_ConfirmDialogW(hwnd, ASK_DELETE_FOLDER, pszDir, NULL))) { @@ -1380,7 +1386,7 @@ static DWORD delete_files(LPSHFILEOPSTRUCTW lpFileOp, const FILE_LIST *flFrom) bPathExists = SHELL_DeleteDirectoryW(lpFileOp->hwnd, fileEntry->szFullPath, FALSE); if (!bPathExists) - return ERROR_PATH_NOT_FOUND; + return GetLastError(); } return ERROR_SUCCESS; diff --git a/dlls/shell32/tests/shlfileop.c b/dlls/shell32/tests/shlfileop.c index 14ace24..d02e3f2 100644 --- a/dlls/shell32/tests/shlfileop.c +++ b/dlls/shell32/tests/shlfileop.c @@ -622,7 +622,6 @@ static void test_delete(void) shfo.pFrom = "nonexistent.txt\0"; shfo.wFunc = FO_DELETE; ret = SHFileOperationA(&shfo); - todo_wine ok(ret == 1026 || ret == ERROR_FILE_NOT_FOUND || /* Vista */ broken(ret == ERROR_SUCCESS), /* NT4 */ @@ -651,7 +650,6 @@ static void test_delete(void) shfo.pFrom = "test1.txt\0nonexistent.txt\0test2.txt\0"; shfo.wFunc = FO_DELETE; ret = SHFileOperationA(&shfo); - todo_wine ok(ret == 1026 || ret == ERROR_FILE_NOT_FOUND || /* Vista */ broken(ret == ERROR_SUCCESS), /* NT4 */ @@ -664,14 +662,12 @@ static void test_delete(void) init_shfo_tests(); shfo.pFrom = "testdir2\\nonexistent.txt\0"; ret = SHFileOperationA(&shfo); - todo_wine ok(ret == ERROR_FILE_NOT_FOUND || /* Vista */ broken(ret == 0x402) || /* XP */ broken(ret == ERROR_SUCCESS), /* NT4 */ "Expected 0x402 or ERROR_FILE_NOT_FOUND, got %x\n", ret); shfo.pFrom = "nonexistent\\one.txt\0"; ret = SHFileOperationA(&shfo); - todo_wine ok(ret == DE_INVALIDFILES || /* Vista or later */ broken(ret == 0x402), /* XP */ "Expected 0x402 or DE_INVALIDFILES, got %x\n", ret);