diff --git a/dlls/gdi/freetype.c b/dlls/gdi/freetype.c index be2bf175913..b6b179811ff 100644 --- a/dlls/gdi/freetype.c +++ b/dlls/gdi/freetype.c @@ -851,13 +851,16 @@ INT WineEngAddFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv) { 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 @@ BOOL WineEngInit(void) 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 @@ BOOL WineEngInit(void) /* 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 @@ BOOL WineEngInit(void) 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 73e5f44be99..8543d6e9b16 100644 --- a/dlls/gdi/printdrv.c +++ b/dlls/gdi/printdrv.c @@ -511,7 +511,7 @@ static int CreateSpoolFile(LPCSTR pszOutput) } else { - char buffer[MAX_PATH]; + char *buffer; WCHAR psCmdPW[MAX_PATH]; TRACE("Just assume it's a file\n"); @@ -521,12 +521,14 @@ static int CreateSpoolFile(LPCSTR pszOutput) * 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 ea9939c320e..973d91b1602 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 67984c8fa01..a41b74f6d06 100644 --- a/dlls/kernel/process.c +++ b/dlls/kernel/process.c @@ -893,13 +893,13 @@ void __wine_kernel_init(void) 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 @@ void __wine_kernel_init(void) /* 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 WINAPI CreateProcessW( LPCWSTR app_name, LPWSTR cmd_line, LPSECURITY_ATTRIB { 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 @@ BOOL WINAPI CreateProcessW( LPCWSTR app_name, LPWSTR cmd_line, LPSECURITY_ATTRIB 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 @@ BOOL WINAPI CreateProcessW( LPCWSTR app_name, LPWSTR cmd_line, LPSECURITY_ATTRIB 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 @@ BOOL WINAPI CreateProcessW( LPCWSTR app_name, LPWSTR cmd_line, LPSECURITY_ATTRIB 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 0a7a53b69fb..8caa4b35353 100644 --- a/dlls/ntdll/directory.c +++ b/dlls/ntdll/directory.c @@ -915,6 +915,26 @@ done: } +/*********************************************************************** + * 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 f4192f28031..5cced80f9d1 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 d3ce816d4b8..a968baa8b63 100644 --- a/dlls/winedos/dosconf.c +++ b/dlls/winedos/dosconf.c @@ -478,10 +478,13 @@ DOSCONF *DOSCONF_GetConfig(void) 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) { diff --git a/files/dos_fs.c b/files/dos_fs.c index af0e4047fa8..057ea2054de 100644 --- a/files/dos_fs.c +++ b/files/dos_fs.c @@ -848,26 +848,6 @@ BOOL DOSFS_GetFullName( LPCWSTR name, BOOL check_last, DOS_FULL_NAME *full ) } -/*********************************************************************** - * wine_get_unix_file_name (KERNEL32.@) Not a Windows API - * - * Return the full Unix file name for a given path. - */ -BOOL WINAPI wine_get_unix_file_name( LPCWSTR dosW, LPSTR buffer, DWORD len ) -{ - BOOL ret; - DOS_FULL_NAME path; - - ret = DOSFS_GetFullName( dosW, FALSE, &path ); - if (ret && len) - { - strncpy( buffer, path.long_name, len ); - buffer[len - 1] = 0; /* ensure 0 termination */ - } - return ret; -} - - /*********************************************************************** * MulDiv (KERNEL32.@) * RETURNS diff --git a/include/winbase.h b/include/winbase.h index 9c7fcc65c0d..50fb61b979b 100644 --- a/include/winbase.h +++ b/include/winbase.h @@ -1988,7 +1988,7 @@ VOID WINAPI _LeaveSysLevel(SYSLEVEL*); /* Wine internal functions */ -BOOL WINAPI wine_get_unix_file_name( LPCWSTR dos, LPSTR buffer, DWORD len ); +extern char *wine_get_unix_file_name( LPCWSTR dos ); /* a few optimizations for i386/gcc */ diff --git a/programs/winemenubuilder/winemenubuilder.c b/programs/winemenubuilder/winemenubuilder.c index 8d88ad4047c..2e683a7fa08 100644 --- a/programs/winemenubuilder/winemenubuilder.c +++ b/programs/winemenubuilder/winemenubuilder.c @@ -326,13 +326,9 @@ static BOOL ExtractFromEXEDLL(const char *szFileName, int nIndex, const char *sz inline static char *get_unix_file_name( const char *dos ) { WCHAR dosW[MAX_PATH]; - char buffer[MAX_PATH], *ret; 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; + return wine_get_unix_file_name( dosW ); } static int ExtractFromICO(const char *szFileName, const char *szXPMFileName) diff --git a/programs/winepath/winepath.c b/programs/winepath/winepath.c index 31cc8b24a93..a49f38c012b 100644 --- a/programs/winepath/winepath.c +++ b/programs/winepath/winepath.c @@ -36,7 +36,7 @@ static char *progname; /* Wine specific functions */ extern BOOL process_init(char *argv[]); -typedef BOOL (WINAPI *wine_get_unix_file_name_t) ( LPCWSTR dos, LPSTR buffer, DWORD len ); +typedef LPSTR (*wine_get_unix_file_name_t) ( LPCWSTR dos ); /* * handle an option */ @@ -162,10 +162,15 @@ int main(int argc, char *argv[]) } if (outputformats & UNIXFORMAT) { WCHAR dosW[MAX_PATH]; + char *unix_name; MultiByteToWideChar(CP_ACP, 0, argv[i], -1, dosW, MAX_PATH); - wine_get_unix_file_name_ptr(dosW, path, sizeof(path)); - printf("%s\n", path); + if ((unix_name = wine_get_unix_file_name_ptr(dosW))) + { + printf("%s\n", unix_name); + HeapFree( GetProcessHeap(), 0, unix_name ); + } + else printf( "\n" ); } }