delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-apps/2002/05/14/02:56:53

Mailing-List: contact cygwin-apps-help AT cygwin DOT com; run by ezmlm
Sender: cygwin-apps-owner AT cygwin DOT com
List-Subscribe: <mailto:cygwin-apps-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin-apps/>
List-Post: <mailto:cygwin-apps AT cygwin DOT com>
List-Help: <mailto:cygwin-apps-help AT cygwin DOT com>, <http://sources.redhat.com/lists.html#faqs>
Mail-Followup-To: cygwin-apps AT cygwin DOT com
Delivered-To: mailing list cygwin-apps AT cygwin DOT com
Message-ID: <1264BCF4F426D611B0B00050DA782A50014C2152@mail.gft.com>
From: =?iso-8859-1?Q?=22Schaible=2C_J=F6rg=22?= <Joerg DOT Schaible AT gft DOT com>
To: cygwin-apps <cygwin-apps AT cygwin DOT com>
Subject: [PATCH]: cygpath.cc
Date: Tue, 14 May 2002 08:55:37 +0200
MIME-Version: 1.0
Note-from-DJ: This may be spam

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01C1FB14.5A7C5560
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hello,

cygpath now supports an option -H that can be used to retrieve the =
Windows'
profile diretcory root. Mapping this directory to /home you can achieve =
a
Unix like schema /home/<username> and gain support for roaming =
profiles.
Additionally I've added the support for the short Windows path switch =
for
options DPSW and cleaned up the code by removing duplicated =
functionality.

Diffs against CVS version appended, ChangeLog below.

Regards,
J=F6rg


2002-05-14  Joerg Schaible <joerg DOT schaible AT gmx DOT de>

	* cygpath.cc (main): Add option H to show the Windows' profiles
	directory.  Support short names for options DPSW.  Clean up
	copied code lines.   =20
	* utils.sgml: Update cygpath section for H option and s support.


------_=_NextPart_000_01C1FB14.5A7C5560
Content-Type: application/octet-stream;
	name="cygpath.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="cygpath.diff"

--- cygpath.cc	2002-05-14 03:55:08.000000000 +0200=0A=
+++ cygpath.new	2002-05-14 03:53:08.000000000 +0200=0A=
@@ -46,6 +46,7 @@=0A=
   {(char *) "allusers", no_argument, NULL, 'A'},=0A=
   {(char *) "desktop", no_argument, NULL, 'D'},=0A=
   {(char *) "smprograms", no_argument, NULL, 'P'},=0A=
+  {(char *) "homeroot", no_argument, NULL, 'H'},=0A=
   {0, no_argument, 0, 0}=0A=
 };=0A=
 =0A=
@@ -66,6 +67,7 @@=0A=
   -w|--windows		print Windows form of filename\n\=0A=
   -A|--allusers		use `All Users' instead of current user for -D, =
-P\n\=0A=
   -D|--desktop		output `Desktop' directory and exit\n\=0A=
+  -H|--homeroot		output `Profiles' directory (home root) and =
exit\n\=0A=
   -P|--smprograms	output Start Menu `Programs' directory and =
exit\n\=0A=
   -S|--sysdir		output system directory and exit\n\=0A=
   -W|--windir		output `Windows' directory and exit\n", prog_name);=0A=
@@ -261,9 +263,6 @@=0A=
   int c, o =3D 0;=0A=
   int options_from_file_flag;=0A=
   char *filename;=0A=
-  char buf[MAX_PATH], buf2[MAX_PATH];=0A=
-  WIN32_FIND_DATA w32_fd;=0A=
-  LPITEMIDLIST id;=0A=
 =0A=
   prog_name =3D strrchr (argv[0], '/');=0A=
   if (prog_name =3D=3D NULL)=0A=
@@ -282,7 +281,7 @@=0A=
   allusers_flag =3D 0;=0A=
   output_flag =3D 0;=0A=
   while ((c =3D=0A=
-	  getopt_long (argc, argv, (char *) "hac:f:opsSuvwWiDPA",=0A=
+	  getopt_long (argc, argv, (char *) "hac:f:opsSuvwWiDPAH",=0A=
 		       long_options, (int *) NULL)) !=3D EOF)=0A=
     {=0A=
       switch (c)=0A=
@@ -330,31 +329,14 @@=0A=
 	  break;=0A=
 =0A=
 	case 'D':=0A=
-	  if (output_flag)=0A=
-	    usage (stderr, 1);=0A=
-	  output_flag =3D 1;=0A=
-	  o =3D 'D';=0A=
-	  break;=0A=
-=0A=
+	case 'H':=0A=
 	case 'P':=0A=
-	  if (output_flag)=0A=
-	    usage (stderr, 1);=0A=
-	  output_flag =3D 1;=0A=
-	  o =3D 'P';=0A=
-	  break;=0A=
-=0A=
 	case 'S':=0A=
-	  if (output_flag)=0A=
-	    usage (stderr, 1);=0A=
-	  output_flag =3D 1;=0A=
-	  o =3D 'S';=0A=
-	  break;=0A=
-=0A=
 	case 'W':=0A=
 	  if (output_flag)=0A=
 	    usage (stderr, 1);=0A=
 	  output_flag =3D 1;=0A=
-	  o =3D 'W';=0A=
+	  o =3D c;=0A=
 	  break;=0A=
 =0A=
 	case 'i':=0A=
@@ -378,6 +360,14 @@=0A=
 =0A=
   if (output_flag)=0A=
     {=0A=
+      char *buf, buf1[MAX_PATH], buf2[MAX_PATH];=0A=
+      DWORD len =3D MAX_PATH;=0A=
+      WIN32_FIND_DATA w32_fd;=0A=
+      LPITEMIDLIST id;=0A=
+      HINSTANCE hinst;=0A=
+      BOOL (*GetProfilesDirectoryAPtr) (LPSTR, LPDWORD) =3D 0;=0A=
+      =0A=
+      buf =3D buf1;=0A=
       switch (o)=0A=
 	{=0A=
 	case 'D':=0A=
@@ -393,12 +383,7 @@=0A=
 	      SHGetSpecialFolderLocation (NULL, CSIDL_DESKTOPDIRECTORY, =
&id);=0A=
 	      SHGetPathFromIDList (id, buf);=0A=
 	    }=0A=
-	  if (!windows_flag)=0A=
-	    cygwin_conv_to_posix_path (buf, buf2);=0A=
-	  else=0A=
-	    strcpy (buf2, buf);=0A=
-	  printf ("%s\n", buf2);=0A=
-	  exit (0);=0A=
+	  break;=0A=
 =0A=
 	case 'P':=0A=
 	  if (!allusers_flag)=0A=
@@ -412,36 +397,48 @@=0A=
 	      SHGetSpecialFolderLocation (NULL, CSIDL_PROGRAMS, &id);=0A=
 	      SHGetPathFromIDList (id, buf);=0A=
 	    }=0A=
-	  if (!windows_flag)=0A=
-	    cygwin_conv_to_posix_path (buf, buf2);=0A=
+	  break;=0A=
+=0A=
+	case 'H':=0A=
+	  hinst =3D LoadLibrary ("userenv");=0A=
+	  if (hinst)=0A=
+	    GetProfilesDirectoryAPtr =3D (BOOL (*) (LPSTR, LPDWORD))=0A=
+	      GetProcAddress (hinst, "GetProfilesDirectoryA");=0A=
+	  if (GetProfilesDirectoryAPtr)=0A=
+	    (*GetProfilesDirectoryAPtr) (buf, &len);=0A=
 	  else=0A=
-	    strcpy (buf2, buf);=0A=
-	  printf ("%s\n", buf2);=0A=
-	  exit (0);=0A=
+	    {=0A=
+	      GetWindowsDirectory (buf, MAX_PATH);=0A=
+	      strcat (buf, "\\Profiles");=0A=
+	    }=0A=
+	  break;=0A=
 =0A=
 	case 'S':=0A=
 	  GetSystemDirectory (buf, MAX_PATH);=0A=
 	  FindFirstFile (buf, &w32_fd);=0A=
 	  strcpy (strrchr (buf, '\\') + 1, w32_fd.cFileName);=0A=
-	  if (!windows_flag)=0A=
-	    cygwin_conv_to_posix_path (buf, buf2);=0A=
-	  else=0A=
-	    strcpy (buf2, buf);=0A=
-	  printf ("%s\n", buf2);=0A=
-	  exit (0);=0A=
+	  break;=0A=
 =0A=
 	case 'W':=0A=
 	  GetWindowsDirectory (buf, MAX_PATH);=0A=
-	  if (!windows_flag)=0A=
-	    cygwin_conv_to_posix_path (buf, buf2);=0A=
-	  else=0A=
-	    strcpy (buf2, buf);=0A=
-	  printf ("%s\n", buf2);=0A=
-	  exit (0);=0A=
+	  break;=0A=
 =0A=
 	default:=0A=
-	  fprintf (stderr, "ERROR: main: switch (o)!\n");=0A=
+    	  usage (stderr, 1);=0A=
 	}=0A=
+=0A=
+	if (!windows_flag)=0A=
+	  {=0A=
+	    cygwin_conv_to_posix_path (buf, buf2);=0A=
+	    buf =3D buf2;=0A=
+	  }=0A=
+	else=0A=
+	  {=0A=
+	    if (shortname_flag)=0A=
+	      buf =3D get_short_name (buf);=0A=
+	  }=0A=
+	printf ("%s\n", buf);=0A=
+	exit (0);=0A=
     }=0A=
 =0A=
   if (options_from_file_flag && !file_arg)=0A=

------_=_NextPart_000_01C1FB14.5A7C5560
Content-Type: application/octet-stream;
	name="utils.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="utils.diff"

--- utils.sgml	2002-05-13 07:25:14.000000000 +0200=0A=
+++ utils.new	2002-05-14 04:08:07.000000000 +0200=0A=
@@ -82,6 +82,7 @@=0A=
   -v|--version          output version information and exit=0A=
   -w|--windows          print Windows form of filename=0A=
   -A|--allusers         use `All Users' instead of current user for =
-D, -P=0A=
+  -H|--homeroot		output `Profiles' directory (home root) and =
exit\n\=0A=
   -D|--desktop          output `Desktop' directory and exit=0A=
   -P|--smprograms       output Start Menu `Programs' directory and =
exit=0A=
   -S|--sysdir           output system directory and exit=0A=
@@ -127,15 +128,18 @@=0A=
 </example>=0A=
 =0A=
 <para>The capital options =0A=
-<literal>-D</literal>, <literal>-P</literal>, <literal>-S</literal>, =
and=0A=
-<literal>-W</literal> output directories used by Windows that are not =
the=0A=
-same on all systems, for example <literal>-S</literal> might output =
=0A=
-C:\WINNT\SYSTEM32 or C:\WINDOWS\SYSTEM. The <literal>-A</literal> =
option=0A=
-forces use of the "All Users" directories instead of the current =
user=0A=
-for the <literal>-D</literal> and <literal>-P</literal> options.=0A=
+<literal>-D</literal>, <literal>-H</literal>, <literal>-P</literal>, =
=0A=
+<literal>-S</literal>, and <literal>-W</literal> output directories =
used =0A=
+by Windows that are not the same on all systems, for example =0A=
+<literal>-S</literal> might output C:\WINNT\SYSTEM32 or =
C:\WINDOWS\SYSTEM. =0A=
+The <literal>-A</literal> option forces use of the "All Users" =
directories =0A=
+instead of the current user for the <literal>-D</literal> and =0A=
+<literal>-P</literal> options. The <literal>-H</literal> shows the =
Windows'=0A=
+profiles directory that can be used as root of home.=0A=
 On Win9x systems with only a single user, <literal>-A</literal> has =
no=0A=
 effect; <literal>-D</literal> and <literal>-AD</literal> would have =
the=0A=
 same output.=0A=
+The <literal>-ws</literal> options can be combined with the capital =
options.=0A=
 =0A=
 </sect2>=0A=
 =0A=

------_=_NextPart_000_01C1FB14.5A7C5560--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019