[PATCH 1/2] winepath: add option to output paths in the current
Windows ANSI code page
Lei Zhang
thestig at google.com
Sun Jul 15 05:35:55 CDT 2007
Hi,
It's occasionally useful to be able to get the Windows path in the
Windows ANSI code page, so I added the --ansi command option to
winepath.
-------------- next part --------------
From 7dd1fc88d8b73a45fc77b17cfc99c3015a9ae9a5 Mon Sep 17 00:00:00 2001
From: Lei Zhang <thestig at google.com>
Date: Sun, 15 Jul 2007 03:01:58 -0700
Subject: [PATCH 1/2] winepath: add option to output paths in the current Windows ANSI code page
---
programs/winepath/winepath.c | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/programs/winepath/winepath.c b/programs/winepath/winepath.c
index 7179214..d7605a8 100644
--- a/programs/winepath/winepath.c
+++ b/programs/winepath/winepath.c
@@ -34,7 +34,8 @@ enum {
SHORTFORMAT = 1,
LONGFORMAT = 2,
UNIXFORMAT = 4,
- WINDOWSFORMAT = 8
+ WINDOWSFORMAT = 8,
+ ANSIFORMAT = 16,
};
static const char progname[] = "winepath";
@@ -53,6 +54,8 @@ static int option(int shortopt, const WC
" directory to the long format\n"
" -s, --short converts the long Windows path of an existing file or\n"
" directory to the short format\n"
+ " -a, --ansi output a Windows path in the current Windows ANSI code\n"
+ " page\n"
" -h, --help output this help message and exit\n"
" -v, --version output version information and exit\n"
"\n"
@@ -76,6 +79,8 @@ static int option(int shortopt, const WC
return UNIXFORMAT;
case 'w':
return WINDOWSFORMAT;
+ case 'a':
+ return ANSIFORMAT;
}
fprintf(stderr, "%s: invalid option ", progname);
@@ -96,10 +101,11 @@ static int parse_options(const WCHAR *ar
static const WCHAR shortW[] = { 's','h','o','r','t',0 };
static const WCHAR unixW[] = { 'u','n','i','x',0 };
static const WCHAR windowsW[] = { 'w','i','n','d','o','w','s',0 };
+ static const WCHAR ansiW[] = { 'a','n','s','i',0 };
static const WCHAR helpW[] = { 'h','e','l','p',0 };
static const WCHAR versionW[] = { 'v','e','r','s','i','o','n',0 };
static const WCHAR nullW[] = { 0 };
- static const WCHAR *longopts[] = { longW, shortW, unixW, windowsW, helpW, versionW, nullW };
+ static const WCHAR *longopts[] = { longW, shortW, unixW, windowsW, ansiW, helpW, versionW, nullW };
int outputformats = 0;
int done = 0;
int i, j;
@@ -144,6 +150,7 @@ int wmain(int argc, const WCHAR *argv[])
{
LPSTR (*wine_get_unix_file_name_ptr)(LPCWSTR) = NULL;
LPWSTR (*wine_get_dos_file_name_ptr)(LPCSTR) = NULL;
+ UINT code_page = CP_UNIXCP;
WCHAR dos_pathW[MAX_PATH];
char path[MAX_PATH];
int outputformats;
@@ -175,17 +182,20 @@ int wmain(int argc, const WCHAR *argv[])
}
}
+ if (outputformats & ANSIFORMAT)
+ code_page = CP_ACP;
+
for (i = 1; argv[i]; i++)
{
*path='\0';
if (outputformats & LONGFORMAT) {
if (GetLongPathNameW(argv[i], dos_pathW, MAX_PATH))
- WideCharToMultiByte(CP_UNIXCP, 0, dos_pathW, -1, path, MAX_PATH, NULL, NULL);
+ WideCharToMultiByte(code_page, 0, dos_pathW, -1, path, MAX_PATH, NULL, NULL);
printf("%s\n", path);
}
if (outputformats & SHORTFORMAT) {
if (GetShortPathNameW(argv[i], dos_pathW, MAX_PATH))
- WideCharToMultiByte(CP_UNIXCP, 0, dos_pathW, -1, path, MAX_PATH, NULL, NULL);
+ WideCharToMultiByte(code_page, 0, dos_pathW, -1, path, MAX_PATH, NULL, NULL);
printf("%s\n", path);
}
if (outputformats & UNIXFORMAT) {
@@ -256,7 +266,7 @@ int wmain(int argc, const WCHAR *argv[])
if ((windows_name = wine_get_dos_file_name_ptr(unix_name)))
{
- WideCharToMultiByte(CP_UNIXCP, 0, windows_name, -1, path, MAX_PATH, NULL, NULL);
+ WideCharToMultiByte(code_page, 0, windows_name, -1, path, MAX_PATH, NULL, NULL);
printf("%s\n", path);
HeapFree( GetProcessHeap(), 0, windows_name );
}
--
1.4.1
More information about the wine-patches
mailing list