ReactOS  0.4.15-dev-1152-g6c94e4f
GetDriveType.c File Reference
#include "precomp.h"
Include dependency graph for GetDriveType.c:

Go to the source code of this file.

Macros

#define IS_DRIVE_TYPE_VALID(type)   ((type) != DRIVE_UNKNOWN && (type) != DRIVE_NO_ROOT_DIR)
 

Functions

 START_TEST (GetDriveType)
 

Macro Definition Documentation

◆ IS_DRIVE_TYPE_VALID

#define IS_DRIVE_TYPE_VALID (   type)    ((type) != DRIVE_UNKNOWN && (type) != DRIVE_NO_ROOT_DIR)

Definition at line 3 of file GetDriveType.c.

Function Documentation

◆ START_TEST()

START_TEST ( GetDriveType  )

Definition at line 5 of file GetDriveType.c.

6 {
7  UINT Type, Type2, i;
9 
10  /* Note: Successful calls can set last error to at least ERROR_NOT_A_REPARSE_POINT, we don't test it here */
11  SetLastError(0xdeadbeaf);
12 
13  Type = GetDriveTypeW(L"");
14  ok(Type == DRIVE_NO_ROOT_DIR, "Expected DRIVE_NO_ROOT_DIR, got %u\n", Type);
15 
16  Type = GetDriveTypeW(L"\nC:\\");
17  ok(Type == DRIVE_NO_ROOT_DIR, "Expected DRIVE_NO_ROOT_DIR, got %u\n", Type);
18 
19  Type = GetDriveTypeW(L"Z:\\");
20  ok(Type == DRIVE_NO_ROOT_DIR, "Expected DRIVE_NO_ROOT_DIR, got %u\n", Type);
21 
22  ok(GetLastError() == 0xdeadbeaf, "Expected no errors, got %lu\n", GetLastError());
23 
24  /* Drive root is accepted without ending slash */
25  Type = GetDriveTypeW(L"C:");
26  ok(IS_DRIVE_TYPE_VALID(Type), "Expected valid drive type, got %u\n", Type);
27 
28  Type = GetDriveTypeW(L"C:\\");
29  ok(IS_DRIVE_TYPE_VALID(Type), "Expected valid drive type, got %u\n", Type);
30 
32  ok(IS_DRIVE_TYPE_VALID(Type), "Expected valid drive type, got %u\n", Type);
33 
34  i = GetCurrentDirectoryW(sizeof(Path)/sizeof(Path[0]), Path);
35  if (i)
36  {
37  /* No trailing backslash returned unless we're at the drive root */
38  if (Path[i - 1] != L'\\')
39  {
40  SetLastError(0xdeadbeaf);
41  Type2 = GetDriveTypeW(Path);
42  ok(Type2 == DRIVE_NO_ROOT_DIR, "Expected DRIVE_NO_ROOT_DIR, got %u\n", Type2);
43  ok(GetLastError() == 0xdeadbeaf, "Expected no errors, got %lu\n", GetLastError());
44 
45  StringCchCopyW(Path + i, MAX_PATH - i, L"\\");
46  }
47  Type2 = GetDriveTypeW(Path);
48  ok(Type == Type2, "Types are not equal: %u != %u\n", Type, Type2);
49  }
50 
51  i = GetSystemDirectoryW(Path, sizeof(Path)/sizeof(Path[0]));
52  if (i)
53  {
54  /* Note: there is no backslash at the end of Path */
55  SetLastError(0xdeadbeaf);
57  ok(Type == DRIVE_NO_ROOT_DIR, "Expected DRIVE_NO_ROOT_DIR, got %u\n", Type);
58  ok(GetLastError() == 0xdeadbeaf, "Expected no errors, got %lu\n", GetLastError());
59 
60  StringCchCopyW(Path + i, MAX_PATH - i, L"\\");
62  ok(IS_DRIVE_TYPE_VALID(Type), "Expected valid drive type, got %u\n", Type);
63 
64  StringCchCopyW(Path + i, MAX_PATH - i, L"/");
66  ok(IS_DRIVE_TYPE_VALID(Type), "Expected valid drive type, got %u\n", Type);
67 
68  StringCchCopyW(Path + i, MAX_PATH - i, L"\\\\");
70  ok(IS_DRIVE_TYPE_VALID(Type), "Expected valid drive type, got %u\n", Type);
71  }
72 }
Type
Definition: Type.h:6
#define IS_DRIVE_TYPE_VALID(type)
Definition: GetDriveType.c:3
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:504
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
#define SetLastError(x)
Definition: compat.h:500
static const WCHAR L[]
Definition: oid.c:1250
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
#define DRIVE_NO_ROOT_DIR
Definition: winbase.h:254
PRTL_UNICODE_STRING_BUFFER Path
#define ok(value,...)
Definition: atltest.h:57
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2312
unsigned int UINT
Definition: ndis.h:50