This is the mail archive of the
cygwin-apps@cygwin.com
mailing list for the Cygwin project.
Re: cygpath patch
- From: Joshua Franklin <joshuadfranklin at yahoo dot com>
- To: cygwin-apps at cygwin dot com
- Date: Mon, 14 Jan 2002 18:14:09 -0800 (PST)
- Subject: Re: cygpath patch
Well, I've attached the patch in case anyone is
interested. It changes cygpath.exe to include the
options:
-A|--allusers use `All Users' directories
instead of current user
-D|--desktop print `Desktop' directory
-P|--smprograms print Start Menu `Programs'
directory
and changed the version:
$./cygpath.exe -v
Cygwin path conversion version 1.2
Copyright 1998-2002 Red Hat, Inc.
Here's a changelog:
2001-01-14 Joshua Daniel Franklin
<joshuadfranklin@yahoo.com>
* cygpath.cc (main) Added options to show Desktop and
Start Menu's Programs directory for current user or
all
users
Sorry if my mail client messes up all the spacing.
__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/
--- cygpath.cc-orig Sat Jan 12 12:37:11 2002
+++ cygpath.cc Mon Jan 14 19:58:55 2002
@@ -1,5 +1,5 @@
/* cygpath.cc -- convert pathnames between Windows and Unix format
- Copyright 1998, 1999, 2000, 2001 Red Hat, Inc.
+ Copyright 1998-2002 Red Hat, Inc.
This file is part of Cygwin.
@@ -7,6 +7,9 @@ This software is a copyrighted work lice
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
+#define NOCOMATTRIBUTE
+
+#include <shlobj.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -22,7 +25,7 @@ static char *prog_name;
static char *file_arg;
static char *close_arg;
static int path_flag, unix_flag, windows_flag, absolute_flag;
-static int shortname_flag, ignore_flag;
+static int shortname_flag, ignore_flag, allusers_flag;
static struct option long_options[] =
{
@@ -39,6 +42,9 @@ static struct option long_options[] =
{ (char *) "windir", no_argument, NULL, 'W' },
{ (char *) "sysdir", no_argument, NULL, 'S' },
{ (char *) "ignore", no_argument, NULL, 'i' },
+ { (char *) "allusers", no_argument, NULL, 'A' },
+ { (char *) "desktop", no_argument, NULL, 'D' },
+ { (char *) "smprograms", no_argument, NULL, 'P' },
{ 0, no_argument, 0, 0 }
};
@@ -57,7 +63,10 @@ Usage: %s [-p|--path] (-u|--unix)|(-w|--
-S|--sysdir print `system' directory\n\
-u|--unix print Unix form of filename\n\
-w|--windows print Windows form of filename\n\
- -W|--windir print `Windows' directory\n",
+ -W|--windir print `Windows' directory\n\
+ -A|--allusers use `All Users' directories instead of current user\n\
+ -D|--desktop print `Desktop' directory\n\
+ -P|--smprograms print Start Menu `Programs' directory\n",
prog_name);
exit (ignore_flag ? 0 : status);
}
@@ -224,6 +233,7 @@ main (int argc, char **argv)
char *filename;
char buf[MAX_PATH], buf2[MAX_PATH];
WIN32_FIND_DATA w32_fd;
+ LPITEMIDLIST id;
prog_name = strrchr (argv[0], '/');
if (prog_name == NULL)
@@ -239,7 +249,7 @@ main (int argc, char **argv)
shortname_flag = 0;
ignore_flag = 0;
options_from_file_flag = 0;
- while ((c = getopt_long (argc, argv, (char *) "hac:f:opsSuvwWi", long_options, (int *) NULL))
+ while ((c = getopt_long (argc, argv, (char *) "hac:f:opsSuvwWiDPA", long_options, (int *) NULL))
!= EOF)
{
switch (c)
@@ -291,6 +301,46 @@ main (int argc, char **argv)
printf("%s\n", buf2);
exit(0);
+ case 'A':
+ allusers_flag = 1;
+ break;
+
+ case 'D':
+ if (!allusers_flag)
+ SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOPDIRECTORY,&id);
+ else
+ SHGetSpecialFolderLocation(NULL, CSIDL_COMMON_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 (!windows_flag)
+ cygwin_conv_to_posix_path(buf, buf2);
+ else
+ strcpy(buf2, buf);
+ printf("%s\n", buf2);
+ exit(0);
+
+ case 'P':
+ if (!allusers_flag)
+ SHGetSpecialFolderLocation(NULL, CSIDL_PROGRAMS, &id);
+ else
+ SHGetSpecialFolderLocation(NULL, CSIDL_COMMON_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 (!windows_flag)
+ cygwin_conv_to_posix_path(buf, buf2);
+ else
+ strcpy(buf2, buf);
+ printf("%s\n", buf2);
+ exit(0);
+
case 'S':
GetSystemDirectory(buf, MAX_PATH);
FindFirstFile(buf, &w32_fd);
@@ -311,8 +361,8 @@ main (int argc, char **argv)
break;
case 'v':
- printf ("Cygwin path conversion version 1.1\n");
- printf ("Copyright 1998,1999,2000,2001 Red Hat, Inc.\n");
+ printf ("Cygwin path conversion version 1.2\n");
+ printf ("Copyright 1998-2002 Red Hat, Inc.\n");
exit (0);
default:
@@ -385,6 +435,9 @@ main (int argc, char **argv)
case 'u':
windows_flag = 0;
unix_flag = 1;
+ break;
+ case 'A':
+ allusers_flag = 1;
break;
case 'p':
path_flag = 1;