- 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.

svn path=/trunk/; revision=40184
This commit is contained in:
Jeffrey Morlan 2009-03-23 14:47:46 +00:00
parent d99f998d2d
commit 73694e1e38
3 changed files with 15 additions and 20 deletions

View file

@ -207,7 +207,6 @@ NTSTATUS NTAPI
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 @@ RtlSetCurrentDirectory_U(PUNICODE_STRING dir)
NTSTATUS Status;
ULONG size;
HANDLE handle = NULL;
WCHAR var[4];
PWSTR ptr;
DPRINT("RtlSetCurrentDirectory %wZ\n", dir);
@ -282,19 +280,6 @@ RtlSetCurrentDirectory_U(PUNICODE_STRING dir)
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();

View file

@ -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;
}

View file

@ -2,4 +2,3 @@
#define _UNICODE
#include "chdir.c"