mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-30 02:50:25 +08:00
* cygpath.cc (main): Add options to show Desktop and Start
Menu's Programs directory for current user or all users. Move bulk of DPWS options outside the getopt case statement. * utils.sgml: Update cygpath section for ADPWS options.
This commit is contained in:
parent
b2db0ebcfe
commit
3cdacffcb2
@ -1,3 +1,10 @@
|
||||
2001-01-16 Joshua Daniel Franklin <joshuadfranklin@yahoo.com>
|
||||
|
||||
* cygpath.cc (main): Add options to show Desktop and Start
|
||||
Menu's Programs directory for current user or all users.
|
||||
Move bulk of DPWS options outside the getopt case statement.
|
||||
* utils.sgml: Update cygpath section for ADPWS options.
|
||||
|
||||
2002-01-15 Joerg Schaible <joerg.schaible@gmx.de>
|
||||
|
||||
* cygpath.cc (doit): Empty file ignored using option -i.
|
||||
|
@ -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 licensed under the terms of the
|
||||
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, output_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 }
|
||||
};
|
||||
|
||||
@ -50,14 +56,18 @@ usage (FILE *stream, int status)
|
||||
Usage: %s [-p|--path] (-u|--unix)|(-w|--windows [-s|--short-name]) filename\n\
|
||||
-a|--absolute output absolute path\n\
|
||||
-c|--close handle close handle (for use in captured process)\n\
|
||||
-f|--file file read file for path information\n\
|
||||
-f|--file file read file for input path information\n\
|
||||
-i|--ignore ignore missing argument\n\
|
||||
-p|--path filename argument is a path\n\
|
||||
-s|--short-name print Windows short form of filename\n\
|
||||
-S|--sysdir print `system' directory\n\
|
||||
-u|--unix print Unix form of filename\n\
|
||||
-v|--version output version information and exit\n\
|
||||
-w|--windows print Windows form of filename\n\
|
||||
-W|--windir print `Windows' directory\n",
|
||||
-A|--allusers use `All Users' instead of current user for -D, -P\n\
|
||||
-D|--desktop output `Desktop' directory and exit\n\
|
||||
-P|--smprograms output Start Menu `Programs' directory and exit\n\
|
||||
-S|--sysdir output system directory and exit\n\
|
||||
-W|--windir output `Windows' directory and exit\n",
|
||||
prog_name);
|
||||
exit (ignore_flag ? 0 : status);
|
||||
}
|
||||
@ -224,11 +234,12 @@ doit (char *filename)
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
int c, o;
|
||||
int options_from_file_flag;
|
||||
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)
|
||||
@ -244,7 +255,9 @@ 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))
|
||||
allusers_flag = 0;
|
||||
output_flag = 0;
|
||||
while ((c = getopt_long (argc, argv, (char *) "hac:f:opsSuvwWiDPA", long_options, (int *) NULL))
|
||||
!= EOF)
|
||||
{
|
||||
switch (c)
|
||||
@ -287,25 +300,37 @@ main (int argc, char **argv)
|
||||
shortname_flag = 1;
|
||||
break;
|
||||
|
||||
case 'W':
|
||||
GetWindowsDirectory(buf, MAX_PATH);
|
||||
if (!windows_flag)
|
||||
cygwin_conv_to_posix_path(buf, buf2);
|
||||
else
|
||||
strcpy(buf2, buf);
|
||||
printf("%s\n", buf2);
|
||||
exit(0);
|
||||
case 'A':
|
||||
allusers_flag = 1;
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
if (output_flag)
|
||||
usage (stderr, 1);
|
||||
output_flag = 1;
|
||||
o = 'D';
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
if (output_flag)
|
||||
usage (stderr, 1);
|
||||
output_flag = 1;
|
||||
o = 'P';
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
GetSystemDirectory(buf, MAX_PATH);
|
||||
FindFirstFile(buf, &w32_fd);
|
||||
strcpy(strrchr(buf, '\\')+1, w32_fd.cFileName);
|
||||
if (!windows_flag)
|
||||
cygwin_conv_to_posix_path(buf, buf2);
|
||||
else
|
||||
strcpy(buf2, buf);
|
||||
printf("%s\n", buf2);
|
||||
exit(0);
|
||||
if (output_flag)
|
||||
usage (stderr, 1);
|
||||
output_flag = 1;
|
||||
o = 'S';
|
||||
break;
|
||||
|
||||
case 'W':
|
||||
if (output_flag)
|
||||
usage (stderr, 1);
|
||||
output_flag = 1;
|
||||
o = 'W';
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
ignore_flag = 1;
|
||||
@ -316,16 +341,81 @@ 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:
|
||||
usage (stderr, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (output_flag)
|
||||
{
|
||||
switch(o) {
|
||||
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);
|
||||
strcpy(strrchr(buf, '\\')+1, w32_fd.cFileName);
|
||||
if (!windows_flag)
|
||||
cygwin_conv_to_posix_path(buf, buf2);
|
||||
else
|
||||
strcpy(buf2, buf);
|
||||
printf("%s\n", buf2);
|
||||
exit(0);
|
||||
|
||||
case 'W':
|
||||
GetWindowsDirectory(buf, MAX_PATH);
|
||||
if (!windows_flag)
|
||||
cygwin_conv_to_posix_path(buf, buf2);
|
||||
else
|
||||
strcpy(buf2, buf);
|
||||
printf("%s\n", buf2);
|
||||
exit(0);
|
||||
|
||||
default:
|
||||
fprintf(stderr, "ERROR: main: switch(o)!\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (options_from_file_flag && !file_arg)
|
||||
usage (stderr, 1);
|
||||
|
||||
|
@ -70,20 +70,21 @@ or if you know what everything is already, just leave this out.</para>
|
||||
<sect2 id="cygpath"><title>cygpath</title>
|
||||
|
||||
<screen>
|
||||
Usage: cygpath [-p|--path] (-u|--unix)|(-w|--windows [-s|--short-name]) filename
|
||||
cygpath [-v|--version]
|
||||
cygpath [-W|--windir|-S|--sysdir]
|
||||
-a|--absolute output absolute path
|
||||
-c|--close handle close handle (for use in captured process)
|
||||
-f|--file file read file for path information
|
||||
-i|--ignore ignore missing filename argument
|
||||
-p|--path filename argument is a path
|
||||
-s|--short-name print Windows short form of filename
|
||||
-S|--sysdir print Windows system directory
|
||||
-u|--unix print UNIX form of filename
|
||||
-v|--version print program version
|
||||
-w|--windows print Windows form of filename
|
||||
-W|--windir print Windows directory
|
||||
Usage: cygpath.exe [-p|--path] (-u|--unix)|(-w|--windows [-s|--short-name]) filename
|
||||
-a|--absolute output absolute path
|
||||
-c|--close handle close handle (for use in captured process)
|
||||
-f|--file file read file for input path information
|
||||
-i|--ignore ignore missing argument
|
||||
-p|--path filename argument is a path
|
||||
-s|--short-name print Windows short form of filename
|
||||
-u|--unix print Unix form of filename
|
||||
-v|--version output version information and exit
|
||||
-w|--windows print Windows form of filename
|
||||
-A|--allusers use `All Users' instead of current user for -D, -P
|
||||
-D|--desktop output `Desktop' directory and exit
|
||||
-P|--smprograms output Start Menu `Programs' directory and exit
|
||||
-S|--sysdir output system directory and exit
|
||||
-W|--windir output `Windows' directory and exit
|
||||
</screen>
|
||||
|
||||
<para>The <command>cygpath</command> program is a utility that
|
||||
@ -124,6 +125,17 @@ done
|
||||
</screen>
|
||||
</example>
|
||||
|
||||
<para>The capital options
|
||||
<literal>-D</literal>, <literal>-P</literal>, <literal>-S</literal>, and
|
||||
<literal>-W</literal> output directories used by Windows that are not the
|
||||
same on all systems, for example <literal>-S</literal> might output
|
||||
C:\WINNT\SYSTEM32 or C:\WINDOWS\SYSTEM. The <literal>-A</literal> option
|
||||
forces use of the "All Users" directories instead of the current user
|
||||
for the <literal>-D</literal> and <literal>-P</literal> options.
|
||||
On Win9x systems with only a single user, <literal>-A</literal> has no
|
||||
effect; <literal>-D</literal> and <literal>-AD</literal> would have the
|
||||
same output.
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="kill"><title>kill</title>
|
||||
|
Loading…
x
Reference in New Issue
Block a user