From 7e0bfac66205cfbb961d9bbb69ce5e57f786804a Mon Sep 17 00:00:00 2001 From: Carl Nettelblad Date: Sun, 29 Apr 2001 21:09:20 +0000 Subject: [PATCH] This change shouldn't mess things up, if used together with latest vfat version. NtQueryInformationFile is required to return valid name information for this to work. svn path=/trunk/; revision=1840 --- reactos/lib/ntdll/rtl/path.c | 52 +++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/reactos/lib/ntdll/rtl/path.c b/reactos/lib/ntdll/rtl/path.c index 6a3ab1888ff..c4ebb64bef2 100644 --- a/reactos/lib/ntdll/rtl/path.c +++ b/reactos/lib/ntdll/rtl/path.c @@ -1,4 +1,4 @@ -/* $Id: path.c,v 1.8 2001/03/08 22:48:42 dwelch Exp $ +/* $Id: path.c,v 1.9 2001/04/29 21:09:20 cnettel Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -15,6 +15,7 @@ #include #include #include +#include #define NDEBUG #include @@ -283,7 +284,10 @@ NTSTATUS STDCALL RtlSetCurrentDirectory_U (PUNICODE_STRING name) HANDLE handle = NULL; PWSTR wcs; PWSTR buf = 0; - + PFILE_NAME_INFORMATION filenameinfo; + ULONG backslashcount = 0; + PWSTR cntr; + DPRINT ("RtlSetCurrentDirectory %wZ\n", name); RtlAcquirePebLock (); @@ -344,7 +348,49 @@ NTSTATUS STDCALL RtlSetCurrentDirectory_U (PUNICODE_STRING name) RtlReleasePebLock (); return Status; } + + filenameinfo = RtlAllocateHeap (RtlGetProcessHeap(), + 0, + MAX_PATH*sizeof(WCHAR)+sizeof(ULONG)); + + NtQueryInformationFile(handle,NULL, filenameinfo,MAX_PATH*sizeof(WCHAR)+sizeof(ULONG),FileNameInformation); + + if (filenameinfo->FileName[1]) // If it's just "\", we need special handling + { + wcs = buf + size / sizeof(WCHAR) - 1; + if (*wcs == L'\\') + { + *(wcs) = 0; + wcs--; + size -= sizeof(WCHAR); + } + + for (cntr=filenameinfo->FileName;*cntr!=0;cntr++) + { + if (*cntr=='\\') backslashcount++; + } + + + DPRINT("%d \n",backslashcount); + for (;backslashcount;wcs--) + { + if (*wcs=='\\') backslashcount--; + } + wcs++; + + + wcscpy(wcs,filenameinfo->FileName); + + size=((wcs-buf)+wcslen(filenameinfo->FileName))*sizeof(WCHAR); + } + + RtlFreeHeap (RtlGetProcessHeap (), + 0, + filenameinfo); + + + /* append backslash if missing */ wcs = buf + size / sizeof(WCHAR) - 1; if (*wcs != L'\\') @@ -353,7 +399,7 @@ NTSTATUS STDCALL RtlSetCurrentDirectory_U (PUNICODE_STRING name) *(++wcs) = 0; size += sizeof(WCHAR); } - + memmove (cd->DosPath.Buffer, buf, size + sizeof(WCHAR));