[SHLWAPI] PathSearchAndQualify function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patches add an incomplete support for PathSearchAndQualify
function.
MSDN Online seems not provide important informations about it, but with
trivial tests, it seems to convert a relative path to an absolute one,
without checking if it's correct, and exists.
It never returned 0 in my tests by now, but I haven't direct access to a
windows box, so the tests are not exaustive.
At least, my software seems to use it correctly.
-- 
Flameeyes <dgp85@users.sf.net>
Index: dlls/shlwapi/path.c
===================================================================
RCS file: /home/wine/wine/dlls/shlwapi/path.c,v
retrieving revision 1.35
diff -u -3 -r1.35 path.c
--- dlls/shlwapi/path.c	19 Jul 2003 03:12:36 -0000	1.35
+++ dlls/shlwapi/path.c	17 Aug 2003 17:38:56 -0000
@@ -3053,8 +3053,75 @@
  */
 BOOL WINAPI PathSearchAndQualifyA(LPCSTR lpszPath, LPSTR lpszBuf, UINT cchBuf)
 {
-  FIXME("(%s,%p,0x%08x)-stub\n", debugstr_a(lpszPath), lpszBuf, cchBuf);
-  return FALSE;
+  if (!lpszPath || !*lpszPath)
+    return FALSE;
+
+  LPSTR temp_in = malloc(sizeof(*lpszPath) * (lpszPath - StrChrA(lpszPath, '\0')));
+  StrCpyA(temp_in, lpszPath);
+  lpszPath = temp_in;
+  LPSTR temp_out = lpszBuf;
+  LPSTR temp_out2 = temp_out;
+  BOOL ret = TRUE;
+  
+  if (*temp_in == '\\' && temp_in[1] == '\\')
+  {
+    /* Network share: skip share server and mount point */
+    temp_in += 2;
+    if ((temp_in = StrChrA(temp_in, '\\')) &&
+        (temp_in = StrChrA(temp_in + 1, '\\')))
+      temp_in++;
+  }
+
+  /* Check x:\ */
+  if (temp_in[0] && temp_in[1] == ':' && temp_in[2] == '\\')
+    temp_in += 3;
+
+  if ( temp_in != lpszPath )
+  {
+    StrCpyNA(temp_out, lpszPath, (temp_in - lpszPath) +1);
+    temp_out += (temp_in - lpszPath);
+    temp_out2 = temp_out;
+    *temp_out = '\0';
+    lpszPath = temp_in;
+  } else {
+    FIXME("must prepend current path");
+  }
+
+  while(*temp_in)
+  {
+    if ( *temp_in == '.' )
+    {
+      if ( ! temp_in[1] )
+      { ret = TRUE; break; }
+
+      if ( temp_in[1] == '\\' ) { temp_in += 2; continue; }
+        
+      if ( temp_in[1] == '.' && temp_in[2] == '\\' )
+      {
+        if ( temp_out == temp_out2 ) { temp_in += 3; continue; }
+
+        temp_out = StrRChrA(temp_out, temp_out2, '\\');
+        *temp_out = '\0'; continue;
+      }
+    } //if ( *temp_in == '.' )
+
+    if ( StrChrA(temp_in, '\\') )
+    {
+      size_t len = (StrChrA(temp_in, '\\') - temp_in )+1;
+      StrCpyNA(temp_out, temp_in, len+1);
+      temp_out += len;
+      temp_in += len;
+      *temp_out = '\0'; continue;
+    } else {
+      StrCpyA(temp_out, temp_in);
+      break;
+    }
+  } // while
+
+  TRACE("(%s)\n", debugstr_a(lpszBuf));
+
+  free(temp_in);
+  return ret;
 }
 
 /*************************************************************************
@@ -3064,8 +3131,75 @@
  */
 BOOL WINAPI PathSearchAndQualifyW(LPCWSTR lpszPath, LPWSTR lpszBuf, UINT cchBuf)
 {
-  FIXME("(%s,%p,0x%08x)-stub\n", debugstr_w(lpszPath), lpszBuf, cchBuf);
-  return FALSE;
+  if (!lpszPath || !*lpszPath)
+    return FALSE;
+
+  LPWSTR temp_in = malloc(sizeof(*lpszPath) * (lpszPath - StrChrW(lpszPath, '\0')));
+  StrCpyW(temp_in, lpszPath);
+  lpszPath = temp_in;
+  LPWSTR temp_out = lpszBuf;
+  LPWSTR temp_out2 = temp_out;
+  BOOL ret = TRUE;
+  
+  if (*temp_in == '\\' && temp_in[1] == '\\')
+  {
+    /* Network share: skip share server and mount point */
+    temp_in += 2;
+    if ((temp_in = StrChrW(temp_in, '\\')) &&
+        (temp_in = StrChrW(temp_in + 1, '\\')))
+      temp_in++;
+  }
+
+  /* Check x:\ */
+  if (temp_in[0] && temp_in[1] == ':' && temp_in[2] == '\\')
+    temp_in += 3;
+
+  if ( temp_in != lpszPath )
+  {
+    StrCpyNW(temp_out, lpszPath, (temp_in - lpszPath) +1);
+    temp_out += (temp_in - lpszPath);
+    temp_out2 = temp_out;
+    *temp_out = '\0';
+    lpszPath = temp_in;
+  } else {
+    FIXME("must prepend current path");
+  }
+
+  while(*temp_in)
+  {
+    if ( *temp_in == '.' )
+    {
+      if ( ! temp_in[1] )
+      { ret = TRUE; break; }
+
+      if ( temp_in[1] == '\\' ) { temp_in += 2; continue; }
+        
+      if ( temp_in[1] == '.' && temp_in[2] == '\\' )
+      {
+        if ( temp_out == temp_out2 ) { temp_in += 3; continue; }
+
+        temp_out = StrRChrW(temp_out, temp_out2, '\\');
+        *temp_out = '\0'; continue;
+      }
+    } //if ( *temp_in == '.' )
+
+    if ( StrChrW(temp_in, '\\') )
+    {
+      size_t len = (StrChrW(temp_in, '\\') - temp_in )+1;
+      StrCpyNW(temp_out, temp_in, len+1);
+      temp_out += len;
+      temp_in += len;
+      *temp_out = '\0'; continue;
+    } else {
+      StrCpyW(temp_out, temp_in);
+      break;
+    }
+  } // while
+
+  TRACE("(%s)\n", debugstr_w(lpszBuf));
+
+  free(temp_in);
+  return ret;
 }
 
 /*************************************************************************

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux