[Wine-patches] [eterwine 2/2] Convert unix paths in kernel32.

Alexander Morozov amorozov на etersoft.ru
Ср Янв 12 15:45:00 MSK 2011


----------- следующая часть -----------
From b07ac35773cb67070f69442af4db0622cdae29b3 Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Wed, 12 Jan 2011 14:20:11 +0300
Subject: [eterwine 2/2] Convert unix paths in kernel32.

---
 dlls/kernel32/process.c  |   50 +++++++++++++++++++++++++++++++++++++++++++++-
 etersoft/scripts/wine.in |   17 +--------------
 2 files changed, 50 insertions(+), 17 deletions(-)

diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
index 4d73348..ab2606d 100644
--- a/dlls/kernel32/process.c
+++ b/dlls/kernel32/process.c
@@ -1132,6 +1132,51 @@ static void set_process_name( int argc, char *argv[] )
     }
 }
 
+static char **convert_unix_paths( char **argv )
+{
+    int ac, argc = 0;
+    char **ret;
+
+    while (argv[++argc]);
+    ret = RtlAllocateHeap( GetProcessHeap(), 0, (argc + 1) * sizeof(*argv) );
+
+    for (ac = 0; ac < argc; ++ac)
+    {
+        WCHAR *dos_path;
+        int fd, len;
+
+        fd = open( argv[ac], O_RDONLY );
+        if (fd < 0)
+        {
+            len = strlen(argv[ac]) + 1;
+            ret[ac] = RtlAllocateHeap( GetProcessHeap(), 0, len );
+            strcpy( ret[ac], argv[ac] );
+        }
+        else
+        {
+            close( fd );
+            dos_path = wine_get_dos_file_name( argv[ac] );
+            len = WideCharToMultiByte( CP_UNIXCP, 0, dos_path, -1, ret[ac], 0,
+                                       NULL, NULL );
+            ret[ac] = RtlAllocateHeap( GetProcessHeap(), 0, len );
+            WideCharToMultiByte( CP_UNIXCP, 0, dos_path, -1, ret[ac], len, NULL,
+                                 NULL );
+            RtlFreeHeap( GetProcessHeap(), 0, dos_path );
+        }
+    }
+    ret[ac] = NULL;
+
+    return ret;
+}
+
+static void free_converted_paths( char **argv )
+{
+    int ac;
+
+    for (ac = 0; argv[ac]; ++ac)
+        RtlFreeHeap( GetProcessHeap(), 0, argv[ac] );
+    RtlFreeHeap( GetProcessHeap(), 0, argv );
+}
 
 /***********************************************************************
  *           __wine_kernel_init
@@ -1149,6 +1194,7 @@ void CDECL __wine_kernel_init(void)
     HANDLE boot_events[2];
     BOOL got_environment = TRUE;
     BOOL got_current_dir = FALSE;
+    char **argv;
 
     /* Initialize everything */
 
@@ -1175,7 +1221,9 @@ void CDECL __wine_kernel_init(void)
     init_current_directory( &params->CurrentDirectory, &got_current_dir );
 
     set_process_name( __wine_main_argc, __wine_main_argv );
-    set_library_wargv( __wine_main_argv );
+    argv = convert_unix_paths( __wine_main_argv );
+    set_library_wargv( argv );
+    free_converted_paths( argv );
     boot_events[0] = boot_events[1] = 0;
 
     if (peb->ProcessParameters->ImagePathName.Buffer)
diff --git a/etersoft/scripts/wine.in b/etersoft/scripts/wine.in
index 72791d6..48a481d 100644
--- a/etersoft/scripts/wine.in
+++ b/etersoft/scripts/wine.in
@@ -476,20 +476,6 @@ if [ -n "$WINEWORKDIRPATH" ] ; then
 	cd "$WINEWORKDIRPATH"
 fi
 
-# translate args from unix path to windows, if possible (eterbug #4933)
-args_to_winpath()
-{
-	for i in "$@" ; do
-		local TP="$i"
-		local TR=${i/\~/$HOME}
-		if [ -r "$TR" ] ; then
-			WP=$($WINELOADER winepath -w "$TR" 2>/dev/null)
-			[ -z "$WP" ] || TP="$WP"
-		fi
-		echo "'$TP' "
-	done
-}
-
 STARTCOM=
 # if file is exists in Unix or Wine notation
 WINEPROGRAMUNIXPATH=$($WINELOADER winepath "$1")
@@ -505,5 +491,4 @@ if [ -n "$1" ] && [ -f "$WINEPROGRAMUNIXPATH" ] ; then
 	fi
 fi
 
-eval run_wine $STARTCOM $(args_to_winpath "$@")
-
+run_wine $STARTCOM "$@"
-- 
1.7.3.4



Подробная информация о списке рассылки Wine-patches