wine_get_unix_file_name
Eric Pouech
pouech-eric at wanadoo.fr
Sat Jan 3 07:42:15 CST 2004
resending:
- the dos filename (as first parameter of wine_get_unix_filename) is now
in unicode
A+
-------------- next part --------------
Name: wgufn
ChangeLog: made wine_get_unix_file_name take a unicode string pointer
License: X11
GenDate: 2004/01/03 13:40:11 UTC
ModifiedFiles: dlls/gdi/printdrv.c dlls/kernel/kernel32.spec dlls/winedos/dosconf.c files/dos_fs.c include/winbase.h programs/winemenubuilder/winemenubuilder.c dlls/gdi/freetype.c programs/winedbg/gdbproxy.c programs/winepath/winepath.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/dlls/gdi/printdrv.c,v
retrieving revision 1.35
diff -u -u -r1.35 printdrv.c
--- dlls/gdi/printdrv.c 17 Nov 2003 20:31:30 -0000 1.35
+++ dlls/gdi/printdrv.c 1 Jan 2004 08:52:36 -0000
@@ -511,6 +511,7 @@
else
{
char buffer[MAX_PATH];
+ WCHAR psCmdPW[MAX_PATH];
TRACE("Just assume it's a file\n");
@@ -518,7 +519,8 @@
* The file name can be dos based, we have to find its
* Unix correspondant file name
*/
- wine_get_unix_file_name(psCmdP, buffer, sizeof(buffer));
+ MultiByteToWideChar(CP_ACP, 0, psCmdP, -1, psCmdPW, MAX_PATH);
+ wine_get_unix_file_name(psCmdPW, buffer, sizeof(buffer));
if ((fd = open(buffer, O_CREAT | O_TRUNC | O_WRONLY , 0600)) < 0)
{
Index: dlls/gdi/freetype.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/dlls/gdi/freetype.c,v
retrieving revision 1.48
diff -u -u -r1.48 freetype.c
--- dlls/gdi/freetype.c 15 Dec 2003 19:50:59 -0000 1.48
+++ dlls/gdi/freetype.c 3 Jan 2004 13:39:33 -0000
@@ -618,7 +618,7 @@
}
-static BOOL ReadFontDir(char *dirname)
+static BOOL ReadFontDir(const char *dirname)
{
DIR *dir;
struct dirent *dent;
@@ -724,17 +724,13 @@
{
if (ft_handle) /* do it only if we have freetype up and running */
{
- DWORD len = WideCharToMultiByte(CP_ACP, 0, file, -1, NULL, 0, NULL, NULL);
- LPSTR fileA = HeapAlloc(GetProcessHeap(), 0, len);
char unixname[MAX_PATH];
- WideCharToMultiByte(CP_ACP, 0, file, -1, fileA, len, NULL, NULL);
if(flags)
FIXME("Ignoring flags %lx\n", flags);
- if(wine_get_unix_file_name(fileA, unixname, sizeof(unixname)))
+ if(wine_get_unix_file_name(file, unixname, sizeof(unixname)))
AddFontFileToList(unixname, NULL);
- HeapFree(GetProcessHeap(), 0, fileA);
}
return 1;
}
@@ -756,11 +752,11 @@
*/
BOOL WineEngInit(void)
{
+ static const WCHAR fontsW[] = {'\\','F','o','n','t','s','\0'};
HKEY hkey;
DWORD valuelen, datalen, i = 0, type, dlen, vlen;
- LPSTR value;
LPVOID data;
- char windowsdir[MAX_PATH];
+ WCHAR windowsdir[MAX_PATH];
char unixname[MAX_PATH];
TRACE("\n");
@@ -826,8 +822,8 @@
TRACE("FreeType version is %d.%d.%d\n",FT_Version.major,FT_Version.minor,FT_Version.patch);
/* load in the fonts from %WINDOWSDIR%\\Fonts first of all */
- GetWindowsDirectoryA(windowsdir, sizeof(windowsdir));
- strcat(windowsdir, "\\Fonts");
+ GetWindowsDirectoryW(windowsdir, sizeof(windowsdir) / sizeof(WCHAR));
+ strcatW(windowsdir, fontsW);
if(wine_get_unix_file_name(windowsdir, unixname, sizeof(unixname)))
ReadFontDir(unixname);
@@ -837,19 +833,20 @@
if(RegOpenKeyA(HKEY_LOCAL_MACHINE,
"Software\\Microsoft\\Windows\\CurrentVersion\\Fonts",
&hkey) == ERROR_SUCCESS) {
- RegQueryInfoKeyA(hkey, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ LPWSTR valueW;
+ RegQueryInfoKeyW(hkey, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
&valuelen, &datalen, NULL, NULL);
valuelen++; /* returned value doesn't include room for '\0' */
- value = HeapAlloc(GetProcessHeap(), 0, valuelen);
- data = HeapAlloc(GetProcessHeap(), 0, datalen);
+ valueW = HeapAlloc(GetProcessHeap(), 0, valuelen * sizeof(WCHAR));
+ data = HeapAlloc(GetProcessHeap(), 0, datalen * sizeof(WCHAR));
- dlen = datalen;
+ dlen = datalen * sizeof(WCHAR);
vlen = valuelen;
- while(RegEnumValueA(hkey, i++, value, &vlen, NULL, &type, data,
+ while(RegEnumValueW(hkey, i++, valueW, &vlen, NULL, &type, data,
&dlen) == ERROR_SUCCESS) {
- if(((LPSTR)data)[0] && ((LPSTR)data)[1] == ':')
- if(wine_get_unix_file_name((LPSTR)data, unixname, sizeof(unixname)))
+ if(((LPWSTR)data)[0] && ((LPWSTR)data)[1] == ':')
+ if(wine_get_unix_file_name((LPWSTR)data, unixname, sizeof(unixname)))
AddFontFileToList(unixname, NULL);
/* reset dlen and vlen */
@@ -857,7 +854,7 @@
vlen = valuelen;
}
HeapFree(GetProcessHeap(), 0, data);
- HeapFree(GetProcessHeap(), 0, value);
+ HeapFree(GetProcessHeap(), 0, valueW);
RegCloseKey(hkey);
}
@@ -867,7 +864,7 @@
if(RegOpenKeyA(HKEY_LOCAL_MACHINE,
"Software\\Wine\\Wine\\Config\\FontDirs",
&hkey) == ERROR_SUCCESS) {
-
+ LPSTR value;
RegQueryInfoKeyA(hkey, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
&valuelen, &datalen, NULL, NULL);
Index: dlls/kernel/kernel32.spec
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/dlls/kernel/kernel32.spec,v
retrieving revision 1.120
diff -u -u -r1.120 kernel32.spec
--- dlls/kernel/kernel32.spec 25 Nov 2003 01:51:07 -0000 1.120
+++ dlls/kernel/kernel32.spec 1 Jan 2004 08:53:34 -0000
@@ -1132,7 +1132,7 @@
@ varargs __wine_call_from_16_regs()
# Unix files
-@ stdcall wine_get_unix_file_name(str ptr long)
+@ stdcall wine_get_unix_file_name(wstr ptr long)
# Init code
@ cdecl __wine_kernel_init()
Index: dlls/winedos/dosconf.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/dlls/winedos/dosconf.c,v
retrieving revision 1.3
diff -u -u -r1.3 dosconf.c
--- dlls/winedos/dosconf.c 17 Nov 2003 20:31:30 -0000 1.3
+++ dlls/winedos/dosconf.c 1 Jan 2004 08:53:36 -0000
@@ -456,13 +456,14 @@
DOSCONF *DOSCONF_GetConfig(void)
{
HKEY hkey;
- CHAR filename[MAX_PATH];
+ WCHAR filename[MAX_PATH];
+ static const WCHAR configW[] = {'c','o','n','f','i','g','.','s','y','s',0};
if (DOSCONF_loaded)
return &DOSCONF_config;
/* default value */
- strcpy( filename, "*" );
+ filename[0] = '*'; filename[1] = '\0';
if (!RegOpenKeyA(HKEY_LOCAL_MACHINE,
"Software\\Wine\\Wine\\Config\\wine",
@@ -471,11 +472,11 @@
DWORD type;
DWORD count = sizeof(filename);
- RegQueryValueExA(hkey, "config.sys", 0, &type, filename, &count);
+ RegQueryValueExW(hkey, configW, 0, &type, (LPBYTE)filename, &count);
RegCloseKey(hkey);
}
- if (strcmp(filename, "*") && *filename != '\0')
+ if ((filename[0] != '*' || filename[1] != '\0') && *filename != '\0')
{
CHAR fullname[MAX_PATH];
@@ -492,7 +493,7 @@
{
WARN( "Couldn't open config.sys file given as %s in"
" configuration file, section [wine]!\n",
- filename );
+ debugstr_w(filename) );
}
}
Index: files/dos_fs.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/files/dos_fs.c,v
retrieving revision 1.143
diff -u -u -r1.143 dos_fs.c
--- files/dos_fs.c 27 Nov 2003 00:59:36 -0000 1.143
+++ files/dos_fs.c 1 Jan 2004 08:53:51 -0000
@@ -1697,15 +1697,12 @@
* wine_get_unix_file_name (KERNEL32.@) Not a Windows API
*
* Return the full Unix file name for a given path.
- * FIXME: convert dos file name to unicode
*/
-BOOL WINAPI wine_get_unix_file_name( LPCSTR dos, LPSTR buffer, DWORD len )
+BOOL WINAPI wine_get_unix_file_name( LPCWSTR dosW, LPSTR buffer, DWORD len )
{
BOOL ret;
DOS_FULL_NAME path;
- WCHAR dosW[MAX_PATHNAME_LEN];
- MultiByteToWideChar(CP_ACP, 0, dos, -1, dosW, MAX_PATHNAME_LEN);
ret = DOSFS_GetFullName( dosW, FALSE, &path );
if (ret && len)
{
Index: include/winbase.h
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/include/winbase.h,v
retrieving revision 1.203
diff -u -u -r1.203 winbase.h
--- include/winbase.h 26 Nov 2003 04:11:56 -0000 1.203
+++ include/winbase.h 1 Jan 2004 08:54:13 -0000
@@ -1868,7 +1868,7 @@
/* Wine internal functions */
-BOOL WINAPI wine_get_unix_file_name( LPCSTR dos, LPSTR buffer, DWORD len );
+BOOL WINAPI wine_get_unix_file_name( LPCWSTR dos, LPSTR buffer, DWORD len );
/* a few optimizations for i386/gcc */
Index: programs/winemenubuilder/winemenubuilder.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/programs/winemenubuilder/winemenubuilder.c,v
retrieving revision 1.8
diff -u -u -r1.8 winemenubuilder.c
--- programs/winemenubuilder/winemenubuilder.c 8 Dec 2003 21:44:24 -0000 1.8
+++ programs/winemenubuilder/winemenubuilder.c 1 Jan 2004 08:54:37 -0000
@@ -325,9 +325,11 @@
/* get the Unix file name for a given path, allocating the string */
inline static char *get_unix_file_name( const char *dos )
{
+ WCHAR dosW[MAX_PATH];
char buffer[MAX_PATH], *ret;
- if (!wine_get_unix_file_name( dos, buffer, sizeof(buffer) )) return NULL;
+ MultiByteToWideChar(CP_ACP, 0, dos, -1, dosW, MAX_PATH);
+ if (!wine_get_unix_file_name( dosW, buffer, sizeof(buffer) )) return NULL;
ret = HeapAlloc( GetProcessHeap(), 0, lstrlenA( buffer ) + 1 );
lstrcpyA( ret, buffer );
return ret;
Index: programs/winepath/winepath.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/programs/winepath/winepath.c,v
retrieving revision 1.3
diff -u -u -r1.3 winepath.c
--- programs/winepath/winepath.c 11 May 2003 02:47:28 -0000 1.3
+++ programs/winepath/winepath.c 3 Jan 2004 13:31:51 -0000
@@ -36,7 +36,7 @@
/* Wine specific functions */
extern BOOL process_init(char *argv[]);
-typedef BOOL (WINAPI *wine_get_unix_file_name_t) ( LPCSTR dos, LPSTR buffer, DWORD len );
+typedef BOOL (WINAPI *wine_get_unix_file_name_t) ( LPCWSTR dos, LPSTR buffer, DWORD len );
/*
* handle an option
*/
@@ -161,7 +161,10 @@
printf("%s\n", path);
}
if (outputformats & UNIXFORMAT) {
- wine_get_unix_file_name_ptr(argv[i], path, sizeof(path));
+ WCHAR dosW[MAX_PATH];
+
+ MultiByteToWideChar(CP_ACP, 0, argv[i], -1, dosW, MAX_PATH);
+ wine_get_unix_file_name_ptr(dosW, path, sizeof(path));
printf("%s\n", path);
}
}
More information about the wine-patches
mailing list