=?UTF-8?Q?Michael=20M=C3=BCller=20?=: shlwapi: Correctly treat '.' when enumerating files in PathIsDirectoryEmptyW.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Jan 15 15:55:41 CST 2015
Module: wine
Branch: master
Commit: 8758a8a671c14d4e4c1303ea9dacd5e7066e5475
URL: http://source.winehq.org/git/wine.git/?a=commit;h=8758a8a671c14d4e4c1303ea9dacd5e7066e5475
Author: Michael Müller <michael at fds-team.de>
Date: Sun Sep 28 17:30:45 2014 +0200
shlwapi: Correctly treat '.' when enumerating files in PathIsDirectoryEmptyW.
---
dlls/shlwapi/path.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/dlls/shlwapi/path.c b/dlls/shlwapi/path.c
index a3b462c..dae949a 100644
--- a/dlls/shlwapi/path.c
+++ b/dlls/shlwapi/path.c
@@ -3872,13 +3872,13 @@ BOOL WINAPI PathIsDirectoryEmptyW(LPCWSTR lpszPath)
WCHAR szSearch[MAX_PATH];
DWORD dwLen;
HANDLE hfind;
- BOOL retVal = FALSE;
+ BOOL retVal = TRUE;
WIN32_FIND_DATAW find_data;
TRACE("(%s)\n",debugstr_w(lpszPath));
if (!lpszPath || !PathIsDirectoryW(lpszPath))
- return FALSE;
+ return FALSE;
lstrcpynW(szSearch, lpszPath, MAX_PATH);
PathAddBackslashW(szSearch);
@@ -3888,14 +3888,23 @@ BOOL WINAPI PathIsDirectoryEmptyW(LPCWSTR lpszPath)
strcpyW(szSearch + dwLen, szAllFiles);
hfind = FindFirstFileW(szSearch, &find_data);
- if (hfind != INVALID_HANDLE_VALUE)
+ if (hfind == INVALID_HANDLE_VALUE)
+ return FALSE;
+
+ do
{
- if (find_data.cFileName[0] == '.' && find_data.cFileName[1] == '.')
- /* The only directory entry should be the parent */
- retVal = !FindNextFileW(hfind, &find_data);
- FindClose(hfind);
+ if (find_data.cFileName[0] == '.')
+ {
+ if (find_data.cFileName[1] == '\0') continue;
+ if (find_data.cFileName[1] == '.' && find_data.cFileName[2] == '\0') continue;
+ }
+
+ retVal = FALSE;
+ break;
}
+ while (FindNextFileW(hfind, &find_data));
+ FindClose(hfind);
return retVal;
}
More information about the wine-cvs
mailing list