ReactOS  0.4.14-dev-323-g6fe6a88
directory.c File Reference
#include <stdarg.h>
#include "wine/test.h"
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "winternl.h"
Include dependency graph for directory.c:

Go to the source code of this file.

Macros

#define TEST_GRANTED_ACCESS(a, b)   test_granted_access(a,b,__LINE__)
 

Functions

static NTSTATUS (WINAPI *pNtQueryObject)(HANDLE
 
static void init (void)
 
static void test_granted_access (HANDLE handle, ACCESS_MASK access, int line)
 
static void test_GetWindowsDirectoryA (void)
 
static void test_GetWindowsDirectoryW (void)
 
static void test_GetSystemDirectoryA (void)
 
static void test_GetSystemDirectoryW (void)
 
static void test_CreateDirectoryA (void)
 
static void test_CreateDirectoryW (void)
 
static void test_RemoveDirectoryA (void)
 
static void test_RemoveDirectoryW (void)
 
static void test_SetCurrentDirectoryA (void)
 
 START_TEST (directory)
 

Variables

static OBJECT_INFORMATION_CLASS
 
static PVOID
 
static ULONG
 
static PULONG
 

Macro Definition Documentation

◆ TEST_GRANTED_ACCESS

#define TEST_GRANTED_ACCESS (   a,
  b 
)    test_granted_access(a,b,__LINE__)

Definition at line 37 of file directory.c.

Function Documentation

◆ init()

static void init ( void  )
static

Definition at line 31 of file directory.c.

32 {
33  HMODULE hntdll = GetModuleHandleA("ntdll.dll");
34  pNtQueryObject = (void *)GetProcAddress(hntdll, "NtQueryObject");
35 }
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
static HINSTANCE hntdll
Definition: process.c:66
#define GetProcAddress(x, y)
Definition: compat.h:410

Referenced by START_TEST().

◆ NTSTATUS()

static NTSTATUS ( WINAPI pNtQueryObject)
static

◆ START_TEST()

START_TEST ( directory  )

Definition at line 544 of file directory.c.

545 {
546  init();
547 
550 
553 
556 
559 
561 }
static void test_RemoveDirectoryA(void)
Definition: directory.c:447
static void test_GetWindowsDirectoryW(void)
Definition: directory.c:79
static void test_CreateDirectoryW(void)
Definition: directory.c:359
static void test_GetSystemDirectoryA(void)
Definition: directory.c:117
static void test_RemoveDirectoryW(void)
Definition: directory.c:488
static void test_SetCurrentDirectoryA(void)
Definition: directory.c:535
static void init(void)
Definition: directory.c:31
static void test_GetWindowsDirectoryA(void)
Definition: directory.c:53
static void test_GetSystemDirectoryW(void)
Definition: directory.c:145
static void test_CreateDirectoryA(void)
Definition: directory.c:179

◆ test_CreateDirectoryA()

static void test_CreateDirectoryA ( void  )
static

Definition at line 179 of file directory.c.

180 {
181  char tmpdir[MAX_PATH];
182  WCHAR curdir[MAX_PATH];
183  BOOL ret;
184 
188  "CreateDirectoryA(NULL): ret=%d err=%d\n", ret, GetLastError());
189 
190  ret = CreateDirectoryA("", NULL);
193  "CreateDirectoryA(%s): ret=%d err=%d\n", tmpdir, ret, GetLastError());
194 
196  ok(ret < MAX_PATH, "System directory should fit into MAX_PATH\n");
197 
200  ok(ret == TRUE, "could not chdir to the System directory\n");
201 
202  ret = CreateDirectoryA(".", NULL);
204  "CreateDirectoryA(%s): ret=%d err=%d\n", tmpdir, ret, GetLastError());
205 
206 
207  ret = CreateDirectoryA("..", NULL);
209  "CreateDirectoryA(%s): ret=%d err=%d\n", tmpdir, ret, GetLastError());
210 
212  tmpdir[3] = 0; /* truncate the path */
216  "CreateDirectoryA(%s): ret=%d err=%d\n", tmpdir, ret, GetLastError());
217 
219  lstrcatA(tmpdir, "Please Remove Me");
221  ok(ret == TRUE, "CreateDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
222 
225  "CreateDirectoryA(%s): ret=%d err=%d\n", tmpdir, ret, GetLastError());
226 
228  ok(ret == TRUE,
229  "RemoveDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
230 
231 
232  lstrcatA(tmpdir, "?");
236  "CreateDirectoryA(%s): ret=%d err=%d\n", tmpdir, ret, GetLastError());
238 
239  tmpdir[lstrlenA(tmpdir) - 1] = '*';
243  "CreateDirectoryA(%s): ret=%d err=%d\n", tmpdir, ret, GetLastError());
245 
247  lstrcatA(tmpdir, "Please Remove Me/Please Remove Me");
250  "CreateDirectoryA(%s): ret=%d err=%d\n", tmpdir, ret, GetLastError());
252 
253  /* Test behavior with a trailing dot.
254  * The directory should be created without the dot.
255  */
257  lstrcatA(tmpdir, "Please Remove Me.");
259  ok(ret == TRUE,
260  "CreateDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
261 
262  lstrcatA(tmpdir, "/Please Remove Me");
264  ok(ret == TRUE,
265  "CreateDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
267  ok(ret == TRUE,
268  "RemoveDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
269 
271  lstrcatA(tmpdir, "Please Remove Me");
273  ok(ret == TRUE,
274  "RemoveDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
275 
276  /* Test behavior with two trailing dots.
277  * The directory should be created without the trailing dots.
278  */
280  lstrcatA(tmpdir, "Please Remove Me..");
282  ok(ret == TRUE,
283  "CreateDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
284 
285  lstrcatA(tmpdir, "/Please Remove Me");
287  ok(ret == TRUE || /* On Win98 */
288  (ret == FALSE && GetLastError() == ERROR_PATH_NOT_FOUND), /* On NT! */
289  "CreateDirectoryA(%s): ret=%d err=%d\n", tmpdir, ret, GetLastError());
290  if (ret == TRUE)
291  {
293  ok(ret == TRUE,
294  "RemoveDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
295  }
296 
298  lstrcatA(tmpdir, "Please Remove Me");
300  ok(ret == TRUE,
301  "RemoveDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
302 
303  /* Test behavior with a trailing space.
304  * The directory should be created without the trailing space.
305  */
307  lstrcatA(tmpdir, "Please Remove Me ");
309  ok(ret == TRUE,
310  "CreateDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
311 
312  lstrcatA(tmpdir, "/Please Remove Me");
314  ok(ret == TRUE || /* On Win98 */
315  (ret == FALSE && GetLastError() == ERROR_PATH_NOT_FOUND), /* On NT! */
316  "CreateDirectoryA(%s): ret=%d err=%d\n", tmpdir, ret, GetLastError());
317  if (ret == TRUE)
318  {
320  ok(ret == TRUE,
321  "RemoveDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
322  }
323 
325  lstrcatA(tmpdir, "Please Remove Me");
327  ok(ret == TRUE,
328  "RemoveDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
329 
330  /* Test behavior with a trailing space.
331  * The directory should be created without the trailing spaces.
332  */
334  lstrcatA(tmpdir, "Please Remove Me ");
336  ok(ret == TRUE,
337  "CreateDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
338 
339  lstrcatA(tmpdir, "/Please Remove Me");
341  ok(ret == TRUE || /* On Win98 */
342  (ret == FALSE && GetLastError() == ERROR_PATH_NOT_FOUND), /* On NT! */
343  "CreateDirectoryA(%s): ret=%d err=%d\n", tmpdir, ret, GetLastError());
344  if (ret == TRUE)
345  {
347  ok(ret == TRUE,
348  "RemoveDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
349  }
350 
352  lstrcatA(tmpdir, "Please Remove Me");
354  ok(ret == TRUE,
355  "RemoveDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
356  SetCurrentDirectoryW(curdir);
357 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:413
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2282
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
smooth NULL
Definition: ftsmooth.c:416
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
static char tmpdir[MAX_PATH]
Definition: shlexec.c:59
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
int ret
BOOL WINAPI SetCurrentDirectoryA(IN LPCSTR lpPathName)
Definition: path.c:2205
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2053
BOOL WINAPI SetCurrentDirectoryW(IN LPCWSTR lpPathName)
Definition: path.c:2248
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:714
#define ERROR_INVALID_NAME
Definition: compat.h:93
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
#define ERROR_BAD_PATHNAME
Definition: winerror.h:233

Referenced by START_TEST().

◆ test_CreateDirectoryW()

static void test_CreateDirectoryW ( void  )
static

Definition at line 359 of file directory.c.

360 {
362  BOOL ret;
363  static const WCHAR empty_strW[] = { 0 };
364  static const WCHAR tmp_dir_name[] = {'P','l','e','a','s','e',' ','R','e','m','o','v','e',' ','M','e',0};
365  static const WCHAR dotW[] = {'.',0};
366  static const WCHAR slashW[] = {'/',0};
367  static const WCHAR dotdotW[] = {'.','.',0};
368  static const WCHAR questionW[] = {'?',0};
369  WCHAR curdir[MAX_PATH];
370 
373  {
374  win_skip("CreateDirectoryW is not available\n");
375  return;
376  }
378  "should not create NULL path ret %u err %u\n", ret, GetLastError());
379 
380  ret = CreateDirectoryW(empty_strW, NULL);
382  "should not create empty path ret %u err %u\n", ret, GetLastError());
383 
385  ok(ret < MAX_PATH, "System directory should fit into MAX_PATH\n");
386 
389  ok(ret == TRUE, "could not chdir to the System directory ret %u err %u\n", ret, GetLastError());
390 
393  "should not create existing path ret %u err %u\n", ret, GetLastError());
394 
397  "should not create existing path ret %u err %u\n", ret, GetLastError());
398 
400  tmpdir[3] = 0; /* truncate the path */
403  "should deny access to the drive root ret %u err %u\n", ret, GetLastError());
404 
406  lstrcatW(tmpdir, tmp_dir_name);
408  ok(ret == TRUE, "CreateDirectoryW should always succeed\n");
409 
412  "should not create existing path ret %u err %u\n", ret, GetLastError());
413 
415  ok(ret == TRUE, "RemoveDirectoryW should always succeed\n");
416 
417  lstrcatW(tmpdir, questionW);
420  "CreateDirectoryW with ? wildcard name should fail with error 183, ret=%s error=%d\n",
421  ret ? " True" : "False", GetLastError());
423  ok(ret == FALSE, "RemoveDirectoryW should have failed\n");
424 
425  tmpdir[lstrlenW(tmpdir) - 1] = '*';
428  "CreateDirectoryW with * wildcard name should fail with error 183, ret=%s error=%d\n",
429  ret ? " True" : "False", GetLastError());
431  ok(ret == FALSE, "RemoveDirectoryW should have failed\n");
432 
434  lstrcatW(tmpdir, tmp_dir_name);
436  lstrcatW(tmpdir, tmp_dir_name);
439  "CreateDirectoryW with multiple nonexistent directories in path should fail ret %u err %u\n",
440  ret, GetLastError());
442  ok(ret == FALSE, "RemoveDirectoryW should have failed\n");
443 
444  SetCurrentDirectoryW(curdir);
445 }
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
#define TRUE
Definition: types.h:120
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:413
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define lstrlenW
Definition: compat.h:407
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:2079
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:732
static char tmpdir[MAX_PATH]
Definition: shlexec.c:59
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
int ret
BOOL WINAPI SetCurrentDirectoryW(IN LPCWSTR lpPathName)
Definition: path.c:2248
#define ok(value,...)
Definition: atltest.h:57
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2312
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
static const WCHAR dotdotW[]
Definition: directory.c:81
#define ERROR_INVALID_NAME
Definition: compat.h:93
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
#define win_skip
Definition: test.h:141
static const WCHAR dotW[]
Definition: directory.c:80
static const WCHAR slashW[]
Definition: devenum.c:59

Referenced by START_TEST().

◆ test_GetSystemDirectoryA()

static void test_GetSystemDirectoryA ( void  )
static

Definition at line 117 of file directory.c.

118 {
119  UINT len, len_with_null;
120  char buf[MAX_PATH];
121 
122  len_with_null = GetSystemDirectoryA(NULL, 0);
123  ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH\n");
124 
125  lstrcpyA(buf, "foo");
127  ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer\n");
128  ok(len == len_with_null, "GetSystemDirectoryA returned %d, expected %d\n",
129  len, len_with_null);
130 
131  lstrcpyA(buf, "foo");
132  len = GetSystemDirectoryA(buf, len_with_null - 1);
133  ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer\n");
134  ok(len == len_with_null, "GetSystemDirectoryA returned %d, expected %d\n",
135  len, len_with_null);
136 
137  lstrcpyA(buf, "foo");
138  len = GetSystemDirectoryA(buf, len_with_null);
139  ok(lstrcmpA(buf, "foo") != 0, "should touch the buffer\n");
140  ok(len == strlen(buf), "returned length should be equal to the length of string\n");
141  ok(len == len_with_null-1, "GetSystemDirectoryW returned %d, expected %d\n",
142  len, len_with_null-1);
143 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2282
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
smooth NULL
Definition: ftsmooth.c:416
#define MAX_PATH
Definition: compat.h:26
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
GLenum GLsizei len
Definition: glext.h:6722
#define ok(value,...)
Definition: atltest.h:57
unsigned int UINT
Definition: ndis.h:50

Referenced by START_TEST().

◆ test_GetSystemDirectoryW()

static void test_GetSystemDirectoryW ( void  )
static

Definition at line 145 of file directory.c.

146 {
147  UINT len, len_with_null;
148  WCHAR buf[MAX_PATH];
149  static const WCHAR fooW[] = {'f','o','o',0};
150 
151  len_with_null = GetSystemDirectoryW(NULL, 0);
152  if (len_with_null == 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
153  {
154  win_skip("GetSystemDirectoryW is not available\n");
155  return;
156  }
157  ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH\n");
158 
159  lstrcpyW(buf, fooW);
161  ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer\n");
162  ok(len == len_with_null, "GetSystemDirectoryW returned %d, expected %d\n",
163  len, len_with_null);
164 
165  lstrcpyW(buf, fooW);
166  len = GetSystemDirectoryW(buf, len_with_null - 1);
167  ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer\n");
168  ok(len == len_with_null, "GetSystemDirectoryW returned %d, expected %d\n",
169  len, len_with_null);
170 
171  lstrcpyW(buf, fooW);
172  len = GetSystemDirectoryW(buf, len_with_null);
173  ok(lstrcmpW(buf, fooW) != 0, "should touch the buffer\n");
174  ok(len == lstrlenW(buf), "returned length should be equal to the length of string\n");
175  ok(len == len_with_null-1, "GetSystemDirectoryW returned %d, expected %d\n",
176  len, len_with_null-1);
177 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define lstrlenW
Definition: compat.h:407
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
static const WCHAR fooW[]
Definition: locale.c:44
GLenum GLsizei len
Definition: glext.h:6722
#define lstrcpyW
Definition: compat.h:406
#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
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_GetWindowsDirectoryA()

static void test_GetWindowsDirectoryA ( void  )
static

Definition at line 53 of file directory.c.

54 {
55  UINT len, len_with_null;
56  char buf[MAX_PATH];
57 
58  len_with_null = GetWindowsDirectoryA(NULL, 0);
59  ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH\n");
60 
61  lstrcpyA(buf, "foo");
62  len_with_null = GetWindowsDirectoryA(buf, 1);
63  ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer\n");
64 
65  lstrcpyA(buf, "foo");
66  len = GetWindowsDirectoryA(buf, len_with_null - 1);
67  ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer\n");
68  ok(len == len_with_null, "GetWindowsDirectoryW returned %d, expected %d\n",
69  len, len_with_null);
70 
71  lstrcpyA(buf, "foo");
72  len = GetWindowsDirectoryA(buf, len_with_null);
73  ok(lstrcmpA(buf, "foo") != 0, "should touch the buffer\n");
74  ok(len == strlen(buf), "returned length should be equal to the length of string\n");
75  ok(len == len_with_null-1, "GetWindowsDirectoryA returned %d, expected %d\n",
76  len, len_with_null-1);
77 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
smooth NULL
Definition: ftsmooth.c:416
#define MAX_PATH
Definition: compat.h:26
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
GLenum GLsizei len
Definition: glext.h:6722
#define ok(value,...)
Definition: atltest.h:57
UINT WINAPI GetWindowsDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2336
unsigned int UINT
Definition: ndis.h:50

Referenced by START_TEST().

◆ test_GetWindowsDirectoryW()

static void test_GetWindowsDirectoryW ( void  )
static

Definition at line 79 of file directory.c.

80 {
81  UINT len, len_with_null;
83  static const WCHAR fooW[] = {'f','o','o',0};
84 
85  len_with_null = GetWindowsDirectoryW(NULL, 0);
86  if (len_with_null == 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
87  {
88  win_skip("GetWindowsDirectoryW is not implemented\n");
89  return;
90  }
91  ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH\n");
92 
93  lstrcpyW(buf, fooW);
95  ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer\n");
96  ok(len == len_with_null, "GetWindowsDirectoryW returned %d, expected %d\n",
97  len, len_with_null);
98 
99  lstrcpyW(buf, fooW);
100  len = GetWindowsDirectoryW(buf, len_with_null - 1);
101  ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer\n");
102  ok(len == len_with_null, "GetWindowsDirectoryW returned %d, expected %d\n",
103  len, len_with_null);
104 
105  lstrcpyW(buf, fooW);
106  len = GetWindowsDirectoryW(buf, len_with_null);
107  ok(lstrcmpW(buf, fooW) != 0, "should touch the buffer\n");
108  ok(len == lstrlenW(buf), "returned length should be equal to the length of string\n");
109  ok(len == len_with_null-1, "GetWindowsDirectoryW returned %d, expected %d\n",
110  len, len_with_null-1);
111 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define lstrlenW
Definition: compat.h:407
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2351
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
static const WCHAR fooW[]
Definition: locale.c:44
GLenum GLsizei len
Definition: glext.h:6722
#define lstrcpyW
Definition: compat.h:406
#define ok(value,...)
Definition: atltest.h:57
unsigned int UINT
Definition: ndis.h:50
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_granted_access()

static void test_granted_access ( HANDLE  handle,
ACCESS_MASK  access,
int  line 
)
static

Definition at line 38 of file directory.c.

39 {
40  OBJECT_BASIC_INFORMATION obj_info;
42 
43  status = pNtQueryObject(handle, ObjectBasicInformation, &obj_info,
44  sizeof(obj_info), NULL);
45  ok_(__FILE__, line)(!status, "NtQueryObject with err: %08x\n", status);
46  ok_(__FILE__, line)(obj_info.GrantedAccess == access, "Granted access should "
47  "be 0x%08x, instead of 0x%08x\n", access, obj_info.GrantedAccess);
48 }
LONG NTSTATUS
Definition: precomp.h:26
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
ACCESS_MASK GrantedAccess
Definition: winternl.h:1251
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
static SERVICE_STATUS status
Definition: service.c:31
#define ok_(x1, x2)
Definition: atltest.h:61
Definition: ps.c:97

◆ test_RemoveDirectoryA()

static void test_RemoveDirectoryA ( void  )
static

Definition at line 447 of file directory.c.

448 {
449  char curdir[MAX_PATH];
450  char tmpdir[MAX_PATH];
451  BOOL ret;
452 
454  lstrcatA(tmpdir, "Please Remove Me");
456  ok(ret == TRUE, "CreateDirectoryA should always succeed\n");
457 
459  ok(SetCurrentDirectoryA(tmpdir), "SetCurrentDirectoryA failed\n");
460 
461  SetLastError(0xdeadbeef);
462  ok(!RemoveDirectoryA(tmpdir), "RemoveDirectoryA succeeded\n");
464  "Expected ERROR_SHARING_VIOLATION, got %u\n", GetLastError());
465 
468 
469  SetCurrentDirectoryA(curdir);
471  ok(ret == TRUE, "RemoveDirectoryA should always succeed\n");
472 
473  lstrcatA(tmpdir, "?");
477  "RemoveDirectoryA with ? wildcard name should fail, ret=%s error=%d\n",
478  ret ? " True" : "False", GetLastError());
479 
480  tmpdir[lstrlenA(tmpdir) - 1] = '*';
484  "RemoveDirectoryA with * wildcard name should fail, ret=%s error=%d\n",
485  ret ? " True" : "False", GetLastError());
486 }
#define TRUE
Definition: types.h:120
PPEB Peb
Definition: dllmain.c:27
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define FILE_TRAVERSE
Definition: nt_native.h:643
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
smooth NULL
Definition: ftsmooth.c:416
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
static char tmpdir[MAX_PATH]
Definition: shlexec.c:59
#define MAX_PATH
Definition: compat.h:26
#define SetLastError(x)
Definition: compat.h:409
int ret
PRTL_USER_PROCESS_PARAMETERS ProcessParameters
Definition: btrfs_drv.h:1890
BOOL WINAPI SetCurrentDirectoryA(IN LPCSTR lpPathName)
Definition: path.c:2205
#define ERROR_SHARING_VIOLATION
Definition: winerror.h:135
#define SYNCHRONIZE
Definition: nt_native.h:61
#define TEST_GRANTED_ACCESS(a, b)
Definition: directory.c:37
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2053
#define ok(value,...)
Definition: atltest.h:57
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2145
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:714
HANDLE Handle
Definition: rtltypes.h:1363
#define ERROR_INVALID_NAME
Definition: compat.h:93
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106

Referenced by START_TEST().

◆ test_RemoveDirectoryW()

static void test_RemoveDirectoryW ( void  )
static

Definition at line 488 of file directory.c.

489 {
490  WCHAR curdir[MAX_PATH];
492  BOOL ret;
493  static const WCHAR tmp_dir_name[] = {'P','l','e','a','s','e',' ','R','e','m','o','v','e',' ','M','e',0};
494  static const WCHAR questionW[] = {'?',0};
495 
497  lstrcatW(tmpdir, tmp_dir_name);
500  {
501  win_skip("CreateDirectoryW is not available\n");
502  return;
503  }
504 
505  ok(ret == TRUE, "CreateDirectoryW should always succeed\n");
506 
508  ok(SetCurrentDirectoryW(tmpdir), "SetCurrentDirectoryW failed\n");
509 
510  SetLastError(0xdeadbeef);
511  ok(!RemoveDirectoryW(tmpdir), "RemoveDirectoryW succeeded\n");
513  "Expected ERROR_SHARING_VIOLATION, got %u\n", GetLastError());
514 
517 
518  SetCurrentDirectoryW(curdir);
520  ok(ret == TRUE, "RemoveDirectoryW should always succeed\n");
521 
522  lstrcatW(tmpdir, questionW);
525  "RemoveDirectoryW with wildcard should fail with error 183, ret=%s error=%d\n",
526  ret ? " True" : "False", GetLastError());
527 
528  tmpdir[lstrlenW(tmpdir) - 1] = '*';
531  "RemoveDirectoryW with * wildcard name should fail with error 183, ret=%s error=%d\n",
532  ret ? " True" : "False", GetLastError());
533 }
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
#define TRUE
Definition: types.h:120
PPEB Peb
Definition: dllmain.c:27
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:413
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define lstrlenW
Definition: compat.h:407
#define FILE_TRAVERSE
Definition: nt_native.h:643
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:2079
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:732
static char tmpdir[MAX_PATH]
Definition: shlexec.c:59
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
#define SetLastError(x)
Definition: compat.h:409
int ret
PRTL_USER_PROCESS_PARAMETERS ProcessParameters
Definition: btrfs_drv.h:1890
#define ERROR_SHARING_VIOLATION
Definition: winerror.h:135
#define SYNCHRONIZE
Definition: nt_native.h:61
#define TEST_GRANTED_ACCESS(a, b)
Definition: directory.c:37
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
BOOL WINAPI SetCurrentDirectoryW(IN LPCWSTR lpPathName)
Definition: path.c:2248
#define ok(value,...)
Definition: atltest.h:57
HANDLE Handle
Definition: rtltypes.h:1363
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
#define ERROR_INVALID_NAME
Definition: compat.h:93
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_SetCurrentDirectoryA()

static void test_SetCurrentDirectoryA ( void  )
static

Definition at line 535 of file directory.c.

536 {
537  SetLastError(0);
538  ok( !SetCurrentDirectoryA( "\\some_dummy_dir" ), "SetCurrentDirectoryA succeeded\n" );
539  ok( GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %d\n", GetLastError() );
540  ok( !SetCurrentDirectoryA( "\\some_dummy\\subdir" ), "SetCurrentDirectoryA succeeded\n" );
541  ok( GetLastError() == ERROR_PATH_NOT_FOUND, "wrong error %d\n", GetLastError() );
542 }
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define SetLastError(x)
Definition: compat.h:409
BOOL WINAPI SetCurrentDirectoryA(IN LPCSTR lpPathName)
Definition: path.c:2205
#define ok(value,...)
Definition: atltest.h:57
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106

Referenced by START_TEST().

Variable Documentation

◆ OBJECT_INFORMATION_CLASS

Definition at line 29 of file directory.c.

◆ PULONG

Definition at line 29 of file directory.c.

◆ PVOID

Definition at line 29 of file directory.c.

◆ ULONG

Definition at line 29 of file directory.c.