2 * PROJECT: ReactOS api tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Tests for the Find*File*A/W APIs.
5 * PROGRAMMER: Hermès BÉLUSCA - MAÏTO
13 * NOTE: This test supposes the following requirements:
14 * - There is a disk attached to the letter "C:"
15 * - There is a Windows-like system installed in "C:\<installation_directory>"
16 * which contains a sub-directory "system32"
17 * - There is no sub-directory called "foobar" in "C:\".
19 * If one of these requirements is not fulfilled, one or more tests may fail.
22 static CHAR OSDirA
[MAX_PATH
]; // OS directory
23 static WCHAR OSDirW
[MAX_PATH
];
24 static CHAR baseA
[MAX_PATH
]; // Current directory
25 static WCHAR baseW
[MAX_PATH
];
26 static CHAR selfnameA
[MAX_PATH
]; // Path to this executable
27 static WCHAR selfnameW
[MAX_PATH
];
28 static LPSTR exenameA
; // Executable's name
29 static LPWSTR exenameW
;
35 * Fixes definition of Wine's ok_err
41 #define ok_err(error) \
42 ok(GetLastError() == (error), "Wrong last error. Expected %lu, got %lu\n", (DWORD)(error), GetLastError())
46 * Types of tests. Define them as macros so that calling them
47 * into the code reports the actual line where they were called.
49 #define testType1_A(lpFileName, dwInitialError, hExpectedHandleValue, dwExpectedError, bExpectedNullFilename) \
51 ZeroMemory(&fd, sizeof(fd)); \
52 SetLastError((dwInitialError)); \
53 h = FindFirstFileA((lpFileName), &fd); \
54 ok(h == (hExpectedHandleValue), "FindFirstFileA returned 0x%p, expected 0x%p\n", h, (hExpectedHandleValue)); \
55 ok_err(dwExpectedError); \
56 if (bExpectedNullFilename) \
57 ok(fd.cFileName[0] == 0, "fd.cFileName != \"\"\n"); \
59 ok(fd.cFileName[0] != 0, "fd.cFileName == \"\"\n"); \
63 #define testType1_W(lpFileName, dwInitialError, hExpectedHandleValue, dwExpectedError, bExpectedNullFilename) \
65 ZeroMemory(&fd, sizeof(fd)); \
66 SetLastError((dwInitialError)); \
67 h = FindFirstFileW((lpFileName), &fd); \
68 ok(h == (hExpectedHandleValue), "FindFirstFileW returned 0x%p, expected 0x%p\n", h, (hExpectedHandleValue)); \
69 ok_err(dwExpectedError); \
70 if (bExpectedNullFilename) \
71 ok(fd.cFileName[0] == 0, "fd.cFileName != \"\"\n"); \
73 ok(fd.cFileName[0] != 0, "fd.cFileName == \"\"\n"); \
77 #define testType2_A(lpFileName, dwInitialError, hUnexpectedHandleValue, dwExpectedError) \
79 ZeroMemory(&fd, sizeof(fd)); \
80 SetLastError((dwInitialError)); \
81 h = FindFirstFileA((lpFileName), &fd); \
82 ok(h != (hUnexpectedHandleValue), "FindFirstFileA returned 0x%p\n", h); \
83 ok_err(dwExpectedError); \
84 ok(fd.cFileName[0] != 0, "fd.cFileName == \"\"\n"); \
88 #define testType2_W(lpFileName, dwInitialError, hUnexpectedHandleValue, dwExpectedError) \
90 ZeroMemory(&fd, sizeof(fd)); \
91 SetLastError((dwInitialError)); \
92 h = FindFirstFileW((lpFileName), &fd); \
93 ok(h != (hUnexpectedHandleValue), "FindFirstFileW returned 0x%p\n", h); \
94 ok_err(dwExpectedError); \
95 ok(fd.cFileName[0] != 0, "fd.cFileName == \"\"\n"); \
100 static void Test_FindFirstFileA(void)
102 CHAR CurrentDirectory
[MAX_PATH
];
103 CHAR Buffer
[MAX_PATH
];
107 /* Save the current directory */
108 GetCurrentDirectoryA(sizeof(CurrentDirectory
) / sizeof(CHAR
), CurrentDirectory
);
110 /*** Tests for the root directory - root directory ***/
111 /* Modify the current directory */
112 SetCurrentDirectoryA("C:\\");
114 testType1_A("C:", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
116 testType1_A("C:\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
117 testType1_A("C:\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
118 testType2_A("C:\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
120 testType1_A("\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
121 testType1_A("\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_INVALID_NAME
, TRUE
);
122 testType2_A("\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
124 /* Restore the old current directory */
125 SetCurrentDirectoryA(CurrentDirectory
);
126 /*****************************************************/
128 /*** Tests for the root directory - long directory ***/
129 /* Modify the current directory */
130 SetCurrentDirectoryA(OSDirA
); /* We expect here that OSDir is of the form: C:\OSDir */
132 testType2_A("C:", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
134 testType1_A("C:\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
135 testType1_A("C:\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
136 testType2_A("C:\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
138 testType1_A("\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
139 testType1_A("\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_INVALID_NAME
, TRUE
);
140 testType2_A("\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
142 /* Restore the old current directory */
143 SetCurrentDirectoryA(CurrentDirectory
);
144 /*****************************************************/
146 /*** Relative paths ***/
148 * NOTE: This test does not give the same results if you launch the app
149 * from a root drive or from a long-form directory (of the form C:\dir).
151 // testType2_A("..", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
152 // testType1_A("..", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE);
153 /**********************/
155 /*** Relative paths - root directory ***/
156 /* Modify the current directory */
157 SetCurrentDirectoryA("C:\\");
159 testType1_A(".", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
160 testType1_A(".\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
161 testType1_A(".\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
162 testType2_A(".\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
164 testType1_A("..", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
165 testType1_A("..\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
166 testType1_A("..\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
167 testType2_A("..\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
169 /* Restore the old current directory */
170 SetCurrentDirectoryA(CurrentDirectory
);
171 /***************************************/
173 /*** Relative paths - long directory ***/
174 /* Modify the current directory */
175 SetCurrentDirectoryA(OSDirA
); /* We expect here that OSDir is of the form: C:\OSDir */
177 testType2_A(".", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
179 testType1_A(".\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
180 testType1_A(".\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
181 testType2_A(".\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
183 testType1_A("..", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
185 testType1_A("..\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
186 testType1_A("..\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
187 testType2_A("..\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
189 /* Restore the old current directory */
190 SetCurrentDirectoryA(CurrentDirectory
);
191 /****************************************/
193 /*** Unexisting path ***/
194 testType1_A("C:\\foobar", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
195 testType1_A("C:\\foobar\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
196 testType1_A("C:\\foobar\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
197 testType1_A("C:\\foobar\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
198 testType1_A("C:\\foobar\\system32\\..\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
200 /* Possibly a DOS device */
201 testType1_A("C:\\foobar\\nul", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
202 testType1_A("C:\\foobar\\nul\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
203 testType1_A("C:\\foobar\\nul\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
204 testType1_A("C:\\foobar\\nul\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
206 testType1_A("C:\\foobar\\toto", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
207 testType1_A("C:\\foobar\\toto\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
208 testType1_A("C:\\foobar\\toto\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
209 testType1_A("C:\\foobar\\toto\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
211 strcpy(Buffer
, "C:\\foobar\\");
212 strcat(Buffer
, exenameA
);
213 testType1_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
215 strcpy(Buffer
, "C:\\foobar\\.\\");
216 strcat(Buffer
, exenameA
);
217 testType1_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
218 /***********************/
220 /*** Existing path ***/
221 strcpy(Buffer
, OSDirA
);
222 testType2_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
224 strcpy(Buffer
, OSDirA
);
225 strcat(Buffer
, "\\");
226 testType1_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
228 strcpy(Buffer
, OSDirA
);
229 strcat(Buffer
, "\\\\");
230 testType1_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
232 strcpy(Buffer
, OSDirA
);
233 strcat(Buffer
, "\\*");
234 testType2_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
236 strcpy(Buffer
, OSDirA
);
237 strcat(Buffer
, "\\.\\*");
238 testType2_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
240 strcpy(Buffer
, OSDirA
);
241 strcat(Buffer
, "\\system32\\..\\*");
242 testType2_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
244 /* Possibly a DOS device */
245 strcpy(Buffer
, OSDirA
);
246 strcat(Buffer
, "\\nul");
247 testType1_A(Buffer
, 0xdeadbeef, (HANDLE
)0x00000001, 0xdeadbeef, FALSE
);
249 strcpy(Buffer
, OSDirA
);
250 strcat(Buffer
, "\\nul\\");
251 testType1_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
253 strcpy(Buffer
, OSDirA
);
254 strcat(Buffer
, "\\nul\\\\");
255 testType1_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
257 strcpy(Buffer
, OSDirA
);
258 strcat(Buffer
, "\\nul\\*");
259 testType1_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
261 strcpy(Buffer
, OSDirA
);
262 strcat(Buffer
, "\\toto");
263 testType1_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
265 strcpy(Buffer
, OSDirA
);
266 strcat(Buffer
, "\\toto\\");
267 testType1_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
269 strcpy(Buffer
, OSDirA
);
270 strcat(Buffer
, "\\toto\\\\");
271 testType1_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
273 strcpy(Buffer
, OSDirA
);
274 strcat(Buffer
, "\\toto\\*");
275 testType1_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
277 // strcpy(Buffer, baseA);
278 // strcat(Buffer, "\\");
279 // strcat(Buffer, exenameA);
280 // testType2_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
282 // strcpy(Buffer, baseA);
283 // strcat(Buffer, "\\.\\");
284 // strcat(Buffer, exenameA);
285 // testType2_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
286 /*********************/
291 static void Test_FindFirstFileW(void)
293 WCHAR CurrentDirectory
[MAX_PATH
];
294 WCHAR Buffer
[MAX_PATH
];
298 /* Save the current directory */
299 GetCurrentDirectoryW(sizeof(CurrentDirectory
) / sizeof(WCHAR
), CurrentDirectory
);
301 /*** Tests for the root directory - root directory ***/
302 /* Modify the current directory */
303 SetCurrentDirectoryW(L
"C:\\");
305 testType1_W(L
"C:", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
307 testType1_W(L
"C:\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
308 testType1_W(L
"C:\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
309 testType2_W(L
"C:\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
311 testType1_W(L
"\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
312 testType1_W(L
"\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_INVALID_NAME
, TRUE
);
313 testType2_W(L
"\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
315 /* Restore the old current directory */
316 SetCurrentDirectoryW(CurrentDirectory
);
317 /*****************************************************/
319 /*** Tests for the root directory - long directory ***/
320 /* Modify the current directory */
321 SetCurrentDirectoryW(OSDirW
); /* We expect here that OSDir is of the form: C:\OSDir */
323 testType2_W(L
"C:", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
325 testType1_W(L
"C:\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
326 testType1_W(L
"C:\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
327 testType2_W(L
"C:\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
329 testType1_W(L
"\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
330 testType1_W(L
"\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_INVALID_NAME
, TRUE
);
331 testType2_W(L
"\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
333 /* Restore the old current directory */
334 SetCurrentDirectoryW(CurrentDirectory
);
335 /*****************************************************/
337 /*** Relative paths ***/
339 * NOTE: This test does not give the same results if you launch the app
340 * from a root drive or from a long-form directory (of the form C:\dir).
342 // testType2_W(L"..", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
343 // testType1_W(L"..", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE);
344 /**********************/
346 /*** Relative paths - root directory ***/
347 /* Modify the current directory */
348 SetCurrentDirectoryW(L
"C:\\");
350 testType1_W(L
".", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
351 testType1_W(L
".\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
352 testType1_W(L
".\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
353 testType2_W(L
".\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
355 testType1_W(L
"..", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
356 testType1_W(L
"..\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
357 testType1_W(L
"..\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
358 testType2_W(L
"..\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
360 /* Restore the old current directory */
361 SetCurrentDirectoryW(CurrentDirectory
);
362 /***************************************/
364 /*** Relative paths - long directory ***/
365 /* Modify the current directory */
366 SetCurrentDirectoryW(OSDirW
); /* We expect here that OSDir is of the form: C:\OSDir */
368 testType2_W(L
".", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
370 testType1_W(L
".\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
371 testType1_W(L
".\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
372 testType2_W(L
".\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
374 testType1_W(L
"..", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
376 testType1_W(L
"..\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
377 testType1_W(L
"..\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
378 testType2_W(L
"..\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
380 /* Restore the old current directory */
381 SetCurrentDirectoryW(CurrentDirectory
);
382 /****************************************/
384 /*** Unexisting path ***/
385 testType1_W(L
"C:\\foobar", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
386 testType1_W(L
"C:\\foobar\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
387 testType1_W(L
"C:\\foobar\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
388 testType1_W(L
"C:\\foobar\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
389 testType1_W(L
"C:\\foobar\\system32\\..\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
391 /* Possibly a DOS device */
392 testType1_W(L
"C:\\foobar\\nul", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
393 testType1_W(L
"C:\\foobar\\nul\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
394 testType1_W(L
"C:\\foobar\\nul\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
395 testType1_W(L
"C:\\foobar\\nul\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
397 testType1_W(L
"C:\\foobar\\toto", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
398 testType1_W(L
"C:\\foobar\\toto\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
399 testType1_W(L
"C:\\foobar\\toto\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
400 testType1_W(L
"C:\\foobar\\toto\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
402 wcscpy(Buffer
, L
"C:\\foobar\\");
403 wcscat(Buffer
, exenameW
);
404 testType1_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
406 wcscpy(Buffer
, L
"C:\\foobar\\.\\");
407 wcscat(Buffer
, exenameW
);
408 testType1_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
409 /***********************/
411 /*** Existing path ***/
412 wcscpy(Buffer
, OSDirW
);
413 testType2_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
415 wcscpy(Buffer
, OSDirW
);
416 wcscat(Buffer
, L
"\\");
417 testType1_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
419 wcscpy(Buffer
, OSDirW
);
420 wcscat(Buffer
, L
"\\\\");
421 testType1_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
423 wcscpy(Buffer
, OSDirW
);
424 wcscat(Buffer
, L
"\\*");
425 testType2_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
427 wcscpy(Buffer
, OSDirW
);
428 wcscat(Buffer
, L
"\\.\\*");
429 testType2_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
431 wcscpy(Buffer
, OSDirW
);
432 wcscat(Buffer
, L
"\\system32\\..\\*");
433 testType2_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
435 /* Possibly a DOS device */
436 wcscpy(Buffer
, OSDirW
);
437 wcscat(Buffer
, L
"\\nul");
438 testType1_W(Buffer
, 0xdeadbeef, (HANDLE
)0x00000001, 0xdeadbeef, FALSE
);
440 wcscpy(Buffer
, OSDirW
);
441 wcscat(Buffer
, L
"\\nul\\");
442 testType1_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
444 wcscpy(Buffer
, OSDirW
);
445 wcscat(Buffer
, L
"\\nul\\\\");
446 testType1_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
448 wcscpy(Buffer
, OSDirW
);
449 wcscat(Buffer
, L
"\\nul\\*");
450 testType1_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
452 wcscpy(Buffer
, OSDirW
);
453 wcscat(Buffer
, L
"\\toto");
454 testType1_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
456 wcscpy(Buffer
, OSDirW
);
457 wcscat(Buffer
, L
"\\toto\\");
458 testType1_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
460 wcscpy(Buffer
, OSDirW
);
461 wcscat(Buffer
, L
"\\toto\\\\");
462 testType1_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
464 wcscpy(Buffer
, OSDirW
);
465 wcscat(Buffer
, L
"\\toto\\*");
466 testType1_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
468 // wcscpy(Buffer, baseW);
469 // wcscat(Buffer, L"\\");
470 // wcscat(Buffer, exenameW);
471 // testType2_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
473 // wcscpy(Buffer, baseW);
474 // wcscat(Buffer, L"\\.\\");
475 // wcscat(Buffer, exenameW);
476 // testType2_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
477 /*********************/
483 static int init(void)
488 myARGC
= winetest_get_mainargs(&myARGV
);
489 if (!GetCurrentDirectoryA(sizeof(baseA
)/sizeof(baseA
[0]), baseA
)) return 0;
490 strcpy(selfnameA
, myARGV
[0]);
492 /* Strip the path of selfname */
493 if ((p
= strrchr(selfnameA
, '\\')) != NULL
)
496 exenameA
= selfnameA
;
498 if ((p
= strrchr(exenameA
, '/')) != NULL
)
501 if (!GetWindowsDirectoryA(OSDirA
, sizeof(OSDirA
)/sizeof(OSDirA
[0]))) return 0;
503 /* Quick-and-dirty conversion ANSI --> UNICODE without the Win32 APIs */
504 for (i
= 0 ; i
<= strlen(baseA
) ; ++i
)
506 baseW
[i
] = (WCHAR
)baseA
[i
];
508 for (i
= 0 ; i
<= strlen(selfnameA
) ; ++i
)
510 selfnameW
[i
] = (WCHAR
)selfnameA
[i
];
512 exenameW
= selfnameW
+ (exenameA
- selfnameA
);
513 for (i
= 0 ; i
<= strlen(OSDirA
) ; ++i
)
515 OSDirW
[i
] = (WCHAR
)OSDirA
[i
];
521 START_TEST(FindFiles
)
524 ok(b
, "Basic init of FindFiles test\n");
527 Test_FindFirstFileA();
528 Test_FindFirstFileW();