mirror of
https://github.com/reactos/reactos.git
synced 2025-04-22 05:00:27 +00:00
[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:
parent
779ba0d221
commit
2ef1af40a1
1 changed files with 45 additions and 14 deletions
|
@ -19,6 +19,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <k32.h>
|
#include <k32.h>
|
||||||
|
#include <strsafe.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
DEBUG_CHANNEL(kernel32file);
|
DEBUG_CHANNEL(kernel32file);
|
||||||
|
@ -401,12 +403,35 @@ GetDriveTypeW(IN LPCWSTR lpRootPathName)
|
||||||
if (wcslen(CurrentDir) > 3)
|
if (wcslen(CurrentDir) > 3)
|
||||||
CurrentDir[3] = 0;
|
CurrentDir[3] = 0;
|
||||||
|
|
||||||
lpRootPath = (PCWSTR)CurrentDir;
|
lpRootPath = CurrentDir;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
size_t Length = wcslen(lpRootPathName);
|
||||||
|
|
||||||
TRACE("lpRootPathName: %S\n", lpRootPathName);
|
TRACE("lpRootPathName: %S\n", lpRootPathName);
|
||||||
lpRootPath = 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);
|
TRACE("lpRootPath: %S\n", lpRootPath);
|
||||||
|
@ -424,6 +449,11 @@ GetDriveTypeW(IN LPCWSTR lpRootPathName)
|
||||||
if (CurrentDir != NULL)
|
if (CurrentDir != NULL)
|
||||||
HeapFree(GetProcessHeap(), 0, CurrentDir);
|
HeapFree(GetProcessHeap(), 0, CurrentDir);
|
||||||
|
|
||||||
|
if (PathName.Buffer[(PathName.Length >> 1) - 1] != L'\\')
|
||||||
|
{
|
||||||
|
return DRIVE_NO_ROOT_DIR;
|
||||||
|
}
|
||||||
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
&PathName,
|
&PathName,
|
||||||
OBJ_CASE_INSENSITIVE,
|
OBJ_CASE_INSENSITIVE,
|
||||||
|
@ -436,6 +466,7 @@ GetDriveTypeW(IN LPCWSTR lpRootPathName)
|
||||||
&IoStatusBlock,
|
&IoStatusBlock,
|
||||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||||
FILE_SYNCHRONOUS_IO_NONALERT);
|
FILE_SYNCHRONOUS_IO_NONALERT);
|
||||||
|
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, PathName.Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, PathName.Buffer);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
return DRIVE_NO_ROOT_DIR; /* According to WINE regression tests */
|
return DRIVE_NO_ROOT_DIR; /* According to WINE regression tests */
|
||||||
|
@ -453,19 +484,19 @@ GetDriveTypeW(IN LPCWSTR lpRootPathName)
|
||||||
|
|
||||||
switch (FileFsDevice.DeviceType)
|
switch (FileFsDevice.DeviceType)
|
||||||
{
|
{
|
||||||
case FILE_DEVICE_CD_ROM:
|
case FILE_DEVICE_CD_ROM:
|
||||||
case FILE_DEVICE_CD_ROM_FILE_SYSTEM:
|
case FILE_DEVICE_CD_ROM_FILE_SYSTEM:
|
||||||
return DRIVE_CDROM;
|
return DRIVE_CDROM;
|
||||||
case FILE_DEVICE_VIRTUAL_DISK:
|
case FILE_DEVICE_VIRTUAL_DISK:
|
||||||
return DRIVE_RAMDISK;
|
return DRIVE_RAMDISK;
|
||||||
case FILE_DEVICE_NETWORK_FILE_SYSTEM:
|
case FILE_DEVICE_NETWORK_FILE_SYSTEM:
|
||||||
return DRIVE_REMOTE;
|
|
||||||
case FILE_DEVICE_DISK:
|
|
||||||
case FILE_DEVICE_DISK_FILE_SYSTEM:
|
|
||||||
if (FileFsDevice.Characteristics & FILE_REMOTE_DEVICE)
|
|
||||||
return DRIVE_REMOTE;
|
return DRIVE_REMOTE;
|
||||||
if (FileFsDevice.Characteristics & FILE_REMOVABLE_MEDIA)
|
case FILE_DEVICE_DISK:
|
||||||
return DRIVE_REMOVABLE;
|
case FILE_DEVICE_DISK_FILE_SYSTEM:
|
||||||
|
if (FileFsDevice.Characteristics & FILE_REMOTE_DEVICE)
|
||||||
|
return DRIVE_REMOTE;
|
||||||
|
if (FileFsDevice.Characteristics & FILE_REMOVABLE_MEDIA)
|
||||||
|
return DRIVE_REMOVABLE;
|
||||||
return DRIVE_FIXED;
|
return DRIVE_FIXED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue