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
11 * NOTE: This test supposes the following requirements:
12 * - There is a disk attached to the letter "C:"
13 * - There is a Windows-like system installed in "C:\<installation_directory>"
14 * which contains a sub-directory "system32"
15 * - There is no sub-directory called "foobar" in "C:\".
17 * If one of these requirements is not fulfilled, one or more tests may fail.
20 static CHAR OSDirA
[MAX_PATH
]; // OS directory
21 static WCHAR OSDirW
[MAX_PATH
];
22 static CHAR baseA
[MAX_PATH
]; // Current directory
23 static WCHAR baseW
[MAX_PATH
];
24 static CHAR selfnameA
[MAX_PATH
]; // Path to this executable
25 static WCHAR selfnameW
[MAX_PATH
];
26 static LPSTR exenameA
; // Executable's name
27 static LPWSTR exenameW
;
33 * Fixes definition of Wine's ok_err
39 #define ok_err(error) \
40 ok(GetLastError() == (error), "Wrong last error. Expected %lu, got %lu\n", (DWORD)(error), GetLastError())
44 * Types of tests. Define them as macros so that calling them
45 * into the code reports the actual line where they were called.
47 #define testType1_A(lpFileName, dwInitialError, hExpectedHandleValue, dwExpectedError, bExpectedNullFilename) \
49 ZeroMemory(&fd, sizeof(fd)); \
50 SetLastError((dwInitialError)); \
51 h = FindFirstFileA((lpFileName), &fd); \
52 ok(h == (hExpectedHandleValue), "FindFirstFileA returned 0x%p, expected 0x%p\n", h, (hExpectedHandleValue)); \
53 ok_err(dwExpectedError); \
54 if (bExpectedNullFilename) \
55 ok(fd.cFileName[0] == 0, "fd.cFileName != \"\"\n"); \
57 ok(fd.cFileName[0] != 0, "fd.cFileName == \"\"\n"); \
61 #define testType1_W(lpFileName, dwInitialError, hExpectedHandleValue, dwExpectedError, bExpectedNullFilename) \
63 ZeroMemory(&fd, sizeof(fd)); \
64 SetLastError((dwInitialError)); \
65 h = FindFirstFileW((lpFileName), &fd); \
66 ok(h == (hExpectedHandleValue), "FindFirstFileW returned 0x%p, expected 0x%p\n", h, (hExpectedHandleValue)); \
67 ok_err(dwExpectedError); \
68 if (bExpectedNullFilename) \
69 ok(fd.cFileName[0] == 0, "fd.cFileName != \"\"\n"); \
71 ok(fd.cFileName[0] != 0, "fd.cFileName == \"\"\n"); \
75 #define testType2_A(lpFileName, dwInitialError, hUnexpectedHandleValue, dwExpectedError) \
77 ZeroMemory(&fd, sizeof(fd)); \
78 SetLastError((dwInitialError)); \
79 h = FindFirstFileA((lpFileName), &fd); \
80 ok(h != (hUnexpectedHandleValue), "FindFirstFileA returned 0x%p\n", h); \
81 ok_err(dwExpectedError); \
82 ok(fd.cFileName[0] != 0, "fd.cFileName == \"\"\n"); \
86 #define testType2_W(lpFileName, dwInitialError, hUnexpectedHandleValue, dwExpectedError) \
88 ZeroMemory(&fd, sizeof(fd)); \
89 SetLastError((dwInitialError)); \
90 h = FindFirstFileW((lpFileName), &fd); \
91 ok(h != (hUnexpectedHandleValue), "FindFirstFileW returned 0x%p\n", h); \
92 ok_err(dwExpectedError); \
93 ok(fd.cFileName[0] != 0, "fd.cFileName == \"\"\n"); \
98 static void Test_FindFirstFileA(void)
100 CHAR CurrentDirectory
[MAX_PATH
];
101 CHAR Buffer
[MAX_PATH
];
105 /* Save the current directory */
106 GetCurrentDirectoryA(sizeof(CurrentDirectory
) / sizeof(CHAR
), CurrentDirectory
);
108 /*** Tests for the root directory - root directory ***/
109 /* Modify the current directory */
110 SetCurrentDirectoryA("C:\\");
112 testType1_A("C:", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
114 testType1_A("C:\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
115 testType1_A("C:\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
116 testType2_A("C:\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
118 testType1_A("\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
119 testType1_A("\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_INVALID_NAME
, TRUE
);
120 testType2_A("\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
122 /* Restore the old current directory */
123 SetCurrentDirectoryA(CurrentDirectory
);
124 /*****************************************************/
126 /*** Tests for the root directory - long directory ***/
127 /* Modify the current directory */
128 SetCurrentDirectoryA(OSDirA
); /* We expect here that OSDir is of the form: C:\OSDir */
130 testType2_A("C:", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
132 testType1_A("C:\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
133 testType1_A("C:\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
134 testType2_A("C:\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
136 testType1_A("\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
137 testType1_A("\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_INVALID_NAME
, TRUE
);
138 testType2_A("\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
140 /* Restore the old current directory */
141 SetCurrentDirectoryA(CurrentDirectory
);
142 /*****************************************************/
144 /*** Relative paths ***/
146 * NOTE: This test does not give the same results if you launch the app
147 * from a root drive or from a long-form directory (of the form C:\dir).
149 // testType2_A("..", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
150 // testType1_A("..", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE);
151 /**********************/
153 /*** Relative paths - root directory ***/
154 /* Modify the current directory */
155 SetCurrentDirectoryA("C:\\");
157 testType1_A(".", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
158 testType1_A(".\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
159 testType1_A(".\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
160 testType2_A(".\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
162 testType1_A("..", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
163 testType1_A("..\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
164 testType1_A("..\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
165 testType2_A("..\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
167 /* Restore the old current directory */
168 SetCurrentDirectoryA(CurrentDirectory
);
169 /***************************************/
171 /*** Relative paths - long directory ***/
172 /* Modify the current directory */
173 SetCurrentDirectoryA(OSDirA
); /* We expect here that OSDir is of the form: C:\OSDir */
175 testType2_A(".", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
177 testType1_A(".\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
178 testType1_A(".\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
179 testType2_A(".\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
181 testType1_A("..", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
183 testType1_A("..\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
184 testType1_A("..\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
185 testType2_A("..\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
187 /* Restore the old current directory */
188 SetCurrentDirectoryA(CurrentDirectory
);
189 /****************************************/
191 /*** Unexisting path ***/
192 testType1_A("C:\\foobar", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
193 testType1_A("C:\\foobar\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
194 testType1_A("C:\\foobar\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
195 testType1_A("C:\\foobar\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
196 testType1_A("C:\\foobar\\system32\\..\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
198 /* Possibly a DOS device */
199 testType1_A("C:\\foobar\\nul", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
200 testType1_A("C:\\foobar\\nul\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
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
);
204 testType1_A("C:\\foobar\\toto", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
205 testType1_A("C:\\foobar\\toto\\", 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
);
209 strcpy(Buffer
, "C:\\foobar\\");
210 strcat(Buffer
, exenameA
);
211 testType1_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
213 strcpy(Buffer
, "C:\\foobar\\.\\");
214 strcat(Buffer
, exenameA
);
215 testType1_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
216 /***********************/
218 /*** Existing path ***/
219 strcpy(Buffer
, OSDirA
);
220 testType2_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
222 strcpy(Buffer
, OSDirA
);
223 strcat(Buffer
, "\\");
224 testType1_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
226 strcpy(Buffer
, OSDirA
);
227 strcat(Buffer
, "\\\\");
228 testType1_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
230 strcpy(Buffer
, OSDirA
);
231 strcat(Buffer
, "\\*");
232 testType2_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
234 strcpy(Buffer
, OSDirA
);
235 strcat(Buffer
, "\\.\\*");
236 testType2_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
238 strcpy(Buffer
, OSDirA
);
239 strcat(Buffer
, "\\system32\\..\\*");
240 testType2_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
242 /* Possibly a DOS device */
243 strcpy(Buffer
, OSDirA
);
244 strcat(Buffer
, "\\nul");
245 testType1_A(Buffer
, 0xdeadbeef, (HANDLE
)0x00000001, 0xdeadbeef, FALSE
);
247 strcpy(Buffer
, OSDirA
);
248 strcat(Buffer
, "\\nul\\");
249 testType1_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
251 strcpy(Buffer
, OSDirA
);
252 strcat(Buffer
, "\\nul\\\\");
253 testType1_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
255 strcpy(Buffer
, OSDirA
);
256 strcat(Buffer
, "\\nul\\*");
257 testType1_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
259 strcpy(Buffer
, OSDirA
);
260 strcat(Buffer
, "\\toto");
261 testType1_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
263 strcpy(Buffer
, OSDirA
);
264 strcat(Buffer
, "\\toto\\");
265 testType1_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
267 strcpy(Buffer
, OSDirA
);
268 strcat(Buffer
, "\\toto\\\\");
269 testType1_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
271 strcpy(Buffer
, OSDirA
);
272 strcat(Buffer
, "\\toto\\*");
273 testType1_A(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
275 // strcpy(Buffer, baseA);
276 // strcat(Buffer, "\\");
277 // strcat(Buffer, exenameA);
278 // testType2_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
280 // strcpy(Buffer, baseA);
281 // strcat(Buffer, "\\.\\");
282 // strcat(Buffer, exenameA);
283 // testType2_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
284 /*********************/
289 static void Test_FindFirstFileW(void)
291 WCHAR CurrentDirectory
[MAX_PATH
];
292 WCHAR Buffer
[MAX_PATH
];
296 /* Save the current directory */
297 GetCurrentDirectoryW(sizeof(CurrentDirectory
) / sizeof(WCHAR
), CurrentDirectory
);
299 /*** Tests for the root directory - root directory ***/
300 /* Modify the current directory */
301 SetCurrentDirectoryW(L
"C:\\");
303 testType1_W(L
"C:", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
305 testType1_W(L
"C:\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
306 testType1_W(L
"C:\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
307 testType2_W(L
"C:\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
309 testType1_W(L
"\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
310 testType1_W(L
"\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_INVALID_NAME
, TRUE
);
311 testType2_W(L
"\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
313 /* Restore the old current directory */
314 SetCurrentDirectoryW(CurrentDirectory
);
315 /*****************************************************/
317 /*** Tests for the root directory - long directory ***/
318 /* Modify the current directory */
319 SetCurrentDirectoryW(OSDirW
); /* We expect here that OSDir is of the form: C:\OSDir */
321 testType2_W(L
"C:", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
323 testType1_W(L
"C:\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
324 testType1_W(L
"C:\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
325 testType2_W(L
"C:\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
327 testType1_W(L
"\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
328 testType1_W(L
"\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_INVALID_NAME
, TRUE
);
329 testType2_W(L
"\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
331 /* Restore the old current directory */
332 SetCurrentDirectoryW(CurrentDirectory
);
333 /*****************************************************/
335 /*** Relative paths ***/
337 * NOTE: This test does not give the same results if you launch the app
338 * from a root drive or from a long-form directory (of the form C:\dir).
340 // testType2_W(L"..", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
341 // testType1_W(L"..", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE);
342 /**********************/
344 /*** Relative paths - root directory ***/
345 /* Modify the current directory */
346 SetCurrentDirectoryW(L
"C:\\");
348 testType1_W(L
".", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
349 testType1_W(L
".\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
350 testType1_W(L
".\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
351 testType2_W(L
".\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
353 testType1_W(L
"..", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
354 testType1_W(L
"..\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
355 testType1_W(L
"..\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
356 testType2_W(L
"..\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
358 /* Restore the old current directory */
359 SetCurrentDirectoryW(CurrentDirectory
);
360 /***************************************/
362 /*** Relative paths - long directory ***/
363 /* Modify the current directory */
364 SetCurrentDirectoryW(OSDirW
); /* We expect here that OSDir is of the form: C:\OSDir */
366 testType2_W(L
".", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
368 testType1_W(L
".\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
369 testType1_W(L
".\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
370 testType2_W(L
".\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
372 testType1_W(L
"..", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
374 testType1_W(L
"..\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
375 testType1_W(L
"..\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
376 testType2_W(L
"..\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
378 /* Restore the old current directory */
379 SetCurrentDirectoryW(CurrentDirectory
);
380 /****************************************/
382 /*** Unexisting path ***/
383 testType1_W(L
"C:\\foobar", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
384 testType1_W(L
"C:\\foobar\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
385 testType1_W(L
"C:\\foobar\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
386 testType1_W(L
"C:\\foobar\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
387 testType1_W(L
"C:\\foobar\\system32\\..\\*", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
389 /* Possibly a DOS device */
390 testType1_W(L
"C:\\foobar\\nul", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
391 testType1_W(L
"C:\\foobar\\nul\\", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
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
);
395 testType1_W(L
"C:\\foobar\\toto", 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
396 testType1_W(L
"C:\\foobar\\toto\\", 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
);
400 wcscpy(Buffer
, L
"C:\\foobar\\");
401 wcscat(Buffer
, exenameW
);
402 testType1_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
404 wcscpy(Buffer
, L
"C:\\foobar\\.\\");
405 wcscat(Buffer
, exenameW
);
406 testType1_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
407 /***********************/
409 /*** Existing path ***/
410 wcscpy(Buffer
, OSDirW
);
411 testType2_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
413 wcscpy(Buffer
, OSDirW
);
414 wcscat(Buffer
, L
"\\");
415 testType1_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
417 wcscpy(Buffer
, OSDirW
);
418 wcscat(Buffer
, L
"\\\\");
419 testType1_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
421 wcscpy(Buffer
, OSDirW
);
422 wcscat(Buffer
, L
"\\*");
423 testType2_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
425 wcscpy(Buffer
, OSDirW
);
426 wcscat(Buffer
, L
"\\.\\*");
427 testType2_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
429 wcscpy(Buffer
, OSDirW
);
430 wcscat(Buffer
, L
"\\system32\\..\\*");
431 testType2_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, 0xdeadbeef);
433 /* Possibly a DOS device */
434 wcscpy(Buffer
, OSDirW
);
435 wcscat(Buffer
, L
"\\nul");
436 testType1_W(Buffer
, 0xdeadbeef, (HANDLE
)0x00000001, 0xdeadbeef, FALSE
);
438 wcscpy(Buffer
, OSDirW
);
439 wcscat(Buffer
, L
"\\nul\\");
440 testType1_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
442 wcscpy(Buffer
, OSDirW
);
443 wcscat(Buffer
, L
"\\nul\\\\");
444 testType1_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
446 wcscpy(Buffer
, OSDirW
);
447 wcscat(Buffer
, L
"\\nul\\*");
448 testType1_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
450 wcscpy(Buffer
, OSDirW
);
451 wcscat(Buffer
, L
"\\toto");
452 testType1_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_FILE_NOT_FOUND
, TRUE
);
454 wcscpy(Buffer
, OSDirW
);
455 wcscat(Buffer
, L
"\\toto\\");
456 testType1_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
458 wcscpy(Buffer
, OSDirW
);
459 wcscat(Buffer
, L
"\\toto\\\\");
460 testType1_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
462 wcscpy(Buffer
, OSDirW
);
463 wcscat(Buffer
, L
"\\toto\\*");
464 testType1_W(Buffer
, 0xdeadbeef, INVALID_HANDLE_VALUE
, ERROR_PATH_NOT_FOUND
, TRUE
);
466 // wcscpy(Buffer, baseW);
467 // wcscat(Buffer, L"\\");
468 // wcscat(Buffer, exenameW);
469 // testType2_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
471 // wcscpy(Buffer, baseW);
472 // wcscat(Buffer, L"\\.\\");
473 // wcscat(Buffer, exenameW);
474 // testType2_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
475 /*********************/
481 static int init(void)
486 myARGC
= winetest_get_mainargs(&myARGV
);
487 if (!GetCurrentDirectoryA(sizeof(baseA
)/sizeof(baseA
[0]), baseA
)) return 0;
488 strcpy(selfnameA
, myARGV
[0]);
490 /* Strip the path of selfname */
491 if ((p
= strrchr(selfnameA
, '\\')) != NULL
)
494 exenameA
= selfnameA
;
496 if ((p
= strrchr(exenameA
, '/')) != NULL
)
499 if (!GetWindowsDirectoryA(OSDirA
, sizeof(OSDirA
)/sizeof(OSDirA
[0]))) return 0;
501 /* Quick-and-dirty conversion ANSI --> UNICODE without the Win32 APIs */
502 for (i
= 0 ; i
<= strlen(baseA
) ; ++i
)
504 baseW
[i
] = (WCHAR
)baseA
[i
];
506 for (i
= 0 ; i
<= strlen(selfnameA
) ; ++i
)
508 selfnameW
[i
] = (WCHAR
)selfnameA
[i
];
510 exenameW
= selfnameW
+ (exenameA
- selfnameA
);
511 for (i
= 0 ; i
<= strlen(OSDirA
) ; ++i
)
513 OSDirW
[i
] = (WCHAR
)OSDirA
[i
];
519 START_TEST(FindFiles
)
522 ok(b
, "Basic init of FindFiles test\n");
525 Test_FindFirstFileA();
526 Test_FindFirstFileW();