1 /* 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 6 */ 7 8 #include "precomp.h" 9 10 /* 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:\". 16 * 17 * If one of these requirements is not fulfilled, one or more tests may fail. 18 */ 19 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; 28 static INT myARGC; 29 static LPSTR* myARGV; 30 31 32 /* 33 * Fixes definition of Wine's ok_err 34 */ 35 #ifdef ok_err 36 #undef ok_err 37 #endif 38 39 #define ok_err(error) \ 40 ok(GetLastError() == (error), "Wrong last error. Expected %lu, got %lu\n", (DWORD)(error), GetLastError()) 41 42 43 /* 44 * Types of tests. Define them as macros so that calling them 45 * into the code reports the actual line where they were called. 46 */ 47 #define testType1_A(lpFileName, dwInitialError, hExpectedHandleValue, dwExpectedError, bExpectedNullFilename) \ 48 do { \ 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"); \ 56 else \ 57 ok(fd.cFileName[0] != 0, "fd.cFileName == \"\"\n"); \ 58 FindClose(h); \ 59 } while (0) 60 61 #define testType1_W(lpFileName, dwInitialError, hExpectedHandleValue, dwExpectedError, bExpectedNullFilename) \ 62 do { \ 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"); \ 70 else \ 71 ok(fd.cFileName[0] != 0, "fd.cFileName == \"\"\n"); \ 72 FindClose(h); \ 73 } while (0) 74 75 #define testType2_A(lpFileName, dwInitialError, hUnexpectedHandleValue, dwExpectedError) \ 76 do { \ 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"); \ 83 FindClose(h); \ 84 } while (0) 85 86 #define testType2_W(lpFileName, dwInitialError, hUnexpectedHandleValue, dwExpectedError) \ 87 do { \ 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"); \ 94 FindClose(h); \ 95 } while (0) 96 97 98 static void Test_FindFirstFileA(void) 99 { 100 CHAR CurrentDirectory[MAX_PATH]; 101 CHAR Buffer[MAX_PATH]; 102 WIN32_FIND_DATAA fd; 103 HANDLE h; 104 105 /* Save the current directory */ 106 GetCurrentDirectoryA(sizeof(CurrentDirectory) / sizeof(CHAR), CurrentDirectory); 107 108 /*** Tests for the root directory - root directory ***/ 109 /* Modify the current directory */ 110 SetCurrentDirectoryA("C:\\"); 111 112 testType1_A("C:", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 113 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); 117 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); 121 122 /* Restore the old current directory */ 123 SetCurrentDirectoryA(CurrentDirectory); 124 /*****************************************************/ 125 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 */ 129 130 testType2_A("C:", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 131 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); 135 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); 139 140 /* Restore the old current directory */ 141 SetCurrentDirectoryA(CurrentDirectory); 142 /*****************************************************/ 143 144 /*** Relative paths ***/ 145 /* 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). 148 */ 149 // testType2_A("..", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 150 // testType1_A("..", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 151 /**********************/ 152 153 /*** Relative paths - root directory ***/ 154 /* Modify the current directory */ 155 SetCurrentDirectoryA("C:\\"); 156 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); 161 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); 166 167 /* Restore the old current directory */ 168 SetCurrentDirectoryA(CurrentDirectory); 169 /***************************************/ 170 171 /*** Relative paths - long directory ***/ 172 /* Modify the current directory */ 173 SetCurrentDirectoryA(OSDirA); /* We expect here that OSDir is of the form: C:\OSDir */ 174 175 testType2_A(".", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 176 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); 180 181 testType1_A("..", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 182 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); 186 187 /* Restore the old current directory */ 188 SetCurrentDirectoryA(CurrentDirectory); 189 /****************************************/ 190 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); 197 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); 203 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); 208 209 strcpy(Buffer, "C:\\foobar\\"); 210 strcat(Buffer, exenameA); 211 testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 212 213 strcpy(Buffer, "C:\\foobar\\.\\"); 214 strcat(Buffer, exenameA); 215 testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 216 /***********************/ 217 218 /*** Existing path ***/ 219 strcpy(Buffer, OSDirA); 220 testType2_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 221 222 strcpy(Buffer, OSDirA); 223 strcat(Buffer, "\\"); 224 testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 225 226 strcpy(Buffer, OSDirA); 227 strcat(Buffer, "\\\\"); 228 testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 229 230 strcpy(Buffer, OSDirA); 231 strcat(Buffer, "\\*"); 232 testType2_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 233 234 strcpy(Buffer, OSDirA); 235 strcat(Buffer, "\\.\\*"); 236 testType2_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 237 238 strcpy(Buffer, OSDirA); 239 strcat(Buffer, "\\system32\\..\\*"); 240 testType2_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 241 242 /* Possibly a DOS device */ 243 strcpy(Buffer, OSDirA); 244 strcat(Buffer, "\\nul"); 245 testType1_A(Buffer, 0xdeadbeef, (HANDLE)0x00000001, 0xdeadbeef, FALSE); 246 247 strcpy(Buffer, OSDirA); 248 strcat(Buffer, "\\nul\\"); 249 testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 250 251 strcpy(Buffer, OSDirA); 252 strcat(Buffer, "\\nul\\\\"); 253 testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 254 255 strcpy(Buffer, OSDirA); 256 strcat(Buffer, "\\nul\\*"); 257 testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 258 259 strcpy(Buffer, OSDirA); 260 strcat(Buffer, "\\toto"); 261 testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 262 263 strcpy(Buffer, OSDirA); 264 strcat(Buffer, "\\toto\\"); 265 testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 266 267 strcpy(Buffer, OSDirA); 268 strcat(Buffer, "\\toto\\\\"); 269 testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 270 271 strcpy(Buffer, OSDirA); 272 strcat(Buffer, "\\toto\\*"); 273 testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 274 275 // strcpy(Buffer, baseA); 276 // strcat(Buffer, "\\"); 277 // strcat(Buffer, exenameA); 278 // testType2_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 279 280 // strcpy(Buffer, baseA); 281 // strcat(Buffer, "\\.\\"); 282 // strcat(Buffer, exenameA); 283 // testType2_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 284 /*********************/ 285 286 return; 287 } 288 289 static void Test_FindFirstFileW(void) 290 { 291 WCHAR CurrentDirectory[MAX_PATH]; 292 WCHAR Buffer[MAX_PATH]; 293 WIN32_FIND_DATAW fd; 294 HANDLE h; 295 296 /* Save the current directory */ 297 GetCurrentDirectoryW(sizeof(CurrentDirectory) / sizeof(WCHAR), CurrentDirectory); 298 299 /*** Tests for the root directory - root directory ***/ 300 /* Modify the current directory */ 301 SetCurrentDirectoryW(L"C:\\"); 302 303 testType1_W(L"C:", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 304 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); 308 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); 312 313 /* Restore the old current directory */ 314 SetCurrentDirectoryW(CurrentDirectory); 315 /*****************************************************/ 316 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 */ 320 321 testType2_W(L"C:", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 322 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); 326 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); 330 331 /* Restore the old current directory */ 332 SetCurrentDirectoryW(CurrentDirectory); 333 /*****************************************************/ 334 335 /*** Relative paths ***/ 336 /* 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). 339 */ 340 // testType2_W(L"..", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 341 // testType1_W(L"..", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 342 /**********************/ 343 344 /*** Relative paths - root directory ***/ 345 /* Modify the current directory */ 346 SetCurrentDirectoryW(L"C:\\"); 347 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); 352 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); 357 358 /* Restore the old current directory */ 359 SetCurrentDirectoryW(CurrentDirectory); 360 /***************************************/ 361 362 /*** Relative paths - long directory ***/ 363 /* Modify the current directory */ 364 SetCurrentDirectoryW(OSDirW); /* We expect here that OSDir is of the form: C:\OSDir */ 365 366 testType2_W(L".", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 367 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); 371 372 testType1_W(L"..", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 373 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); 377 378 /* Restore the old current directory */ 379 SetCurrentDirectoryW(CurrentDirectory); 380 /****************************************/ 381 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); 388 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); 394 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); 399 400 wcscpy(Buffer, L"C:\\foobar\\"); 401 wcscat(Buffer, exenameW); 402 testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 403 404 wcscpy(Buffer, L"C:\\foobar\\.\\"); 405 wcscat(Buffer, exenameW); 406 testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 407 /***********************/ 408 409 /*** Existing path ***/ 410 wcscpy(Buffer, OSDirW); 411 testType2_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 412 413 wcscpy(Buffer, OSDirW); 414 wcscat(Buffer, L"\\"); 415 testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 416 417 wcscpy(Buffer, OSDirW); 418 wcscat(Buffer, L"\\\\"); 419 testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 420 421 wcscpy(Buffer, OSDirW); 422 wcscat(Buffer, L"\\*"); 423 testType2_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 424 425 wcscpy(Buffer, OSDirW); 426 wcscat(Buffer, L"\\.\\*"); 427 testType2_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 428 429 wcscpy(Buffer, OSDirW); 430 wcscat(Buffer, L"\\system32\\..\\*"); 431 testType2_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 432 433 /* Possibly a DOS device */ 434 wcscpy(Buffer, OSDirW); 435 wcscat(Buffer, L"\\nul"); 436 testType1_W(Buffer, 0xdeadbeef, (HANDLE)0x00000001, 0xdeadbeef, FALSE); 437 438 wcscpy(Buffer, OSDirW); 439 wcscat(Buffer, L"\\nul\\"); 440 testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 441 442 wcscpy(Buffer, OSDirW); 443 wcscat(Buffer, L"\\nul\\\\"); 444 testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 445 446 wcscpy(Buffer, OSDirW); 447 wcscat(Buffer, L"\\nul\\*"); 448 testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 449 450 wcscpy(Buffer, OSDirW); 451 wcscat(Buffer, L"\\toto"); 452 testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 453 454 wcscpy(Buffer, OSDirW); 455 wcscat(Buffer, L"\\toto\\"); 456 testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 457 458 wcscpy(Buffer, OSDirW); 459 wcscat(Buffer, L"\\toto\\\\"); 460 testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 461 462 wcscpy(Buffer, OSDirW); 463 wcscat(Buffer, L"\\toto\\*"); 464 testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 465 466 // wcscpy(Buffer, baseW); 467 // wcscat(Buffer, L"\\"); 468 // wcscat(Buffer, exenameW); 469 // testType2_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 470 471 // wcscpy(Buffer, baseW); 472 // wcscat(Buffer, L"\\.\\"); 473 // wcscat(Buffer, exenameW); 474 // testType2_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 475 /*********************/ 476 477 return; 478 } 479 480 481 static int init(void) 482 { 483 LPSTR p; 484 size_t i; 485 486 myARGC = winetest_get_mainargs(&myARGV); 487 if (!GetCurrentDirectoryA(sizeof(baseA)/sizeof(baseA[0]), baseA)) return 0; 488 strcpy(selfnameA, myARGV[0]); 489 490 /* Strip the path of selfname */ 491 if ((p = strrchr(selfnameA, '\\')) != NULL) 492 exenameA = p + 1; 493 else 494 exenameA = selfnameA; 495 496 if ((p = strrchr(exenameA, '/')) != NULL) 497 exenameA = p + 1; 498 499 if (!GetWindowsDirectoryA(OSDirA, sizeof(OSDirA)/sizeof(OSDirA[0]))) return 0; 500 501 /* Quick-and-dirty conversion ANSI --> UNICODE without the Win32 APIs */ 502 for (i = 0 ; i <= strlen(baseA) ; ++i) 503 { 504 baseW[i] = (WCHAR)baseA[i]; 505 } 506 for (i = 0 ; i <= strlen(selfnameA) ; ++i) 507 { 508 selfnameW[i] = (WCHAR)selfnameA[i]; 509 } 510 exenameW = selfnameW + (exenameA - selfnameA); 511 for (i = 0 ; i <= strlen(OSDirA) ; ++i) 512 { 513 OSDirW[i] = (WCHAR)OSDirA[i]; 514 } 515 516 return 1; 517 } 518 519 START_TEST(FindFiles) 520 { 521 int b = init(); 522 ok(b, "Basic init of FindFiles test\n"); 523 if (!b) return; 524 525 Test_FindFirstFileA(); 526 Test_FindFirstFileW(); 527 } 528