[ros-diffs] [jmorlan] 40184: - Moved the code for updating the drive-specific current-directory environment variable out of RTL and into the CRT. Testing on Windows shows that neither RtlSetCurrentDirectory_U or SetCurrentDirectory update these variables, but _tchdir does.

jmorlan at svn.reactos.org jmorlan at svn.reactos.org
Mon Mar 23 15:47:47 CET 2009


Author: jmorlan
Date: Mon Mar 23 17:47:46 2009
New Revision: 40184

URL: http://svn.reactos.org/svn/reactos?rev=40184&view=rev
Log:
- Moved the code for updating the drive-specific current-directory environment variable out of RTL and into the CRT. Testing on Windows shows that neither RtlSetCurrentDirectory_U or SetCurrentDirectory update these variables, but _tchdir does.

Modified:
    trunk/reactos/lib/rtl/path.c
    trunk/reactos/lib/sdk/crt/direct/chdir.c
    trunk/reactos/lib/sdk/crt/direct/wchdir.c

Modified: trunk/reactos/lib/rtl/path.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/path.c?rev=40184&r1=40183&r2=40184&view=diff
==============================================================================
--- trunk/reactos/lib/rtl/path.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/path.c [iso-8859-1] Mon Mar 23 17:47:46 2009
@@ -207,7 +207,6 @@
 RtlSetCurrentDirectory_U(PUNICODE_STRING dir)
 {
    UNICODE_STRING full;
-   UNICODE_STRING envvar;
    FILE_FS_DEVICE_INFORMATION device_info;
    OBJECT_ATTRIBUTES Attr;
    IO_STATUS_BLOCK iosb;
@@ -215,7 +214,6 @@
    NTSTATUS Status;
    ULONG size;
    HANDLE handle = NULL;
-   WCHAR var[4];
    PWSTR ptr;
 
    DPRINT("RtlSetCurrentDirectory %wZ\n", dir);
@@ -281,19 +279,6 @@
    memcpy( cd->DosPath.Buffer, ptr, size * sizeof(WCHAR));
    cd->DosPath.Buffer[size] = 0;
    cd->DosPath.Length = size * sizeof(WCHAR);
-
-
-   /* FIXME: whats this all about??? Wine doesnt have this. -Gunnar */
-   if (cd->DosPath.Buffer[1]==':')
-   {
-      envvar.Length = 2 * swprintf (var, L"=%c:", cd->DosPath.Buffer[0]);
-      envvar.MaximumLength = 8;
-      envvar.Buffer = var;
-
-      RtlSetEnvironmentVariable(NULL,
-                 &envvar,
-                 &cd->DosPath);
-   }
 
    RtlFreeUnicodeString( &full);
    RtlReleasePebLock();

Modified: trunk/reactos/lib/sdk/crt/direct/chdir.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/direct/chdir.c?rev=40184&r1=40183&r2=40184&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/direct/chdir.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/direct/chdir.c [iso-8859-1] Mon Mar 23 17:47:46 2009
@@ -8,9 +8,20 @@
  */
 int _tchdir(const _TCHAR* _path)
 {
-    if (!SetCurrentDirectory(_path)) {
-      _dosmaperr(_path?GetLastError():0);
-		return -1;
-	}
+    WCHAR newdir[MAX_PATH];
+
+    if (!SetCurrentDirectory(_path))
+    {
+        _dosmaperr(_path ? GetLastError() : 0);
+        return -1;
+    }
+
+    /* Update the drive-specific current directory variable */
+    if (GetCurrentDirectoryW(MAX_PATH, newdir) && newdir[1] == L':')
+    {
+        WCHAR envvar[4] = { L'=', towupper(newdir[0]), L':', L'\0' };
+        SetEnvironmentVariableW(envvar, newdir);
+    }
+
     return 0;
 }

Modified: trunk/reactos/lib/sdk/crt/direct/wchdir.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/direct/wchdir.c?rev=40184&r1=40183&r2=40184&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/direct/wchdir.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/direct/wchdir.c [iso-8859-1] Mon Mar 23 17:47:46 2009
@@ -2,4 +2,3 @@
 #define _UNICODE
 
 #include "chdir.c"
-



More information about the Ros-diffs mailing list