| 390 | |
| 391 | #ifdef _WIN32 |
| 392 | static bool GlobHelper(const String& pathSpec, int type, std::vector<String>& files, std::vector<String>& dirs) |
| 393 | { |
| 394 | HANDLE handle; |
| 395 | WIN32_FIND_DATA wfd; |
| 396 | |
| 397 | handle = FindFirstFile(pathSpec.CStr(), &wfd); |
| 398 | |
| 399 | if (handle == INVALID_HANDLE_VALUE) { |
| 400 | DWORD errorCode = GetLastError(); |
| 401 | |
| 402 | if (errorCode == ERROR_FILE_NOT_FOUND) |
| 403 | return false; |
| 404 | |
| 405 | BOOST_THROW_EXCEPTION(win32_error() |
| 406 | << boost::errinfo_api_function("FindFirstFile") |
| 407 | << errinfo_win32_error(errorCode) |
| 408 | << boost::errinfo_file_name(pathSpec)); |
| 409 | } |
| 410 | |
| 411 | do { |
| 412 | if (strcmp(wfd.cFileName, ".") == 0 || strcmp(wfd.cFileName, "..") == 0) |
| 413 | continue; |
| 414 | |
| 415 | String path = Utility::DirName(pathSpec) + "/" + wfd.cFileName; |
| 416 | |
| 417 | if ((wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && (type & GlobDirectory)) |
| 418 | dirs.push_back(path); |
| 419 | else if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && (type & GlobFile)) |
| 420 | files.push_back(path); |
| 421 | } while (FindNextFile(handle, &wfd)); |
| 422 | |
| 423 | if (!FindClose(handle)) { |
| 424 | BOOST_THROW_EXCEPTION(win32_error() |
| 425 | << boost::errinfo_api_function("FindClose") |
| 426 | << errinfo_win32_error(GetLastError())); |
| 427 | } |
| 428 | |
| 429 | return true; |
| 430 | } |
| 431 | #endif /* _WIN32 */ |
| 432 | |
| 433 | #ifndef _WIN32 |
no test coverage detected