[KERNEL32]

- Failure if does not come to an end a way with a symbol '\' (exception - a path of a looks like 'C:')

* Fixes 2 tests for kernel32_apitest GetDriveType (all tests for GetDriveType passed now)

svn path=/trunk/; revision=72512
This commit is contained in:
Dmitry Chapyshev 2016-08-30 19:22:00 +00:00
parent 779ba0d221
commit 2ef1af40a1

View file

@ -19,6 +19,8 @@
*/
#include <k32.h>
#include <strsafe.h>
#define NDEBUG
#include <debug.h>
DEBUG_CHANNEL(kernel32file);
@ -401,13 +403,36 @@ GetDriveTypeW(IN LPCWSTR lpRootPathName)
if (wcslen(CurrentDir) > 3)
CurrentDir[3] = 0;
lpRootPath = (PCWSTR)CurrentDir;
lpRootPath = CurrentDir;
}
else
{
size_t Length = wcslen(lpRootPathName);
TRACE("lpRootPathName: %S\n", lpRootPathName);
if (Length == 2)
{
WCHAR DriveLetter = RtlUpcaseUnicodeChar(lpRootPathName[0]);
if (DriveLetter >= L'A' && DriveLetter <= L'Z' && lpRootPathName[1] == L':')
{
Length = (Length + 2) * sizeof(WCHAR);
CurrentDir = HeapAlloc(GetProcessHeap(), 0, Length);
if (!CurrentDir)
return DRIVE_UNKNOWN;
StringCbPrintfW(CurrentDir, Length, L"%s\\", lpRootPathName);
lpRootPath = CurrentDir;
}
}
else
{
lpRootPath = lpRootPathName;
}
}
TRACE("lpRootPath: %S\n", lpRootPath);
@ -424,6 +449,11 @@ GetDriveTypeW(IN LPCWSTR lpRootPathName)
if (CurrentDir != NULL)
HeapFree(GetProcessHeap(), 0, CurrentDir);
if (PathName.Buffer[(PathName.Length >> 1) - 1] != L'\\')
{
return DRIVE_NO_ROOT_DIR;
}
InitializeObjectAttributes(&ObjectAttributes,
&PathName,
OBJ_CASE_INSENSITIVE,
@ -436,6 +466,7 @@ GetDriveTypeW(IN LPCWSTR lpRootPathName)
&IoStatusBlock,
FILE_SHARE_READ | FILE_SHARE_WRITE,
FILE_SYNCHRONOUS_IO_NONALERT);
RtlFreeHeap(RtlGetProcessHeap(), 0, PathName.Buffer);
if (!NT_SUCCESS(Status))
return DRIVE_NO_ROOT_DIR; /* According to WINE regression tests */