James Hawkins : msi: Append the next directory to search to the current directory when recursing .

Alexandre Julliard julliard at winehq.org
Mon Oct 20 08:00:56 CDT 2008


Module: wine
Branch: master
Commit: 1fb22654e4f0a3a724ebb7ef1503b6d991143364
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=1fb22654e4f0a3a724ebb7ef1503b6d991143364

Author: James Hawkins <jhawkins at codeweavers.com>
Date:   Mon Oct 20 04:20:25 2008 -0500

msi: Append the next directory to search to the current directory when recursing.

---

 dlls/msi/appsearch.c     |   27 ++++++++++++++++++++-------
 dlls/msi/tests/package.c |    5 +----
 2 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/dlls/msi/appsearch.c b/dlls/msi/appsearch.c
index 056cd24..79554db 100644
--- a/dlls/msi/appsearch.c
+++ b/dlls/msi/appsearch.c
@@ -731,15 +731,18 @@ static UINT ACTION_RecurseSearchDirectory(MSIPACKAGE *package, LPWSTR *appValue,
     WIN32_FIND_DATAW findData;
     UINT rc = ERROR_SUCCESS;
     size_t dirLen = lstrlenW(dir), fileLen = lstrlenW(sig->File);
+    WCHAR subpath[MAX_PATH];
     WCHAR *buf;
 
+    static const WCHAR dot[] = {'.',0};
+    static const WCHAR dotdot[] = {'.','.',0};
     static const WCHAR starDotStarW[] = { '*','.','*',0 };
 
     TRACE("Searching directory %s for file %s, depth %d\n", debugstr_w(dir),
           debugstr_w(sig->File), depth);
 
     if (depth < 0)
-        return ERROR_INVALID_PARAMETER;
+        return ERROR_SUCCESS;
 
     *appValue = NULL;
     /* We need the buffer in both paths below, so go ahead and allocate it
@@ -772,7 +775,7 @@ static UINT ACTION_RecurseSearchDirectory(MSIPACKAGE *package, LPWSTR *appValue,
         FindClose(hFind);
     }
 
-    if (rc == ERROR_SUCCESS && !*appValue && depth > 0)
+    if (rc == ERROR_SUCCESS && !*appValue)
     {
         lstrcpyW(buf, dir);
         PathAddBackslashW(buf);
@@ -781,18 +784,28 @@ static UINT ACTION_RecurseSearchDirectory(MSIPACKAGE *package, LPWSTR *appValue,
         hFind = FindFirstFileW(buf, &findData);
         if (hFind != INVALID_HANDLE_VALUE)
         {
-            if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+            if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
+                lstrcmpW(findData.cFileName, dot) &&
+                lstrcmpW(findData.cFileName, dotdot))
+            {
+                lstrcpyW(subpath, dir);
+                PathAppendW(subpath, findData.cFileName);
                 rc = ACTION_RecurseSearchDirectory(package, appValue, sig,
-                                                   findData.cFileName,
-                                                   depth - 1);
+                                                   subpath, depth - 1);
+            }
 
             while (rc == ERROR_SUCCESS && !*appValue &&
                    FindNextFileW(hFind, &findData) != 0)
             {
+                if (!lstrcmpW(findData.cFileName, dot) ||
+                    !lstrcmpW(findData.cFileName, dotdot))
+                    continue;
+
+                lstrcpyW(subpath, dir);
+                PathAppendW(subpath, findData.cFileName);
                 if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
                     rc = ACTION_RecurseSearchDirectory(package, appValue,
-                                                       sig, findData.cFileName,
-                                                       depth - 1);
+                                                       sig, subpath, depth - 1);
             }
 
             FindClose(hFind);
diff --git a/dlls/msi/tests/package.c b/dlls/msi/tests/package.c
index 981c39e..30c9567 100644
--- a/dlls/msi/tests/package.c
+++ b/dlls/msi/tests/package.c
@@ -7158,10 +7158,7 @@ static void test_appsearch_drlocator(void)
     sprintf(path, "%s\\one\\two\\three\\FileName2", CURR_DIR);
     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
-    todo_wine
-    {
-        ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
-    }
+    ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
 
     size = MAX_PATH;
     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);




More information about the wine-cvs mailing list