Moved wine_get_unix_file_name implementation to ntdll, and changed it
to return an allocated buffer instead of a fixed size one.
diff --git a/dlls/gdi/freetype.c b/dlls/gdi/freetype.c
index be2bf17..b6b1798 100644
--- a/dlls/gdi/freetype.c
+++ b/dlls/gdi/freetype.c
@@ -851,13 +851,16 @@
{
if (ft_handle) /* do it only if we have freetype up and running */
{
- char unixname[MAX_PATH];
+ char *unixname;
if(flags)
FIXME("Ignoring flags %lx\n", flags);
- if(wine_get_unix_file_name(file, unixname, sizeof(unixname)))
+ if((unixname = wine_get_unix_file_name(file)))
+ {
AddFontFileToList(unixname, NULL, FALSE);
+ HeapFree(GetProcessHeap(), 0, unixname);
+ }
}
return 1;
}
@@ -884,7 +887,7 @@
DWORD valuelen, datalen, i = 0, type, dlen, vlen;
LPVOID data;
WCHAR windowsdir[MAX_PATH];
- char unixname[MAX_PATH];
+ char *unixname;
HANDLE font_mutex;
TRACE("\n");
@@ -958,8 +961,11 @@
/* load in the fonts from %WINDOWSDIR%\\Fonts first of all */
GetWindowsDirectoryW(windowsdir, sizeof(windowsdir) / sizeof(WCHAR));
strcatW(windowsdir, fontsW);
- if(wine_get_unix_file_name(windowsdir, unixname, sizeof(unixname)))
+ if((unixname = wine_get_unix_file_name(windowsdir)))
+ {
ReadFontDir(unixname, FALSE);
+ HeapFree(GetProcessHeap(), 0, unixname);
+ }
/* now look under HKLM\Software\Microsoft\Windows[ NT]\CurrentVersion\Fonts
for any fonts not installed in %WINDOWSDIR%\Fonts. They will have their
@@ -981,8 +987,11 @@
while(RegEnumValueW(hkey, i++, valueW, &vlen, NULL, &type, data,
&dlen) == ERROR_SUCCESS) {
if(((LPWSTR)data)[0] && ((LPWSTR)data)[1] == ':')
- if(wine_get_unix_file_name((LPWSTR)data, unixname, sizeof(unixname)))
+ if((unixname = wine_get_unix_file_name((LPWSTR)data)))
+ {
AddFontFileToList(unixname, NULL, FALSE);
+ HeapFree(GetProcessHeap(), 0, unixname);
+ }
/* reset dlen and vlen */
dlen = datalen;
vlen = valuelen;
diff --git a/dlls/gdi/printdrv.c b/dlls/gdi/printdrv.c
index 73e5f44..8543d6e 100644
--- a/dlls/gdi/printdrv.c
+++ b/dlls/gdi/printdrv.c
@@ -511,7 +511,7 @@
}
else
{
- char buffer[MAX_PATH];
+ char *buffer;
WCHAR psCmdPW[MAX_PATH];
TRACE("Just assume it's a file\n");
@@ -521,12 +521,14 @@
* Unix correspondant file name
*/
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)
+ if ((buffer = wine_get_unix_file_name(psCmdPW)))
{
- ERR("Failed to create spool file '%s' ('%s'). (error %s)\n",
- buffer, psCmdP, strerror(errno));
+ if ((fd = open(buffer, O_CREAT | O_TRUNC | O_WRONLY , 0600)) < 0)
+ {
+ ERR("Failed to create spool file '%s' ('%s'). (error %s)\n",
+ buffer, psCmdP, strerror(errno));
+ }
+ HeapFree(GetProcessHeap(), 0, buffer);
}
}
return fd;
diff --git a/dlls/kernel/kernel32.spec b/dlls/kernel/kernel32.spec
index ea9939c..973d91b 100644
--- a/dlls/kernel/kernel32.spec
+++ b/dlls/kernel/kernel32.spec
@@ -1154,7 +1154,7 @@
@ varargs __wine_call_from_16_regs()
# Unix files
-@ stdcall wine_get_unix_file_name(wstr ptr long)
+@ cdecl wine_get_unix_file_name(wstr) ntdll.wine_get_unix_file_name
# Init code
@ cdecl __wine_kernel_init()
diff --git a/dlls/kernel/process.c b/dlls/kernel/process.c
index 67984c8..a41b74f 100644
--- a/dlls/kernel/process.c
+++ b/dlls/kernel/process.c
@@ -893,13 +893,13 @@
ExitProcess(1);
case BINARY_UNIX_LIB:
{
- DOS_FULL_NAME full_name;
+ char *unix_name;
TRACE( "starting Winelib app %s\n", debugstr_w(main_exe_name) );
CloseHandle( main_exe_file );
main_exe_file = 0;
- if (DOSFS_GetFullName( main_exe_name, TRUE, &full_name ) &&
- wine_dlopen( full_name.long_name, RTLD_NOW, error, sizeof(error) ))
+ if ((unix_name = wine_get_unix_file_name( main_exe_name )) &&
+ wine_dlopen( unix_name, RTLD_NOW, error, sizeof(error) ))
{
static const WCHAR soW[] = {'.','s','o',0};
if ((p = strrchrW( main_exe_name, '.' )) && !strcmpW( p, soW ))
@@ -908,6 +908,7 @@
/* update the unicode string */
RtlInitUnicodeString( &peb->ProcessParameters->ImagePathName, main_exe_name );
}
+ HeapFree( GetProcessHeap(), 0, unix_name );
goto found;
}
MESSAGE( "wine: could not load %s: %s\n", debugstr_w(main_exe_name), error );
@@ -1606,8 +1607,7 @@
{
BOOL retv = FALSE;
HANDLE hFile = 0;
- const char *unixdir = NULL;
- DOS_FULL_NAME full_dir;
+ char *unixdir = NULL;
WCHAR name[MAX_PATH];
WCHAR *tidy_cmdline, *p, *envW = env;
@@ -1629,15 +1629,12 @@
if (cur_dir)
{
- if (DOSFS_GetFullName( cur_dir, TRUE, &full_dir )) unixdir = full_dir.long_name;
+ unixdir = wine_get_unix_file_name( cur_dir );
}
else
{
WCHAR buf[MAX_PATH];
- if (GetCurrentDirectoryW(MAX_PATH, buf))
- {
- if (DOSFS_GetFullName( buf, TRUE, &full_dir )) unixdir = full_dir.long_name;
- }
+ if (GetCurrentDirectoryW(MAX_PATH, buf)) unixdir = wine_get_unix_file_name( buf );
}
if (env && !(flags & CREATE_UNICODE_ENVIRONMENT)) /* convert environment to unicode */
@@ -1715,12 +1712,15 @@
case BINARY_UNIX_EXE:
{
/* unknown file, try as unix executable */
- DOS_FULL_NAME full_name;
+ char *unix_name;
TRACE( "starting %s as Unix binary\n", debugstr_w(name) );
- if (DOSFS_GetFullName( name, TRUE, &full_name ))
- retv = (fork_and_exec( full_name.long_name, tidy_cmdline, envW, unixdir ) != -1);
+ if ((unix_name = wine_get_unix_file_name( name )))
+ {
+ retv = (fork_and_exec( unix_name, tidy_cmdline, envW, unixdir ) != -1);
+ HeapFree( GetProcessHeap(), 0, unix_name );
+ }
}
break;
}
@@ -1729,6 +1729,7 @@
done:
if (tidy_cmdline != cmd_line) HeapFree( GetProcessHeap(), 0, tidy_cmdline );
if (envW != env) HeapFree( GetProcessHeap(), 0, envW );
+ if (unixdir) HeapFree( GetProcessHeap(), 0, unixdir );
return retv;
}
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index 0a7a53b..8caa4b3 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -915,6 +915,26 @@
}
+/***********************************************************************
+ * wine_get_unix_file_name (NTDLL.@) Not a Windows API
+ *
+ * Return the full Unix file name for a given path.
+ * Returned buffer must be freed by caller.
+ */
+char *wine_get_unix_file_name( LPCWSTR dosW )
+{
+ UNICODE_STRING nt_name;
+ ANSI_STRING unix_name;
+ NTSTATUS status;
+
+ if (!RtlDosPathNameToNtPathName_U( dosW, &nt_name, NULL, NULL )) return NULL;
+ status = DIR_nt_to_unix( &nt_name, &unix_name, FALSE, FALSE );
+ RtlFreeUnicodeString( &nt_name );
+ if (status) return NULL;
+ return unix_name.Buffer;
+}
+
+
/******************************************************************
* RtlDoesFileExists_U (NTDLL.@)
*/
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index f4192f2..5cced80 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -1123,6 +1123,9 @@
# signal handling
@ cdecl __wine_set_signal_handler(long ptr)
+# Filesystem
+@ cdecl wine_get_unix_file_name(wstr)
+
################################################################
# Wine dll separation hacks, these will go away, don't use them
#
diff --git a/dlls/winedos/dosconf.c b/dlls/winedos/dosconf.c
index d3ce816..a968baa 100644
--- a/dlls/winedos/dosconf.c
+++ b/dlls/winedos/dosconf.c
@@ -478,10 +478,13 @@
if ((filename[0] != '*' || filename[1] != '\0') && *filename != '\0')
{
- CHAR fullname[MAX_PATH];
+ char *fullname;
- if (wine_get_unix_file_name(filename, fullname, sizeof(fullname)))
+ if ((fullname = wine_get_unix_file_name(filename)))
+ {
DOSCONF_fd = fopen(fullname, "r");
+ HeapFree( GetProcessHeap(), 0, fullname );
+ }
if (DOSCONF_fd)
{