From 03e327f37f24d8571ecc38e015f6ec9f9fff712a Mon Sep 17 00:00:00 2001 From: Carl Nettelblad Date: Wed, 7 Mar 2001 22:29:09 +0000 Subject: [PATCH] Current directory now always with correct casing. svn path=/trunk/; revision=1675 --- reactos/lib/ntdll/rtl/path.c | 47 +++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/reactos/lib/ntdll/rtl/path.c b/reactos/lib/ntdll/rtl/path.c index 1c49e61cf9b..a4dec9366cf 100644 --- a/reactos/lib/ntdll/rtl/path.c +++ b/reactos/lib/ntdll/rtl/path.c @@ -1,4 +1,4 @@ -/* $Id: path.c,v 1.6 2000/09/01 17:05:46 ekohl Exp $ +/* $Id: path.c,v 1.7 2001/03/07 22:29:09 cnettel Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -119,7 +119,7 @@ RtlDetermineDosPathNameType_U ( PWSTR Path ) { - DPRINT ("RtlDetermineDosPathNameType_U %S\n", Path); +// DPRINT ("RtlDetermineDosPathNameType_U %S\n", Path); if (Path == NULL) return 0; @@ -240,7 +240,7 @@ RtlGetCurrentDirectory_U ( ULONG Length; PCURDIR cd; - DPRINT ("RtlGetCurrentDirectory %lu %p\n", MaximumLength, Buffer); +// DPRINT ("RtlGetCurrentDirectory %lu %p\n", MaximumLength, Buffer); cd = &(NtCurrentPeb ()->ProcessParameters->CurrentDirectory); @@ -250,8 +250,8 @@ RtlGetCurrentDirectory_U ( cd->DosPath.Buffer[Length - 2] != L':') Length--; - DPRINT ("cd->DosPath.Buffer %S Length %d\n", - cd->DosPath.Buffer, Length); +// DPRINT ("cd->DosPath.Buffer %S Length %d\n", +// cd->DosPath.Buffer, Length); if (MaximumLength / sizeof(WCHAR) > Length) { @@ -283,7 +283,10 @@ NTSTATUS STDCALL RtlSetCurrentDirectory_U (PUNICODE_STRING name) ULONG size; HANDLE handle = NULL; PWSTR wcs; + PWSTR devpathstart, loopvar; PWSTR buf = 0; + PFILE_NAME_INFORMATION objnameinfo; + ULONG reslength; DPRINT ("RtlSetCurrentDirectory %wZ\n", name); @@ -334,6 +337,28 @@ NTSTATUS STDCALL RtlSetCurrentDirectory_U (PUNICODE_STRING name) &iosb, FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT); + + objnameinfo = RtlAllocateHeap (RtlGetProcessHeap(), + 0, + cd->DosPath.MaximumLength*sizeof(WCHAR)+4); // A little margin, for Length pre-fix + + NtQueryInformationFile(handle,NULL,objnameinfo,sizeof(OBJECT_NAME_INFORMATION),FileNameInformation); + + devpathstart=buf+wcslen(buf); + + for (loopvar=objnameinfo->FileName;(*loopvar);loopvar++) + if ((*loopvar)=='\\') + { + devpathstart--; + for (;devpathstart>buf && (*devpathstart)!='\\';devpathstart--) {} + } + + wcscpy(devpathstart, objnameinfo->FileName); + + +RtlFreeHeap (RtlGetProcessHeap (), + 0, + objnameinfo); if (!NT_SUCCESS(Status)) { RtlFreeHeap (RtlGetProcessHeap (), @@ -394,8 +419,8 @@ RtlGetFullPathName_U ( PCURDIR cd; NTSTATUS Status; - DPRINT("RtlGetFullPathName_U %S %ld %p %p\n", - DosName, size, buf, FilePart); +// DPRINT("RtlGetFullPathName_U %S %ld %p %p\n", +// DosName, size, buf, FilePart); if (!DosName || !*DosName) return 0; @@ -436,7 +461,7 @@ CHECKPOINT; RtlAcquirePebLock(); cd = &(NtCurrentPeb ()->ProcessParameters->CurrentDirectory); -DPRINT("type %ld\n", type); +//DPRINT("type %ld\n", type); switch (type) { case 1: /* \\xxx or \\.xxx */ @@ -507,7 +532,7 @@ CHECKPOINT; return 0; } - DPRINT("buf \'%S\' DosName \'%S\' len %ld\n", buf, DosName, len); +// DPRINT("buf \'%S\' DosName \'%S\' len %ld\n", buf, DosName, len); /* add dosname to prefix */ wcsncat (buf, DosName, len); @@ -521,9 +546,9 @@ CHECKPOINT; if (len < 3 && buf[len-1] == L':') wcscat (buf, L"\\"); - DPRINT("buf \'%S\'\n", buf); +// DPRINT("buf \'%S\'\n", buf); RtlpEatPath (buf); - DPRINT("buf \'%S\'\n", buf); +// DPRINT("buf \'%S\'\n", buf); len = wcslen (buf);