Alexandre Julliard : kernel32: Don't call from A to W function in Get/ SetCurrentDirectory.

Alexandre Julliard julliard at winehq.org
Mon Aug 19 14:32:59 CDT 2013


Module: wine
Branch: master
Commit: fe64e21e3b6f923c55dee50c866005293fe2a9b8
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=fe64e21e3b6f923c55dee50c866005293fe2a9b8

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Sun Aug 18 19:57:05 2013 +0200

kernel32: Don't call from A to W function in Get/SetCurrentDirectory.

---

 dlls/kernel32/path.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/dlls/kernel32/path.c b/dlls/kernel32/path.c
index 5cd3c4b..3ee0dd6 100644
--- a/dlls/kernel32/path.c
+++ b/dlls/kernel32/path.c
@@ -1502,10 +1502,9 @@ UINT WINAPI GetCurrentDirectoryA( UINT buflen, LPSTR buf )
         return 0;
     }
 
-    ret = GetCurrentDirectoryW(MAX_PATH, bufferW);
-
+    ret = RtlGetCurrentDirectory_U( sizeof(bufferW), bufferW );
     if (!ret) return 0;
-    if (ret > MAX_PATH)
+    if (ret > sizeof(bufferW))
     {
         SetLastError(ERROR_FILENAME_EXCED_RANGE);
         return 0;
@@ -1524,12 +1523,8 @@ BOOL WINAPI SetCurrentDirectoryW( LPCWSTR dir )
 
     RtlInitUnicodeString( &dirW, dir );
     status = RtlSetCurrentDirectory_U( &dirW );
-    if (status != STATUS_SUCCESS)
-    {
-        SetLastError( RtlNtStatusToDosError(status) );
-        return FALSE;
-    }
-    return TRUE;
+    if (status != STATUS_SUCCESS) SetLastError( RtlNtStatusToDosError(status) );
+    return !status;
 }
 
 
@@ -1539,9 +1534,14 @@ BOOL WINAPI SetCurrentDirectoryW( LPCWSTR dir )
 BOOL WINAPI SetCurrentDirectoryA( LPCSTR dir )
 {
     WCHAR *dirW;
+    UNICODE_STRING strW;
+    NTSTATUS status;
 
     if (!(dirW = FILE_name_AtoW( dir, FALSE ))) return FALSE;
-    return SetCurrentDirectoryW( dirW );
+    RtlInitUnicodeString( &strW, dirW );
+    status = RtlSetCurrentDirectory_U( &strW );
+    if (status != STATUS_SUCCESS) SetLastError( RtlNtStatusToDosError(status) );
+    return !status;
 }
 
 




More information about the wine-cvs mailing list