shlwapi: Implement PathSearchAndQualify

Huw D M Davies h.davies1 at physics.ox.ac.uk
Fri Sep 24 07:41:05 CDT 2004


On Thu, Sep 23, 2004 at 12:56:16PM -0700, Alexandre Julliard wrote:
> I think you need to throw a SearchPath() in there too. If you try with
> a simple file name without directory you'll see that the test fails.

Yup, I guess the clue was in the function name<g>
Here's a corrected version with a few more tests.

     Huw Davies <huw at codeweavers.com>
     Implement PathSearchAndQualify
-- 
Huw Davies
huw at codeweavers.com
Index: dlls/shlwapi/path.c
===================================================================
RCS file: /home/wine/wine/dlls/shlwapi/path.c,v
retrieving revision 1.46
diff -u -r1.46 path.c
--- dlls/shlwapi/path.c	10 Sep 2004 21:12:11 -0000	1.46
+++ dlls/shlwapi/path.c	24 Sep 2004 12:34:17 -0000
@@ -3115,8 +3115,11 @@
  */
 BOOL WINAPI PathSearchAndQualifyA(LPCSTR lpszPath, LPSTR lpszBuf, UINT cchBuf)
 {
-  FIXME("(%s,%p,0x%08x)-stub\n", debugstr_a(lpszPath), lpszBuf, cchBuf);
-  return FALSE;
+    TRACE("(%s,%p,0x%08x)\n", debugstr_a(lpszPath), lpszBuf, cchBuf);
+
+    if(SearchPathA(NULL, lpszPath, NULL, cchBuf, lpszBuf, NULL))
+        return TRUE;
+    return !!GetFullPathNameA(lpszPath, cchBuf, lpszBuf, NULL);
 }
 
 /*************************************************************************
@@ -3126,8 +3129,11 @@
  */
 BOOL WINAPI PathSearchAndQualifyW(LPCWSTR lpszPath, LPWSTR lpszBuf, UINT cchBuf)
 {
-  FIXME("(%s,%p,0x%08x)-stub\n", debugstr_w(lpszPath), lpszBuf, cchBuf);
-  return FALSE;
+    TRACE("(%s,%p,0x%08x)\n", debugstr_w(lpszPath), lpszBuf, cchBuf);
+
+    if(SearchPathW(NULL, lpszPath, NULL, cchBuf, lpszBuf, NULL))
+        return TRUE;
+    return !!GetFullPathNameW(lpszPath, cchBuf, lpszBuf, NULL);
 }
 
 /*************************************************************************
Index: dlls/shlwapi/tests/path.c
===================================================================
RCS file: /home/wine/wine/dlls/shlwapi/tests/path.c,v
retrieving revision 1.10
diff -u -r1.10 path.c
--- dlls/shlwapi/tests/path.c	9 Aug 2004 18:52:18 -0000	1.10
+++ dlls/shlwapi/tests/path.c	24 Sep 2004 12:34:17 -0000
@@ -293,6 +293,56 @@
     }
 }
 
+static void test_PathSearchAndQualify(void)
+{
+    WCHAR path1[] = {'c',':','\\','f','o','o',0};
+    WCHAR expect1[] = {'c',':','\\','f','o','o',0};
+    WCHAR path2[] = {'c',':','f','o','o',0};
+    WCHAR c_drive[] = {'c',':',0}; 
+    WCHAR foo[] = {'f','o','o',0}; 
+    WCHAR path3[] = {'\\','f','o','o',0};
+    WCHAR winini[] = {'w','i','n','.','i','n','i',0};
+    WCHAR out[MAX_PATH];
+    WCHAR cur_dir[MAX_PATH];
+    WCHAR dot[] = {'.',0};
+
+    /* c:\foo */
+    ok(PathSearchAndQualifyW(path1, out, MAX_PATH) != 0,
+       "PathSearchAndQualify rets 0\n");
+    ok(!lstrcmpiW(out, expect1), "strings don't match\n");
+
+    /* c:foo */
+    ok(PathSearchAndQualifyW(path2, out, MAX_PATH) != 0,
+       "PathSearchAndQualify rets 0\n");
+    GetFullPathNameW(c_drive, MAX_PATH, cur_dir, NULL);
+    PathAddBackslashW(cur_dir);
+    strcatW(cur_dir, foo);
+    ok(!lstrcmpiW(out, cur_dir), "strings don't match\n");    
+
+    /* foo */
+    ok(PathSearchAndQualifyW(foo, out, MAX_PATH) != 0,
+       "PathSearchAndQualify rets 0\n");
+    GetFullPathNameW(dot, MAX_PATH, cur_dir, NULL);
+    PathAddBackslashW(cur_dir);
+    strcatW(cur_dir, foo);
+    ok(!lstrcmpiW(out, cur_dir), "strings don't match\n");    
+
+    /* \foo */
+    ok(PathSearchAndQualifyW(path3, out, MAX_PATH) != 0,
+       "PathSearchAndQualify rets 0\n");
+    GetFullPathNameW(dot, MAX_PATH, cur_dir, NULL);
+    strcpyW(cur_dir + 2, path3);
+    ok(!lstrcmpiW(out, cur_dir), "strings don't match\n");
+
+    /* win.ini */
+    ok(PathSearchAndQualifyW(winini, out, MAX_PATH) != 0,
+       "PathSearchAndQualify rets 0\n");
+    if(!SearchPathW(NULL, winini, NULL, MAX_PATH, cur_dir, NULL))
+        GetFullPathNameW(winini, MAX_PATH, cur_dir, NULL);
+    ok(!lstrcmpiW(out, cur_dir), "strings don't match\n");
+
+}
+
 START_TEST(path)
 {
   test_UrlHash();
@@ -300,4 +350,6 @@
   test_UrlCanonicalize();
   test_UrlEscape();
   test_UrlCombine();
+
+  test_PathSearchAndQualify();
 }



More information about the wine-patches mailing list