cygpath and SHGetSpecialFolderPath

Corinna Vinschen vinschen@redhat.com
Thu Oct 16 15:54:00 GMT 2003


On Thu, Oct 16, 2003 at 10:36:30AM -0400, Christopher Faylor wrote:
> On Thu, Oct 16, 2003 at 04:11:29PM +0200, Corinna Vinschen wrote:
> >On Wed, Oct 15, 2003 at 10:43:50AM -0400, Larry Hall (RFK Partners, Inc) wrote:
> >> At 06:05 AM 10/15/2003, Corinna Vinschen you wrote:
> >> >While reading the thread about the cygpath problem, I looked into the
> >> >code and found that the code is using SHGetSpecialFolderLocation/
> >> >SHGetPathFromIDList.  The same output could be achieved by just calling
> >> >SHGetSpecialFolderPath.  The only problem with this function is that
> >> >it expects IE4 to be installed.  Is that a showstopper for using that
> >> >function in cygpath?  Does anybody honestly still use an IE < 4.0?
> >> 
> >> Doesn't setup already require at least IE 5? 
> >
> >No further discussion/opinion?  If nobody vehemently disagrees, I'll
> >change cygpath.cc within the next 24 hours.  Speak up now or shut up
> >forever ;-)
> 
> Do you have a patch available?

Yep.

Index: cygpath.cc
===================================================================
RCS file: /cvs/src/src/winsup/utils/cygpath.cc,v
retrieving revision 1.29
diff -u -p -r1.29 cygpath.cc
--- cygpath.cc	11 Sep 2003 02:56:40 -0000	1.29
+++ cygpath.cc	16 Oct 2003 15:54:07 -0000
@@ -9,6 +9,8 @@ details. */
 
 #define NOCOMATTRIBUTE
 
+#define _WIN32_IE 0x0400
+
 #include <shlobj.h>
 #include <stdio.h>
 #include <string.h>
@@ -330,7 +332,6 @@ dowin (char option)
   char *buf, buf1[MAX_PATH], buf2[MAX_PATH];
   DWORD len = MAX_PATH;
   WIN32_FIND_DATA w32_fd;
-  LPITEMIDLIST id;
   HINSTANCE k32;
   BOOL (*GetProfilesDirectoryAPtr) (LPSTR, LPDWORD) = 0;
 
@@ -338,27 +339,15 @@ dowin (char option)
   switch (option)
     {
     case 'D':
-      SHGetSpecialFolderLocation (NULL, allusers_flag ?
-	CSIDL_COMMON_DESKTOPDIRECTORY : CSIDL_DESKTOPDIRECTORY, &id);
-      SHGetPathFromIDList (id, buf);
-      /* This if clause is a Fix for Win95 without any "All Users" */
-      if (strlen (buf) == 0)
-	{
-	  SHGetSpecialFolderLocation (NULL, CSIDL_DESKTOPDIRECTORY, &id);
-	  SHGetPathFromIDList (id, buf);
-	}
+      if (!SHGetSpecialFolderPath (NULL, buf, allusers_flag ?
+	      CSIDL_COMMON_DESKTOPDIRECTORY : CSIDL_DESKTOPDIRECTORY, FALSE))
+	SHGetSpecialFolderPath (NULL, buf, CSIDL_DESKTOPDIRECTORY, FALSE);
       break;
 
     case 'P':
-      SHGetSpecialFolderLocation (NULL, allusers_flag ?
-	CSIDL_COMMON_PROGRAMS : CSIDL_PROGRAMS, &id);
-      SHGetPathFromIDList (id, buf);
-      /* This if clause is a Fix for Win95 without any "All Users" */
-      if (strlen (buf) == 0)
-	{
-	  SHGetSpecialFolderLocation (NULL, CSIDL_PROGRAMS, &id);
-	  SHGetPathFromIDList (id, buf);
-	}
+      if (!SHGetSpecialFolderPath (NULL, buf, allusers_flag ?
+			    CSIDL_COMMON_PROGRAMS : CSIDL_PROGRAMS, FALSE))
+	SHGetSpecialFolderPath (NULL, buf, CSIDL_PROGRAMS, FALSE);
       break;
 
     case 'H':

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.



More information about the Cygwin-developers mailing list