kernel32: Explicitly treat the current working directory name as a unix one.
Dmitry Timoshkov
dmitry at codeweavers.com
Fri Dec 4 05:39:19 CST 2009
Ubuntu 9.10 sets PWD="//" once Wine changes its current working
directory to '/', and Wine starts to treat it as an UNC name, which
leads to impossibility to set starting directory to '/'. This patch
adds a workaround to this Ubuntu bug.
---
dlls/kernel32/process.c | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
index 83d3f6c..08ac255 100644
--- a/dlls/kernel32/process.c
+++ b/dlls/kernel32/process.c
@@ -829,14 +829,16 @@ static void init_current_directory( CURDIR *cur_dir )
if (pwd)
{
- WCHAR *dirW;
- int lenW = MultiByteToWideChar( CP_UNIXCP, 0, pwd, -1, NULL, 0 );
- if ((dirW = HeapAlloc( GetProcessHeap(), 0, lenW * sizeof(WCHAR) )))
+ ANSI_STRING unix_name;
+ UNICODE_STRING nt_name;
+ RtlInitAnsiString( &unix_name, pwd );
+ if (!wine_unix_to_nt_file_name( &unix_name, &nt_name ))
{
- MultiByteToWideChar( CP_UNIXCP, 0, pwd, -1, dirW, lenW );
- RtlInitUnicodeString( &dir_str, dirW );
- RtlSetCurrentDirectory_U( &dir_str );
- RtlFreeUnicodeString( &dir_str );
+ UNICODE_STRING dos_path;
+ /* skip the \??\ prefix, nt_name is 0 terminated */
+ RtlInitUnicodeString( &dos_path, nt_name.Buffer + 4 );
+ RtlSetCurrentDirectory_U( &dos_path );
+ RtlFreeUnicodeString( &nt_name );
}
}
--
1.6.4.2
More information about the wine-patches
mailing list